mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
zig cc: Update driver files to Clang 20.
This commit is contained in:
parent
c712f18d74
commit
0181cfe8ad
3 changed files with 44 additions and 21 deletions
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "clang/Basic/Stack.h"
|
||||
#include "clang/Basic/TargetOptions.h"
|
||||
#include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
|
||||
#include "clang/CodeGen/ObjectFilePCHContainerWriter.h"
|
||||
#include "clang/Config/config.h"
|
||||
#include "clang/Driver/DriverDiagnostic.h"
|
||||
#include "clang/Driver/Options.h"
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
#include "clang/Frontend/TextDiagnosticPrinter.h"
|
||||
#include "clang/Frontend/Utils.h"
|
||||
#include "clang/FrontendTool/Utils.h"
|
||||
#include "clang/Serialization/ObjectFilePCHContainerReader.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Config/llvm-config.h"
|
||||
|
|
@ -44,6 +45,7 @@
|
|||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Support/TimeProfiler.h"
|
||||
#include "llvm/Support/Timer.h"
|
||||
#include "llvm/Support/VirtualFileSystem.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/TargetParser/AArch64TargetParser.h"
|
||||
|
|
@ -263,7 +265,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
|
|||
CompilerInvocation::GetResourcesPath(Argv0, MainAddr);
|
||||
|
||||
// Create the actual diagnostics engine.
|
||||
Clang->createDiagnostics();
|
||||
Clang->createDiagnostics(*llvm::vfs::getRealFileSystem());
|
||||
if (!Clang->hasDiagnostics())
|
||||
return 1;
|
||||
|
||||
|
|
@ -281,6 +283,10 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
|
|||
// Execute the frontend actions.
|
||||
{
|
||||
llvm::TimeTraceScope TimeScope("ExecuteCompiler");
|
||||
bool TimePasses = Clang->getCodeGenOpts().TimePasses;
|
||||
if (TimePasses)
|
||||
Clang->createFrontendTimer();
|
||||
llvm::TimeRegion Timer(TimePasses ? &Clang->getFrontendTimer() : nullptr);
|
||||
Success = ExecuteCompilerInvocation(Clang.get());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,10 +96,6 @@ struct AssemblerInvocation {
|
|||
LLVM_PREFERRED_TYPE(bool)
|
||||
unsigned GenDwarfForAssembly : 1;
|
||||
LLVM_PREFERRED_TYPE(bool)
|
||||
unsigned RelaxELFRelocations : 1;
|
||||
LLVM_PREFERRED_TYPE(bool)
|
||||
unsigned SSE2AVX : 1;
|
||||
LLVM_PREFERRED_TYPE(bool)
|
||||
unsigned Dwarf64 : 1;
|
||||
unsigned DwarfVersion;
|
||||
std::string DwarfDebugFlags;
|
||||
|
|
@ -168,6 +164,13 @@ struct AssemblerInvocation {
|
|||
|
||||
LLVM_PREFERRED_TYPE(bool)
|
||||
unsigned Crel : 1;
|
||||
LLVM_PREFERRED_TYPE(bool)
|
||||
unsigned ImplicitMapsyms : 1;
|
||||
|
||||
LLVM_PREFERRED_TYPE(bool)
|
||||
unsigned X86RelaxRelocations : 1;
|
||||
LLVM_PREFERRED_TYPE(bool)
|
||||
unsigned X86Sse2Avx : 1;
|
||||
|
||||
/// The name of the relocation model to use.
|
||||
std::string RelocationModel;
|
||||
|
|
@ -199,7 +202,6 @@ public:
|
|||
ShowInst = 0;
|
||||
ShowEncoding = 0;
|
||||
RelaxAll = 0;
|
||||
SSE2AVX = 0;
|
||||
NoExecStack = 0;
|
||||
FatalWarnings = 0;
|
||||
NoWarn = 0;
|
||||
|
|
@ -211,6 +213,9 @@ public:
|
|||
EmitDwarfUnwind = EmitDwarfUnwindType::Default;
|
||||
EmitCompactUnwindNonCanonical = false;
|
||||
Crel = false;
|
||||
ImplicitMapsyms = 0;
|
||||
X86RelaxRelocations = 0;
|
||||
X86Sse2Avx = 0;
|
||||
}
|
||||
|
||||
static bool CreateFromArgs(AssemblerInvocation &Res,
|
||||
|
|
@ -290,8 +295,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
|
|||
.Default(llvm::DebugCompressionType::None);
|
||||
}
|
||||
|
||||
Opts.RelaxELFRelocations = !Args.hasArg(OPT_mrelax_relocations_no);
|
||||
Opts.SSE2AVX = Args.hasArg(OPT_msse2avx);
|
||||
if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32))
|
||||
Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64);
|
||||
Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
|
||||
|
|
@ -382,6 +385,9 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
|
|||
Opts.EmitCompactUnwindNonCanonical =
|
||||
Args.hasArg(OPT_femit_compact_unwind_non_canonical);
|
||||
Opts.Crel = Args.hasArg(OPT_crel);
|
||||
Opts.ImplicitMapsyms = Args.hasArg(OPT_mmapsyms_implicit);
|
||||
Opts.X86RelaxRelocations = !Args.hasArg(OPT_mrelax_relocations_no);
|
||||
Opts.X86Sse2Avx = Args.hasArg(OPT_msse2avx);
|
||||
|
||||
Opts.AsSecureLogFile = Args.getLastArgValue(OPT_as_secure_log_file);
|
||||
|
||||
|
|
@ -440,8 +446,9 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
|
|||
MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
|
||||
MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels;
|
||||
MCOptions.Crel = Opts.Crel;
|
||||
MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations;
|
||||
MCOptions.X86Sse2Avx = Opts.SSE2AVX;
|
||||
MCOptions.ImplicitMapSyms = Opts.ImplicitMapsyms;
|
||||
MCOptions.X86RelaxRelocations = Opts.X86RelaxRelocations;
|
||||
MCOptions.X86Sse2Avx = Opts.X86Sse2Avx;
|
||||
MCOptions.CompressDebugSections = Opts.CompressDebugSections;
|
||||
MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;
|
||||
|
||||
|
|
@ -489,10 +496,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
|
|||
// MCObjectFileInfo needs a MCContext reference in order to initialize itself.
|
||||
std::unique_ptr<MCObjectFileInfo> MOFI(
|
||||
TheTarget->createMCObjectFileInfo(Ctx, PIC));
|
||||
if (Opts.DarwinTargetVariantTriple)
|
||||
MOFI->setDarwinTargetVariantTriple(*Opts.DarwinTargetVariantTriple);
|
||||
if (!Opts.DarwinTargetVariantSDKVersion.empty())
|
||||
MOFI->setDarwinTargetVariantSDKVersion(Opts.DarwinTargetVariantSDKVersion);
|
||||
Ctx.setObjectFileInfo(MOFI.get());
|
||||
|
||||
if (Opts.GenDwarfForAssembly)
|
||||
|
|
@ -574,6 +577,13 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
|
|||
Str.reset(TheTarget->createMCObjectStreamer(
|
||||
T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI));
|
||||
Str.get()->initSections(Opts.NoExecStack, *STI);
|
||||
if (T.isOSBinFormatMachO() && T.isOSDarwin()) {
|
||||
Triple *TVT = Opts.DarwinTargetVariantTriple
|
||||
? &*Opts.DarwinTargetVariantTriple
|
||||
: nullptr;
|
||||
Str->emitVersionForTarget(T, VersionTuple(), TVT,
|
||||
Opts.DarwinTargetVariantSDKVersion);
|
||||
}
|
||||
}
|
||||
|
||||
// When -fembed-bitcode is passed to clang_as, a 1-byte marker
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Option/OptTable.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
|
|
@ -46,12 +47,14 @@
|
|||
#include "llvm/Support/StringSaver.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Support/Timer.h"
|
||||
#include "llvm/Support/VirtualFileSystem.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/TargetParser/Host.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <system_error>
|
||||
|
||||
using namespace clang;
|
||||
using namespace clang::driver;
|
||||
using namespace llvm::opt;
|
||||
|
|
@ -327,9 +330,11 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex
|
|||
Diags.takeClient(), std::move(SerializedConsumer)));
|
||||
}
|
||||
|
||||
ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false);
|
||||
auto VFS = llvm::vfs::getRealFileSystem();
|
||||
ProcessWarningOptions(Diags, *DiagOpts, *VFS, /*ReportDiags=*/false);
|
||||
|
||||
Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
|
||||
Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags,
|
||||
/*Title=*/"clang LLVM compiler", VFS);
|
||||
auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(ProgName);
|
||||
TheDriver.setTargetAndMode(TargetAndMode);
|
||||
// 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
|
|||
if (!SetBackdoorDriverOutputsFromEnvVars(TheDriver))
|
||||
return 1;
|
||||
|
||||
auto ExecuteCC1WithContext =
|
||||
[&ToolContext](SmallVectorImpl<const char *> &ArgV) {
|
||||
return ExecuteCC1Tool(ArgV, ToolContext);
|
||||
};
|
||||
if (!UseNewCC1Process) {
|
||||
TheDriver.CC1Main = [ToolContext](SmallVectorImpl<const char *> &ArgV) {
|
||||
return ExecuteCC1Tool(ArgV, ToolContext);
|
||||
};
|
||||
TheDriver.CC1Main = ExecuteCC1WithContext;
|
||||
// Ensure the CC1Command actually catches cc1 crashes
|
||||
llvm::CrashRecoveryContext::Enable();
|
||||
}
|
||||
|
|
@ -427,7 +434,7 @@ static int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContex
|
|||
if (!UseNewCC1Process && IsCrash) {
|
||||
// When crashing in -fintegrated-cc1 mode, bury the timer pointers, because
|
||||
// the internal linked list might point to already released stack frames.
|
||||
llvm::BuryPointer(llvm::TimerGroup::aquireDefaultGroup());
|
||||
llvm::BuryPointer(llvm::TimerGroup::acquireTimerGlobals());
|
||||
} else {
|
||||
// If any timers were active but haven't been destroyed yet, print their
|
||||
// results now. This happens in -disable-free mode.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue