forked from OSchip/llvm-project
[clang-cl] Add support for /Brepro
The /Brepro flag controls whether or not the compiler should embed timestamps into the object file. Object files which do not embed timestamps are not suitable for incremental linking but are suitable for hermetic build systems and staged self-hosts of clang. A normal clang spelling of this flag has been added, -mincremental-linker-compatible. llvm-svn: 256204
This commit is contained in:
parent
03e2cc3007
commit
2b9349db38
|
@ -52,6 +52,12 @@ class CLRemainingArgs<string name> : Option<["/", "-"], name,
|
|||
// (We don't put any of these in cl_compile_Group as the options they alias are
|
||||
// already in the right group.)
|
||||
|
||||
def _SLASH_Brepro : CLFlag<"Brepro">,
|
||||
HelpText<"Emit an object file which can be reproduced over time">,
|
||||
Alias<mincremental_linker_compatible>;
|
||||
def _SLASH_Brepro_ : CLFlag<"Brepro-">,
|
||||
HelpText<"Emit an object file which cannot be reproduced over time">,
|
||||
Alias<mno_incremental_linker_compatible>;
|
||||
def _SLASH_C : CLFlag<"C">,
|
||||
HelpText<"Don't discard comments when preprocessing">, Alias<C>;
|
||||
def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias<c>;
|
||||
|
|
|
@ -1459,6 +1459,11 @@ def mred_zone : Flag<["-"], "mred-zone">, Group<m_Group>;
|
|||
def mregparm_EQ : Joined<["-"], "mregparm=">, Group<m_Group>;
|
||||
def mrelax_all : Flag<["-"], "mrelax-all">, Group<m_Group>, Flags<[CC1Option,CC1AsOption]>,
|
||||
HelpText<"(integrated-as) Relax all machine instructions">;
|
||||
def mincremental_linker_compatible : Flag<["-"], "mincremental-linker-compatible">, Group<m_Group>,
|
||||
Flags<[CC1Option,CC1AsOption]>,
|
||||
HelpText<"(integrated-as) Emit an object file which can be used with an incremental linker">;
|
||||
def mno_incremental_linker_compatible : Flag<["-"], "mno-incremental-linker-compatible">, Group<m_Group>,
|
||||
HelpText<"(integrated-as) Emit an object file which cannot be used with an incremental linker">;
|
||||
def mrtd : Flag<["-"], "mrtd">, Group<m_Group>, Flags<[CC1Option]>,
|
||||
HelpText<"Make StdCall calling convention the default">;
|
||||
def msmall_data_threshold_EQ : Joined <["-"], "msmall-data-threshold=">, Group<m_Group>;
|
||||
|
|
|
@ -75,6 +75,9 @@ CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
|
|||
///< compile step.
|
||||
CODEGENOPT(EmitFunctionSummary, 1, 0) ///< Set when -flto=thin is enabled on the
|
||||
///< compile step.
|
||||
CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which can
|
||||
///< be used with an incremental
|
||||
///< linker.
|
||||
CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
|
||||
CODEGENOPT(MergeFunctions , 1, 0) ///< Set when -fmerge-functions is enabled.
|
||||
CODEGENOPT(MSVolatile , 1, 0) ///< Set when /volatile:ms is enabled.
|
||||
|
|
|
@ -571,6 +571,8 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
|
|||
Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
|
||||
Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm;
|
||||
Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack;
|
||||
Options.MCOptions.MCIncrementalLinkerCompatible =
|
||||
CodeGenOpts.IncrementalLinkerCompatible;
|
||||
Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
|
||||
Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
|
||||
Options.MCOptions.ABIName = TargetOpts.ABI;
|
||||
|
|
|
@ -2567,6 +2567,15 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
|
|||
if (UseRelaxAll(C, Args))
|
||||
CmdArgs.push_back("-mrelax-all");
|
||||
|
||||
// Only default to -mincremental-linker-compatible if we think we are
|
||||
// targeting the MSVC linker.
|
||||
bool DefaultIncrementalLinkerCompatible =
|
||||
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
|
||||
if (Args.hasFlag(options::OPT_mincremental_linker_compatible,
|
||||
options::OPT_mno_incremental_linker_compatible,
|
||||
DefaultIncrementalLinkerCompatible))
|
||||
CmdArgs.push_back("-mincremental-linker-compatible");
|
||||
|
||||
// When passing -I arguments to the assembler we sometimes need to
|
||||
// unconditionally take the next argument. For example, when parsing
|
||||
// '-Wa,-I -Wa,foo' we need to accept the -Wa,foo arg after seeing the
|
||||
|
|
|
@ -500,6 +500,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
|
||||
Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
|
||||
Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
|
||||
Opts.IncrementalLinkerCompatible =
|
||||
Args.hasArg(OPT_mincremental_linker_compatible);
|
||||
Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
|
||||
Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels);
|
||||
Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm);
|
||||
|
|
|
@ -376,6 +376,15 @@
|
|||
// Z7: "-gcodeview"
|
||||
// Z7: "-debug-info-kind=line-tables-only"
|
||||
|
||||
// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
|
||||
// BreproDefault: "-mincremental-linker-compatible"
|
||||
|
||||
// RUN: %clang_cl /Brepro- /Brepro /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro %s
|
||||
// Brepro: "-mincremental-linker-compatible"
|
||||
|
||||
// RUN: %clang_cl /Brepro /Brepro- /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro_ %s
|
||||
// Brepro_-NOT: "-mincremental-linker-compatible"
|
||||
|
||||
// This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
|
||||
// later on the command line, so it should win. Interestingly the cc1 arguments
|
||||
// came out right, but had wrong semantics, because an invariant assumed by
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// RUN: %clang '-###' %s -c -o tmp.o -target i686-pc-linux-gnu -integrated-as -mincremental-linker-compatible 2>&1 | FileCheck %s --check-prefix=TEST1
|
||||
// TEST1: "-cc1" {{.*}} "-mincremental-linker-compatible"
|
||||
|
||||
// RUN: %clang '-###' %s -c -o tmp.o -target i686-pc-linux-gnu -integrated-as -mno-incremental-linker-compatible 2>&1 | FileCheck %s --check-prefix=TEST2
|
||||
// TEST2-NOT: "-cc1" {{.*}} "-mincremental-linker-compatible"
|
||||
|
||||
// RUN: %clang '-###' %s -c -o tmp.o -target i686-pc-linux-gnu -integrated-as -mno-incremental-linker-compatible -mincremental-linker-compatible 2>&1 | FileCheck %s --check-prefix=TEST3
|
||||
// TEST3: "-cc1" {{.*}} "-mincremental-linker-compatible"
|
||||
|
||||
// RUN: %clang '-###' %s -c -o tmp.o -target i686-pc-linux-gnu -integrated-as -mincremental-linker-compatible -mno-incremental-linker-compatible 2>&1 | FileCheck %s --check-prefix=TEST4
|
||||
// TEST4-NOT: "-cc1" {{.*}} "-mincremental-linker-compatible"
|
||||
|
||||
// RUN: %clang '-###' %s -c -o tmp.o -target i686-pc-mingw32 -integrated-as 2>&1 | FileCheck %s --check-prefix=TEST5
|
||||
// TEST5-NOT: "-cc1" {{.*}} "-mincremental-linker-compatible"
|
||||
|
||||
// RUN: %clang '-###' %s -c -o tmp.o -target i686-pc-win32 -integrated-as 2>&1 | FileCheck %s --check-prefix=TEST6
|
||||
// TEST6: "-cc1" {{.*}} "-mincremental-linker-compatible"
|
|
@ -125,6 +125,7 @@ struct AssemblerInvocation {
|
|||
unsigned RelaxAll : 1;
|
||||
unsigned NoExecStack : 1;
|
||||
unsigned FatalWarnings : 1;
|
||||
unsigned IncrementalLinkerCompatible : 1;
|
||||
|
||||
/// The name of the relocation model to use.
|
||||
std::string RelocationModel;
|
||||
|
@ -144,6 +145,7 @@ public:
|
|||
RelaxAll = 0;
|
||||
NoExecStack = 0;
|
||||
FatalWarnings = 0;
|
||||
IncrementalLinkerCompatible = 0;
|
||||
DwarfVersion = 0;
|
||||
}
|
||||
|
||||
|
@ -248,6 +250,8 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
|
|||
Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
|
||||
Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
|
||||
Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
|
||||
Opts.IncrementalLinkerCompatible =
|
||||
Args.hasArg(OPT_mincremental_linker_compatible);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
@ -394,9 +398,10 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
|
|||
MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple,
|
||||
Opts.CPU);
|
||||
Triple T(Opts.Triple);
|
||||
Str.reset(TheTarget->createMCObjectStreamer(T, Ctx, *MAB, *Out, CE, *STI,
|
||||
Opts.RelaxAll,
|
||||
/*DWARFMustBeAtTheEnd*/ true));
|
||||
Str.reset(TheTarget->createMCObjectStreamer(
|
||||
T, Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,
|
||||
Opts.IncrementalLinkerCompatible,
|
||||
/*DWARFMustBeAtTheEnd*/ true));
|
||||
Str.get()->InitSections(Opts.NoExecStack);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue