diff options
| author | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2018-04-20 16:29:03 +0000 |
|---|---|---|
| committer | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2018-04-20 16:29:03 +0000 |
| commit | 2889dbd84158f6ec5b705a327162a48a65bf6147 (patch) | |
| tree | 4e827fc20132cf312cfbaaaf7cb032b91065dd3b /lib | |
| parent | 44fa4e90c42a5754b690391e84d330f5e0eff1fa (diff) | |
| download | clang-2889dbd84158f6ec5b705a327162a48a65bf6147.tar.gz | |
[CodeGen] Add an option to suppress output of llvm.ident
Summary:
By default Clang outputs its version (including git commit hash, in
case of trunk builds) into object and assembly files. It might be
useful to have an option to disable this, especially for debugging
purposes.
This patch implements new command line flags -Qn and -Qy (the names
are chosen for compatibility with GCC). -Qn disables output of
the 'llvm.ident' metadata string and the 'producer' debug info. -Qy
(enabled by default) does the opposite.
Reviewers: faisalv, echristo, aprantl
Reviewed By: aprantl
Subscribers: aprantl, cfe-commits, JDevlieghere, rogfer01
Differential Revision: https://reviews.llvm.org/D45255
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 3 | ||||
| -rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 3 | ||||
| -rw-r--r-- | lib/Driver/ToolChains/Clang.cpp | 3 | ||||
| -rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 2 |
4 files changed, 9 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index bdd326d70e..474018c065 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -577,7 +577,8 @@ void CGDebugInfo::CreateCompileUnit() { remapDIPath(getCurrentDirname()), CSInfo, getSource(SM, SM.getMainFileID())), - Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, + CGOpts.EmitVersionIdentMetadata ? Producer : "", + LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind, 0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling, diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 17d9db3399..707b826418 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -571,7 +571,8 @@ void CodeGenModule::Release() { if (DebugInfo) DebugInfo->finalize(); - EmitVersionIdentMetadata(); + if (getCodeGenOpts().EmitVersionIdentMetadata) + EmitVersionIdentMetadata(); EmitTargetMetadata(); } diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index a3cb0f21ed..6c5e2caae4 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -4408,6 +4408,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } + if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true)) + CmdArgs.push_back("-Qn"); + // -fcommon is the default unless compiling kernel code or the target says so bool NoCommonDefault = KernelOrKext || isNoCommonDefault(RawTriple); if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common, diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 67e15b41ad..f904e65e72 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1112,6 +1112,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue( Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags); + Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true); + return Success; } |
