aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Driver/Action.h12
-rw-r--r--lib/Driver/Action.cpp7
-rw-r--r--lib/Driver/Driver.cpp18
-rw-r--r--lib/Driver/ToolChains.cpp4
-rw-r--r--lib/Driver/Tools.cpp86
-rw-r--r--lib/Driver/Tools.h18
-rw-r--r--lib/Driver/WindowsToolChain.cpp2
-rw-r--r--test/Driver/split-debug.c15
8 files changed, 57 insertions, 105 deletions
diff --git a/include/clang/Driver/Action.h b/include/clang/Driver/Action.h
index 62f4aad49b..4057e48f69 100644
--- a/include/clang/Driver/Action.h
+++ b/include/clang/Driver/Action.h
@@ -46,10 +46,9 @@ public:
LipoJobClass,
DsymutilJobClass,
VerifyJobClass,
- SplitDebugJobClass,
JobClassFirst=PreprocessJobClass,
- JobClassLast=SplitDebugJobClass
+ JobClassLast=VerifyJobClass
};
static const char *getClassName(ActionClass AC);
@@ -234,15 +233,6 @@ public:
}
};
-class SplitDebugJobAction : public JobAction {
- virtual void anchor();
-public:
- SplitDebugJobAction(ActionList &Inputs, types::ID Type);
- static bool classof(const Action *A) {
- return A->getKind() == SplitDebugJobClass;
- }
-};
-
} // end namespace driver
} // end namespace clang
diff --git a/lib/Driver/Action.cpp b/lib/Driver/Action.cpp
index 29f7ad2993..2b5bbee3db 100644
--- a/lib/Driver/Action.cpp
+++ b/lib/Driver/Action.cpp
@@ -33,7 +33,6 @@ const char *Action::getClassName(ActionClass AC) {
case LipoJobClass: return "lipo";
case DsymutilJobClass: return "dsymutil";
case VerifyJobClass: return "verify";
- case SplitDebugJobClass: return "split-debug";
}
llvm_unreachable("invalid class");
@@ -120,9 +119,3 @@ void VerifyJobAction::anchor() {}
VerifyJobAction::VerifyJobAction(ActionList &Inputs, types::ID Type)
: JobAction(VerifyJobClass, Inputs, Type) {
}
-
-void SplitDebugJobAction::anchor() {}
-
-SplitDebugJobAction::SplitDebugJobAction(ActionList &Inputs, types::ID Type)
- : JobAction(SplitDebugJobClass, Inputs, Type) {
-}
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 606555e3db..048c1540d3 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -1107,12 +1107,6 @@ void Driver::BuildActions(const ToolChain &TC, const DerivedArgList &Args,
Current.reset(ConstructPhaseAction(Args, Phase, Current.take()));
if (Current->getType() == types::TY_Nothing)
break;
- else if (Current->getType() == types::TY_Object &&
- Args.hasArg(options::OPT_gsplit_dwarf)) {
- ActionList Input;
- Input.push_back(Current.take());
- Current.reset(new SplitDebugJobAction(Input, types::TY_Object));
- }
}
// If we ended with something, add to the output list.
@@ -1120,16 +1114,6 @@ void Driver::BuildActions(const ToolChain &TC, const DerivedArgList &Args,
Actions.push_back(Current.take());
}
- if (!SplitInputs.empty()) {
- for (ActionList::iterator i = SplitInputs.begin(), e = SplitInputs.end();
- i != e; ++i) {
- Action *Act = *i;
- ActionList Inputs;
- Inputs.push_back(Act);
- Actions.push_back(new SplitDebugJobAction(Inputs, types::TY_Object));
- }
- }
-
// Add a link action if necessary.
if (!LinkerInputs.empty())
Actions.push_back(new LinkJobAction(LinkerInputs, types::TY_Image));
@@ -1410,8 +1394,6 @@ void Driver::BuildJobsForAction(Compilation &C,
// Determine the place to write output to, if any.
if (JA->getType() == types::TY_Nothing)
Result = InputInfo(A->getType(), BaseInput);
- else if (isa<SplitDebugJobAction>(A))
- Result = InputInfos[0];
else
Result = InputInfo(GetNamedOutputPath(C, *JA, BaseInput, AtTopLevel),
A->getType(), BaseInput);
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 367041ef86..d1072d5a37 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -189,7 +189,6 @@ Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA,
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
- case Action::SplitDebugJobClass:
case Action::InputClass:
case Action::BindArchClass:
llvm_unreachable("Invalid tool kind.");
@@ -1389,7 +1388,6 @@ Tool &Generic_GCC::SelectTool(const Compilation &C,
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
- case Action::SplitDebugJobClass:
case Action::InputClass:
case Action::BindArchClass:
llvm_unreachable("Invalid tool kind.");
@@ -2452,8 +2450,6 @@ Tool &Linux::SelectTool(const Compilation &C, const JobAction &JA,
break;
case Action::LinkJobClass:
T = new tools::linuxtools::Link(*this); break;
- case Action::SplitDebugJobClass:
- T = new tools::linuxtools::SplitDebug(*this); break;
default:
T = &Generic_GCC::SelectTool(C, JA, Inputs);
}
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index a63623a3be..da23fd5130 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1705,6 +1705,47 @@ static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs) {
}
}
+void Clang::SplitDebugInfo(Compilation &C, const JobAction &JA,
+ const ArgList &Args,
+ const InputInfoList &Inputs,
+ const InputInfo &Output,
+ const char *LinkingOutput) const {
+ ArgStringList ExtractArgs;
+ ExtractArgs.push_back("--extract-dwo");
+
+ ArgStringList StripArgs;
+ StripArgs.push_back("--strip-dwo");
+
+ // Grabbing the output of the earlier compile step.
+ StripArgs.push_back(Output.getFilename());
+ ExtractArgs.push_back(Output.getFilename());
+
+ // Add an output for the extract.
+ Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o);
+ const char *OutFile;
+ if (FinalOutput) {
+ SmallString<128> T(FinalOutput->getValue());
+ llvm::sys::path::replace_extension(T, "dwo");
+ OutFile = Args.MakeArgString(T);
+ } else {
+ // Use the compilation dir.
+ SmallString<128> T(Args.getLastArgValue(options::OPT_fdebug_compilation_dir));
+ T += llvm::sys::path::stem(Inputs[0].getBaseInput());
+ llvm::sys::path::replace_extension(T, "dwo");
+ OutFile = Args.MakeArgString(T);
+ }
+ ExtractArgs.push_back(OutFile);
+
+ const char *Exec =
+ Args.MakeArgString(getToolChain().GetProgramPath("objcopy"));
+
+ // First extract the dwo sections.
+ C.addCommand(new Command(JA, *this, Exec, ExtractArgs));
+
+ // Then remove them from the original .o file.
+ C.addCommand(new Command(JA, *this, Exec, StripArgs));
+}
+
void Clang::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
@@ -3219,6 +3260,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Finally add the command to the compilation.
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ // Handle the debug info splitting at object creation time.
+ // TODO: Currently only works on linux with newer objcopy.
+ if (Args.hasArg(options::OPT_gsplit_dwarf) &&
+ getToolChain().getTriple().getOS() == llvm::Triple::Linux &&
+ isa<AssembleJobAction>(JA))
+ SplitDebugInfo(C, JA, Args, Inputs, Output, LinkingOutput);
+
if (Arg *A = Args.getLastArg(options::OPT_pg))
if (Args.hasArg(options::OPT_fomit_frame_pointer))
D.Diag(diag::err_drv_argument_not_allowed_with)
@@ -4002,7 +4050,7 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
if (getToolChain().getTriple().getArch() != llvm::Triple::x86_64 &&
(((Args.hasArg(options::OPT_mkernel) ||
- Args.hasArg(options::OPT_fapple_kext)) &&
+ Args.hasArg(options::OPT_fapple_kext)) &&
(!getDarwinToolChain().isTargetIPhoneOS() ||
getDarwinToolChain().isIPhoneOSVersionLT(6, 0))) ||
Args.hasArg(options::OPT_static)))
@@ -5873,42 +5921,6 @@ void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA,
C.addCommand(new Command(JA, *this, ToolChain.Linker.c_str(), CmdArgs));
}
-void linuxtools::SplitDebug::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &Args,
- const char *LinkingOutput) const {
- // Assert some invariants.
- assert(Inputs.size() == 1 && "Unable to handle multiple inputs.");
- const InputInfo &Input = Inputs[0];
- assert(Input.isFilename() && "Unexpected verify input");
-
- ArgStringList ExtractArgs;
- ExtractArgs.push_back("--extract-dwo");
-
- ArgStringList StripArgs;
- StripArgs.push_back("--strip-dwo");
-
- // Grabbing the output of the earlier compile step.
- StripArgs.push_back(Input.getFilename());
- ExtractArgs.push_back(Input.getFilename());
-
- // Add an output for the extract.
- SmallString<128> T(Inputs[0].getBaseInput());
- llvm::sys::path::replace_extension(T, "dwo");
- const char *OutFile = Args.MakeArgString(T);
- ExtractArgs.push_back(OutFile);
-
- const char *Exec =
- Args.MakeArgString(getToolChain().GetProgramPath("objcopy"));
-
- // First extract the dwo sections.
- C.addCommand(new Command(JA, *this, Exec, ExtractArgs));
-
- // Then remove them from the original .o file.
- C.addCommand(new Command(JA, *this, Exec, StripArgs));
-}
-
void minix::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h
index 6c1f71fcc7..2d7f8b0962 100644
--- a/lib/Driver/Tools.h
+++ b/lib/Driver/Tools.h
@@ -54,6 +54,10 @@ namespace tools {
void AddSparcTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddX86TargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddHexagonTargetArgs (const ArgList &Args, ArgStringList &CmdArgs) const;
+ void SplitDebugInfo(Compilation &C, const JobAction &JA,
+ const ArgList &Args, const InputInfoList &Inputs,
+ const InputInfo &Output,
+ const char *LinkingOutput) const;
enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile };
@@ -454,20 +458,6 @@ namespace linuxtools {
const ArgList &TCArgs,
const char *LinkingOutput) const;
};
-
- class LLVM_LIBRARY_VISIBILITY SplitDebug : public Tool {
- public:
- SplitDebug(const ToolChain &TC) : Tool("linuxtools::SplitDebug",
- "objcopy", TC) {}
-
- virtual bool hasIntegratedCPP() const { return false; }
-
- virtual void ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
- const char *LinkingOutput) const;
- };
}
/// minix -- Directly call GNU Binutils assembler and linker
namespace minix {
diff --git a/lib/Driver/WindowsToolChain.cpp b/lib/Driver/WindowsToolChain.cpp
index f640b17611..e7ab4ced87 100644
--- a/lib/Driver/WindowsToolChain.cpp
+++ b/lib/Driver/WindowsToolChain.cpp
@@ -55,8 +55,6 @@ Tool &Windows::SelectTool(const Compilation &C, const JobAction &JA,
case Action::LipoJobClass:
case Action::DsymutilJobClass:
case Action::VerifyJobClass:
- case Action::SplitDebugJobClass:
- llvm_unreachable("Invalid tool kind.");
case Action::PreprocessJobClass:
case Action::PrecompileJobClass:
case Action::AnalyzeJobClass:
diff --git a/test/Driver/split-debug.c b/test/Driver/split-debug.c
index c3903eaaa7..a3711e4c0f 100644
--- a/test/Driver/split-debug.c
+++ b/test/Driver/split-debug.c
@@ -1,19 +1,10 @@
// Check that we split debug output properly
//
// REQUIRES: asserts
-// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases \
-// RUN: -gsplit-dwarf -arch x86_64 %s 2> %t
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
// RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
//
-// CHECK-ACTIONS: 0: input, "{{.*}}split-debug.c", c
-// CHECK-ACTIONS: 4: split-debug, {3}, object
+// CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
-// Check output name derivation.
-//
-// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-bindings \
-// RUN: -gsplit-dwarf -arch x86_64 -c %s 2> %t
-// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
-//
-// CHECK-OUTPUT-NAME:# "x86_64-unknown-linux-gnu" - "clang", inputs: ["{{.*}}split-debug.c"], output: "{{.*}}split-debug{{.*}}.o"
-// CHECK-OUTPUT-NAME:# "x86_64-unknown-linux-gnu" - "linuxtools::SplitDebug", inputs: ["{{.*}}split-debug{{.*}}.o"], output: "{{.*}}split-debug{{.*}}.o"