zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 83ff94406e13e18c8826cd48a68c2c8d676feaac (tree)
parent 9c2d8056ce177fef2a1b859016b11362686213b1
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Wed, 16 Dec 2020 10:40:56 +0100

Update clang drivers

llvm commit b2851aea80e5a8f0cfd6c3c5a56a6b00fb28c6b6

Diffstat:
Msrc/zig_clang_cc1as_main.cpp | 29++++++++++++++---------------
Msrc/zig_clang_driver.cpp | 7+++++++
2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/zig_clang_cc1as_main.cpp b/src/zig_clang_cc1as_main.cpp @@ -221,19 +221,13 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, // Any DebugInfoKind implies GenDwarfForAssembly. Opts.GenDwarfForAssembly = Args.hasArg(OPT_debug_info_kind_EQ); - if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections, - OPT_compress_debug_sections_EQ)) { - if (A->getOption().getID() == OPT_compress_debug_sections) { - // TODO: be more clever about the compression type auto-detection - Opts.CompressDebugSections = llvm::DebugCompressionType::GNU; - } else { - Opts.CompressDebugSections = - llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue()) - .Case("none", llvm::DebugCompressionType::None) - .Case("zlib", llvm::DebugCompressionType::Z) - .Case("zlib-gnu", llvm::DebugCompressionType::GNU) - .Default(llvm::DebugCompressionType::None); - } + if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections_EQ)) { + Opts.CompressDebugSections = + llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue()) + .Case("none", llvm::DebugCompressionType::None) + .Case("zlib", llvm::DebugCompressionType::Z) + .Case("zlib-gnu", llvm::DebugCompressionType::GNU) + .Default(llvm::DebugCompressionType::None); } Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations); @@ -434,8 +428,11 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, std::unique_ptr<MCStreamer> Str; std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo()); + assert(MCII && "Unable to create instruction info!"); + std::unique_ptr<MCSubtargetInfo> STI( TheTarget->createMCSubtargetInfo(Opts.Triple, Opts.CPU, FS)); + assert(STI && "Unable to create subtarget info!"); raw_pwrite_stream *Out = FDOS.get(); std::unique_ptr<buffer_ostream> BOS; @@ -474,6 +471,8 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx)); std::unique_ptr<MCAsmBackend> MAB( TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions)); + assert(MAB && "Unable to create asm backend!"); + std::unique_ptr<MCObjectWriter> OW = DwoOS ? MAB->createDwoObjectWriter(*Out, *DwoOS) : MAB->createObjectWriter(*Out); @@ -526,8 +525,8 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, Failed = Parser->Run(Opts.NoInitialTextSection); } - // Close Streamer first. - // It might have a reference to the output stream. + // Parser has a reference to the output stream (Str), so close Parser first. + Parser.reset(); Str.reset(); // Close the output stream early. BOS.reset(); diff --git a/src/zig_clang_driver.cpp b/src/zig_clang_driver.cpp @@ -529,6 +529,13 @@ int ZigClang_main(int argc_, const char **argv_) { #ifdef _WIN32 IsCrash |= CommandRes == 3; #endif +#if LLVM_ON_UNIX + // When running in integrated-cc1 mode, the CrashRecoveryContext returns + // the same codes as if the program crashed. See section "Exit Status for + // Commands": + // https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html + IsCrash |= CommandRes > 128; +#endif if (IsCrash) { TheDriver.generateCompilationDiagnostics(*C, *FailingCommand); break;