The option -split-dwarf-file is passed by the driver to the compiler after
processing -Xclang options, thus overriding any possible explicitly specified
option:
$ clang++ -c -gsplit-dwarf a.cpp -o a.o -Xclang -split-dwarf-file -Xclang
b.dwo
$ readelf -wi a.o | grep dwo_name
<c> DW_AT_GNU_dwo_name: (indirect string, offset: 0x0): a.dwo
This is because the driver invokes the compiler as
/usr/bin/clang-3.4 -cc1 ... -split-dwarf-file b.dwo -o a.o -x c++
a.cpp -split-dwarf-file a.dwo
The attached patch fixes this. Ok to push?
--
Lubos Lunak
From 993f4a10cf4396ad107a58ff764290ad8b984c99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <[email protected]>
Date: Fri, 4 Apr 2014 09:12:59 +0200
Subject: [PATCH] allow -split-dwarf-file to be overriden by command line
The driver passed it after -XClang options, thus overriding anything that
was given on the command line.
---
lib/Driver/Tools.cpp | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 3671880..6262965 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -3804,6 +3804,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Forward -fparse-all-comments to -cc1.
Args.AddAllArgs(CmdArgs, options::OPT_fparse_all_comments);
+ // 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() &&
+ (isa<AssembleJobAction>(JA) || isa<CompileJobAction>(JA));
+ const char *SplitDwarfOut;
+ if (SplitDwarf) {
+ CmdArgs.push_back("-split-dwarf-file");
+ SplitDwarfOut = SplitDebugName(Args, Inputs);
+ CmdArgs.push_back(SplitDwarfOut);
+ }
+
// Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option
// parser.
Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
@@ -3862,18 +3874,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(Flags.str()));
}
- // 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() &&
- (isa<AssembleJobAction>(JA) || isa<CompileJobAction>(JA));
- const char *SplitDwarfOut;
- if (SplitDwarf) {
- CmdArgs.push_back("-split-dwarf-file");
- SplitDwarfOut = SplitDebugName(Args, Inputs);
- CmdArgs.push_back(SplitDwarfOut);
- }
-
// Finally add the compile command to the compilation.
if (Args.hasArg(options::OPT__SLASH_fallback) &&
Output.getType() == types::TY_Object) {
--
1.8.4.5
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits