r243694 - Split DWARF: Allow -gmlt/-gsplit-dwarf to override rather than complement each other
David Blaikie
dblaikie at gmail.com
Thu Jul 30 14:42:22 PDT 2015
Author: dblaikie
Date: Thu Jul 30 16:42:22 2015
New Revision: 243694
URL: http://llvm.org/viewvc/llvm-project?rev=243694&view=rev
Log:
Split DWARF: Allow -gmlt/-gsplit-dwarf to override rather than complement each other
It doesn't make any sense to enable -gmlt with -gsplit-dwarf, since
-gmlt is designed for on-line symbolication (and -gsplit-dwarf normally
emits all the -gmlt data into the .o anyway - so there's nothing to
split out except redundant/duplicate info).
With this change they override each other, -gmlt -gsplit-dwarf is the
same as -gsplit-dwarf and -gsplit-dwarf -gmlt is the same as -gmlt.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/split-debug.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=243694&r1=243693&r2=243694&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jul 30 16:42:22 2015
@@ -3644,9 +3644,11 @@ void Clang::ConstructJob(Compilation &C,
// Use the last option from "-g" group. "-gline-tables-only" and "-gdwarf-x"
// are preserved, all other debug options are substituted with "-g".
Args.ClaimAllArgs(options::OPT_g_Group);
+ Arg *SplitDwarfArg = Args.getLastArg(options::OPT_gsplit_dwarf);
if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
- if (A->getOption().matches(options::OPT_gline_tables_only) ||
- A->getOption().matches(options::OPT_g1)) {
+ if ((A->getOption().matches(options::OPT_gline_tables_only) ||
+ A->getOption().matches(options::OPT_g1)) &&
+ (!SplitDwarfArg || A->getIndex() > SplitDwarfArg->getIndex())) {
// FIXME: we should support specifying dwarf version with
// -gline-tables-only.
CmdArgs.push_back("-gline-tables-only");
@@ -3656,6 +3658,7 @@ void Clang::ConstructJob(Compilation &C,
Triple.getOS() == llvm::Triple::FreeBSD ||
Triple.getOS() == llvm::Triple::Solaris)
CmdArgs.push_back("-gdwarf-2");
+ SplitDwarfArg = nullptr;
} else if (A->getOption().matches(options::OPT_gdwarf_2))
CmdArgs.push_back("-gdwarf-2");
else if (A->getOption().matches(options::OPT_gdwarf_3))
@@ -3685,8 +3688,7 @@ void Clang::ConstructJob(Compilation &C,
// -gsplit-dwarf should turn on -g and enable the backend dwarf
// splitting and extraction.
// FIXME: Currently only works on Linux.
- if (getToolChain().getTriple().isOSLinux() &&
- Args.hasArg(options::OPT_gsplit_dwarf)) {
+ if (getToolChain().getTriple().isOSLinux() && SplitDwarfArg) {
CmdArgs.push_back("-g");
CmdArgs.push_back("-backend-option");
CmdArgs.push_back("-split-dwarf=Enable");
@@ -4970,8 +4972,7 @@ void Clang::ConstructJob(Compilation &C,
// Add the split debug info name to the command lines here so we
// can propagate it to the backend.
- bool SplitDwarf = Args.hasArg(options::OPT_gsplit_dwarf) &&
- getToolChain().getTriple().isOSLinux() &&
+ bool SplitDwarf = SplitDwarfArg && getToolChain().getTriple().isOSLinux() &&
(isa<AssembleJobAction>(JA) || isa<CompileJobAction>(JA) ||
isa<BackendJobAction>(JA));
const char *SplitDwarfOut;
Modified: cfe/trunk/test/Driver/split-debug.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.c?rev=243694&r1=243693&r2=243694&view=diff
==============================================================================
--- cfe/trunk/test/Driver/split-debug.c (original)
+++ cfe/trunk/test/Driver/split-debug.c Thu Jul 30 16:42:22 2015
@@ -32,3 +32,20 @@
// RUN: FileCheck -check-prefix=CHECK-IAS < %t %s
//
// CHECK-IAS: objcopy
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -gmlt -S -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-GMLT-OVER-SPLIT < %t %s
+//
+// CHECK-GMLT-OVER-SPLIT: "-gline-tables-only"
+// CHECK-GMLT-OVER-SPLIT-NOT: "-g"
+// CHECK-GMLT-OVER-SPLIT-NOT: "-split-dwarf=Enable"
+// CHECK-GMLT-OVER-SPLIT-NOT: "-split-dwarf-file"
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -S -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-GMLT < %t %s
+//
+// CHECK-SPLIT-OVER-GMLT-NOT: "-gline-tables-only"
+// CHECK-SPLIT-OVER-GMLT: "-g"
+// CHECK-SPLIT-OVER-GMLT: "-split-dwarf=Enable"
+// CHECK-SPLIT-OVER-GMLT: "-split-dwarf-file"
+// CHECK-SPLIT-OVER-GMLT-NOT: "-gline-tables-only"
More information about the cfe-commits
mailing list