| author | |
| committer | |
| log | 0181cfe8adfab3e7a682aaec10f932cd3279f40a |
| tree | 6931fc329da7b2b8175fce0b0b3b3f79d8d71f7e |
| parent | c712f18d7421b04f12a90841bbda5d6336f2286b |
| signature |
3 files changed, 44 insertions(+), 21 deletions(-)
src/zig_clang_cc1_main.cpp+8-2| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | ||
| 15 | #include "clang/Basic/Stack.h" | 15 | #include "clang/Basic/Stack.h" |
| 16 | #include "clang/Basic/TargetOptions.h" | 16 | #include "clang/Basic/TargetOptions.h" |
| 17 | #include "clang/CodeGen/ObjectFilePCHContainerOperations.h" | 17 | #include "clang/CodeGen/ObjectFilePCHContainerWriter.h" |
| 18 | #include "clang/Config/config.h" | 18 | #include "clang/Config/config.h" |
| 19 | #include "clang/Driver/DriverDiagnostic.h" | 19 | #include "clang/Driver/DriverDiagnostic.h" |
| 20 | #include "clang/Driver/Options.h" | 20 | #include "clang/Driver/Options.h" |
| ... | @@ -25,6 +25,7 @@ | ... | @@ -25,6 +25,7 @@ |
| 25 | #include "clang/Frontend/TextDiagnosticPrinter.h" | 25 | #include "clang/Frontend/TextDiagnosticPrinter.h" |
| 26 | #include "clang/Frontend/Utils.h" | 26 | #include "clang/Frontend/Utils.h" |
| 27 | #include "clang/FrontendTool/Utils.h" | 27 | #include "clang/FrontendTool/Utils.h" |
| 28 | #include "clang/Serialization/ObjectFilePCHContainerReader.h" | ||
| 28 | #include "llvm/ADT/Statistic.h" | 29 | #include "llvm/ADT/Statistic.h" |
| 29 | #include "llvm/ADT/StringExtras.h" | 30 | #include "llvm/ADT/StringExtras.h" |
| 30 | #include "llvm/Config/llvm-config.h" | 31 | #include "llvm/Config/llvm-config.h" |
| ... | @@ -44,6 +45,7 @@ | ... | @@ -44,6 +45,7 @@ |
| 44 | #include "llvm/Support/TargetSelect.h" | 45 | #include "llvm/Support/TargetSelect.h" |
| 45 | #include "llvm/Support/TimeProfiler.h" | 46 | #include "llvm/Support/TimeProfiler.h" |
| 46 | #include "llvm/Support/Timer.h" | 47 | #include "llvm/Support/Timer.h" |
| 48 | #include "llvm/Support/VirtualFileSystem.h" | ||
| 47 | #include "llvm/Support/raw_ostream.h" | 49 | #include "llvm/Support/raw_ostream.h" |
| 48 | #include "llvm/Target/TargetMachine.h" | 50 | #include "llvm/Target/TargetMachine.h" |
| 49 | #include "llvm/TargetParser/AArch64TargetParser.h" | 51 | #include "llvm/TargetParser/AArch64TargetParser.h" |
| ... | @@ -263,7 +265,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { | ... | @@ -263,7 +265,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { |
| 263 | CompilerInvocation::GetResourcesPath(Argv0, MainAddr); | 265 | CompilerInvocation::GetResourcesPath(Argv0, MainAddr); |
| 264 | 266 | ||
| 265 | // Create the actual diagnostics engine. | 267 | // Create the actual diagnostics engine. |
| 266 | Clang->createDiagnostics(); | 268 | Clang->createDiagnostics(*llvm::vfs::getRealFileSystem()); |
| 267 | if (!Clang->hasDiagnostics()) | 269 | if (!Clang->hasDiagnostics()) |
| 268 | return 1; | 270 | return 1; |
| 269 | 271 | ||
| ... | @@ -281,6 +283,10 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { | ... | @@ -281,6 +283,10 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { |
| 281 | // Execute the frontend actions. | 283 | // Execute the frontend actions. |
| 282 | { | 284 | { |
| 283 | llvm::TimeTraceScope TimeScope("ExecuteCompiler"); | 285 | llvm::TimeTraceScope TimeScope("ExecuteCompiler"); |
| 286 | bool TimePasses = Clang->getCodeGenOpts().TimePasses; | ||
| 287 | if (TimePasses) | ||
| 288 | Clang->createFrontendTimer(); | ||
| 289 | llvm::TimeRegion Timer(TimePasses ? &Clang->getFrontendTimer() : nullptr); | ||
| 284 | Success = ExecuteCompilerInvocation(Clang.get()); | 290 | Success = ExecuteCompilerInvocation(Clang.get()); |
| 285 | } | 291 | } |
| 286 | 292 |
src/zig_clang_cc1as_main.cpp+23-13| ... | @@ -96,10 +96,6 @@ struct AssemblerInvocation { | ... | @@ -96,10 +96,6 @@ struct AssemblerInvocation { |
| 96 | LLVM_PREFERRED_TYPE(bool) | 96 | LLVM_PREFERRED_TYPE(bool) |
| 97 | unsigned GenDwarfForAssembly : 1; | 97 | unsigned GenDwarfForAssembly : 1; |
| 98 | LLVM_PREFERRED_TYPE(bool) | 98 | LLVM_PREFERRED_TYPE(bool) |
| 99 | unsigned RelaxELFRelocations : 1; | ||
| 100 | LLVM_PREFERRED_TYPE(bool) | ||
| 101 | unsigned SSE2AVX : 1; | ||
| 102 | LLVM_PREFERRED_TYPE(bool) | ||
| 103 | unsigned Dwarf64 : 1; | 99 | unsigned Dwarf64 : 1; |
| 104 | unsigned DwarfVersion; | 100 | unsigned DwarfVersion; |
| 105 | std::string DwarfDebugFlags; | 101 | std::string DwarfDebugFlags; |
| ... | @@ -168,6 +164,13 @@ struct AssemblerInvocation { | ... | @@ -168,6 +164,13 @@ struct AssemblerInvocation { |
| 168 | 164 | ||
| 169 | LLVM_PREFERRED_TYPE(bool) | 165 | LLVM_PREFERRED_TYPE(bool) |
| 170 | unsigned Crel : 1; | 166 | unsigned Crel : 1; |
| 167 | LLVM_PREFERRED_TYPE(bool) | ||
| 168 | unsigned ImplicitMapsyms : 1; | ||
| 169 | |||
| 170 | LLVM_PREFERRED_TYPE(bool) | ||
| 171 | unsigned X86RelaxRelocations : 1; | ||
| 172 | LLVM_PREFERRED_TYPE(bool) | ||
| 173 | unsigned X86Sse2Avx : 1; | ||
| 171 | 174 | ||
| 172 | /// The name of the relocation model to use. | 175 | /// The name of the relocation model to use. |
| 173 | std::string RelocationModel; | 176 | std::string RelocationModel; |
| ... | @@ -199,7 +202,6 @@ public: | ... | @@ -199,7 +202,6 @@ public: |
| 199 | ShowInst = 0; | 202 | ShowInst = 0; |
| 200 | ShowEncoding = 0; | 203 | ShowEncoding = 0; |
| 201 | RelaxAll = 0; | 204 | RelaxAll = 0; |
| 202 | SSE2AVX = 0; | ||
| 203 | NoExecStack = 0; | 205 | NoExecStack = 0; |
| 204 | FatalWarnings = 0; | 206 | FatalWarnings = 0; |
| 205 | NoWarn = 0; | 207 | NoWarn = 0; |
| ... | @@ -211,6 +213,9 @@ public: | ... | @@ -211,6 +213,9 @@ public: |
| 211 | EmitDwarfUnwind = EmitDwarfUnwindType::Default; | 213 | EmitDwarfUnwind = EmitDwarfUnwindType::Default; |
| 212 | EmitCompactUnwindNonCanonical = false; | 214 | EmitCompactUnwindNonCanonical = false; |
| 213 | Crel = false; | 215 | Crel = false; |
| 216 | ImplicitMapsyms = 0; | ||
| 217 | X86RelaxRelocations = 0; | ||
| 218 | X86Sse2Avx = 0; | ||
| 214 | } | 219 | } |
| 215 | 220 | ||
| 216 | static bool CreateFromArgs(AssemblerInvocation &Res, | 221 | static bool CreateFromArgs(AssemblerInvocation &Res, |
| ... | @@ -290,8 +295,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, | ... | @@ -290,8 +295,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, |
| 290 | .Default(llvm::DebugCompressionType::None); | 295 | .Default(llvm::DebugCompressionType::None); |
| 291 | } | 296 | } |
| 292 | 297 | ||
| 293 | Opts.RelaxELFRelocations = !Args.hasArg(OPT_mrelax_relocations_no); | ||
| 294 | Opts.SSE2AVX = Args.hasArg(OPT_msse2avx); | ||
| 295 | if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32)) | 298 | if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32)) |
| 296 | Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64); | 299 | Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64); |
| 297 | Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags); | 300 | Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags); |
| ... | @@ -382,6 +385,9 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, | ... | @@ -382,6 +385,9 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, |
| 382 | Opts.EmitCompactUnwindNonCanonical = | 385 | Opts.EmitCompactUnwindNonCanonical = |
| 383 | Args.hasArg(OPT_femit_compact_unwind_non_canonical); | 386 | Args.hasArg(OPT_femit_compact_unwind_non_canonical); |
| 384 | Opts.Crel = Args.hasArg(OPT_crel); | 387 | Opts.Crel = Args.hasArg(OPT_crel); |
| 388 | Opts.ImplicitMapsyms = Args.hasArg(OPT_mmapsyms_implicit); | ||
| 389 | Opts.X86RelaxRelocations = !Args.hasArg(OPT_mrelax_relocations_no); | ||
| 390 | Opts.X86Sse2Avx = Args.hasArg(OPT_msse2avx); | ||
| 385 | 391 | ||
| 386 | Opts.AsSecureLogFile = Args.getLastArgValue(OPT_as_secure_log_file); | 392 | Opts.AsSecureLogFile = Args.getLastArgValue(OPT_as_secure_log_file); |
| 387 | 393 | ||
| ... | @@ -440,8 +446,9 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, | ... | @@ -440,8 +446,9 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, |
| 440 | MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical; | 446 | MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical; |
| 441 | MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels; | 447 | MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels; |
| 442 | MCOptions.Crel = Opts.Crel; | 448 | MCOptions.Crel = Opts.Crel; |
| 443 | MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations; | 449 | MCOptions.ImplicitMapSyms = Opts.ImplicitMapsyms; |
| 444 | MCOptions.X86Sse2Avx = Opts.SSE2AVX; | 450 | MCOptions.X86RelaxRelocations = Opts.X86RelaxRelocations; |
| 451 | MCOptions.X86Sse2Avx = Opts.X86Sse2Avx; | ||
| 445 | MCOptions.CompressDebugSections = Opts.CompressDebugSections; | 452 | MCOptions.CompressDebugSections = Opts.CompressDebugSections; |
| 446 | MCOptions.AsSecureLogFile = Opts.AsSecureLogFile; | 453 | MCOptions.AsSecureLogFile = Opts.AsSecureLogFile; |
| 447 | 454 | ||
| ... | @@ -489,10 +496,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, | ... | @@ -489,10 +496,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, |
| 489 | // MCObjectFileInfo needs a MCContext reference in order to initialize itself. | 496 | // MCObjectFileInfo needs a MCContext reference in order to initialize itself. |
| 490 | std::unique_ptr<MCObjectFileInfo> MOFI( | 497 | std::unique_ptr<MCObjectFileInfo> MOFI( |
| 491 | TheTarget->createMCObjectFileInfo(Ctx, PIC)); | 498 | TheTarget->createMCObjectFileInfo(Ctx, PIC)); |
| 492 | if (Opts.DarwinTargetVariantTriple) | ||
| 493 | MOFI->setDarwinTargetVariantTriple(*Opts.DarwinTargetVariantTriple); | ||
| 494 | if (!Opts.DarwinTargetVariantSDKVersion.empty()) | ||
| 495 | MOFI->setDarwinTargetVariantSDKVersion(Opts.DarwinTargetVariantSDKVersion); | ||
| 496 | Ctx.setObjectFileInfo(MOFI.get()); | 499 | Ctx.setObjectFileInfo(MOFI.get()); |
| 497 | 500 | ||
| 498 | if (Opts.GenDwarfForAssembly) | 501 | if (Opts.GenDwarfForAssembly) |
| ... | @@ -574,6 +577,13 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, | ... | @@ -574,6 +577,13 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, |
| 574 | Str.reset(TheTarget->createMCObjectStreamer( | 577 | Str.reset(TheTarget->createMCObjectStreamer( |
| 575 | T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI)); | 578 | T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI)); |
| 576 | Str.get()->initSections(Opts.NoExecStack, *STI); | 579 | Str.get()->initSections(Opts.NoExecStack, *STI); |
| 580 | if (T.isOSBinFormatMachO() && T.isOSDarwin()) { | ||
| 581 | Triple *TVT = Opts.DarwinTargetVariantTriple | ||
| 582 | ? &*Opts.DarwinTargetVariantTriple | ||
| 583 | : nullptr; | ||
| 584 | Str->emitVersionForTarget(T, VersionTuple(), TVT, | ||
| 585 | Opts.DarwinTargetVariantSDKVersion); | ||
| 586 | } | ||
| 577 | } | 587 | } |
| 578 | 588 | ||
| 579 | // When -fembed-bitcode is passed to clang_as, a 1-byte marker | 589 | // When -fembed-bitcode is passed to clang_as, a 1-byte marker |
src/zig_clang_driver.cpp+13-6| ... | @@ -29,6 +29,7 @@ | ... | @@ -29,6 +29,7 @@ |
| 29 | #include "llvm/ADT/SmallString.h" | 29 | #include "llvm/ADT/SmallString.h" |
| 30 | #include "llvm/ADT/SmallVector.h" | 30 | #include "llvm/ADT/SmallVector.h" |
| 31 | #include "llvm/ADT/StringSet.h" | 31 | #include "llvm/ADT/StringSet.h" |
| 32 | #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX | ||
| 32 | #include "llvm/Option/ArgList.h" | 33 | #include "llvm/Option/ArgList.h" |
| 33 | #include "llvm/Option/OptTable.h" | 34 | #include "llvm/Option/OptTable.h" |
| 34 | #include "llvm/Option/Option.h" | 35 | #include "llvm/Option/Option.h" |
| ... | @@ -46,12 +47,14 @@ | ... | @@ -46,12 +47,14 @@ |
| 46 | #include "llvm/Support/StringSaver.h" | 47 | #include "llvm/Support/StringSaver.h" |
| 47 | #include "llvm/Support/TargetSelect.h" | 48 | #include "llvm/Support/TargetSelect.h" |
| 48 | #include "llvm/Support/Timer.h" | 49 | #include "llvm/Support/Timer.h" |
| 50 | #include "llvm/Support/VirtualFileSystem.h" | ||
| 49 | #include "llvm/Support/raw_ostream.h" | 51 | #include "llvm/Support/raw_ostream.h" |
| 50 | #include "llvm/TargetParser/Host.h" | 52 | #include "llvm/TargetParser/Host.h" |
| 51 | #include <memory> | 53 | #include <memory> |
| 52 | #include <optional> | 54 | #include <optional> |
| 53 | #include <set> | 55 | #include <set> |
| 54 | #include <system_error> | 56 | #include <system_error> |
| 57 | |||
| 55 | using namespace clang; | 58 | using namespace clang; |
| 56 | using namespace clang::driver; | 59 | using namespace clang::driver; |
| 57 | using namespace llvm::opt; | 60 | using namespace llvm::opt; |
| ... | @@ -327,9 +330,11 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex | ... | @@ -327,9 +330,11 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex |
| 327 | Diags.takeClient(), std::move(SerializedConsumer))); | 330 | Diags.takeClient(), std::move(SerializedConsumer))); |
| 328 | } | 331 | } |
| 329 | 332 | ||
| 330 | ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false); | 333 | auto VFS = llvm::vfs::getRealFileSystem(); |
| 334 | ProcessWarningOptions(Diags, *DiagOpts, *VFS, /*ReportDiags=*/false); | ||
| 331 | 335 | ||
| 332 | Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags); | 336 | Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags, |
| 337 | /*Title=*/"clang LLVM compiler", VFS); | ||
| 333 | auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(ProgName); | 338 | auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(ProgName); |
| 334 | TheDriver.setTargetAndMode(TargetAndMode); | 339 | TheDriver.setTargetAndMode(TargetAndMode); |
| 335 | // If -canonical-prefixes is set, GetExecutablePath will have resolved Path | 340 | // If -canonical-prefixes is set, GetExecutablePath will have resolved Path |
| ... | @@ -345,10 +350,12 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex | ... | @@ -345,10 +350,12 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex |
| 345 | if (!SetBackdoorDriverOutputsFromEnvVars(TheDriver)) | 350 | if (!SetBackdoorDriverOutputsFromEnvVars(TheDriver)) |
| 346 | return 1; | 351 | return 1; |
| 347 | 352 | ||
| 353 | auto ExecuteCC1WithContext = | ||
| 354 | [&ToolContext](SmallVectorImpl<const char *> &ArgV) { | ||
| 355 | return ExecuteCC1Tool(ArgV, ToolContext); | ||
| 356 | }; | ||
| 348 | if (!UseNewCC1Process) { | 357 | if (!UseNewCC1Process) { |
| 349 | TheDriver.CC1Main = [ToolContext](SmallVectorImpl<const char *> &ArgV) { | 358 | TheDriver.CC1Main = ExecuteCC1WithContext; |
| 350 | return ExecuteCC1Tool(ArgV, ToolContext); | ||
| 351 | }; | ||
| 352 | // Ensure the CC1Command actually catches cc1 crashes | 359 | // Ensure the CC1Command actually catches cc1 crashes |
| 353 | llvm::CrashRecoveryContext::Enable(); | 360 | llvm::CrashRecoveryContext::Enable(); |
| 354 | } | 361 | } |
| ... | @@ -427,7 +434,7 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex | ... | @@ -427,7 +434,7 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex |
| 427 | if (!UseNewCC1Process && IsCrash) { | 434 | if (!UseNewCC1Process && IsCrash) { |
| 428 | // When crashing in -fintegrated-cc1 mode, bury the timer pointers, because | 435 | // When crashing in -fintegrated-cc1 mode, bury the timer pointers, because |
| 429 | // the internal linked list might point to already released stack frames. | 436 | // the internal linked list might point to already released stack frames. |
| 430 | llvm::BuryPointer(llvm::TimerGroup::aquireDefaultGroup()); | 437 | llvm::BuryPointer(llvm::TimerGroup::acquireTimerGlobals()); |
| 431 | } else { | 438 | } else { |
| 432 | // If any timers were active but haven't been destroyed yet, print their | 439 | // If any timers were active but haven't been destroyed yet, print their |
| 433 | // results now. This happens in -disable-free mode. | 440 | // results now. This happens in -disable-free mode. |