diff options
author | Eric Christopher <echristo@gmail.com> | 2013-02-05 07:29:57 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2013-02-05 07:29:57 +0000 |
commit | c706c8e440abf61910c042380e19c67932998395 (patch) | |
tree | e1ad31e6b3fe68189ecfdaa8ad03bd251642cc3c /lib/Driver/Tools.cpp | |
parent | 4f4e2af2643c1914c2e49ac6372f7c2c38616432 (diff) |
Driver and option support for -gsplit-dwarf. This is a part of
the DWARF5 split dwarf proposal.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r-- | lib/Driver/Tools.cpp | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index dbd25dfbea..71e50a5c9e 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2250,16 +2250,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, D.CCLogDiagnosticsFilename : "-"); } - // Use the last option from "-g" group. "-gline-tables-only" is - // preserved, all other debug options are substituted with "-g". + // Use the last option from "-g" group. "-gline-tables-only" + // is preserved, all other debug options are substituted with "-g". Args.ClaimAllArgs(options::OPT_g_Group); if (Arg *A = Args.getLastArg(options::OPT_g_Group)) { - if (A->getOption().matches(options::OPT_gline_tables_only)) { + if (A->getOption().matches(options::OPT_gline_tables_only)) CmdArgs.push_back("-gline-tables-only"); - } else if (!A->getOption().matches(options::OPT_g0) && - !A->getOption().matches(options::OPT_ggdb0)) { + else if (!A->getOption().matches(options::OPT_g0) && + !A->getOption().matches(options::OPT_ggdb0)) CmdArgs.push_back("-g"); - } } // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now. @@ -2267,6 +2266,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasArg(options::OPT_gcolumn_info)) CmdArgs.push_back("-dwarf-column-info"); + // -gsplit-dwarf should turn on -g and enable the backend dwarf + // splitting and extraction. + if (Args.hasArg(options::OPT_gsplit_dwarf)) { + CmdArgs.push_back("-g"); + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back("-split-dwarf=Enable"); + } + Args.AddAllArgs(CmdArgs, options::OPT_ffunction_sections); Args.AddAllArgs(CmdArgs, options::OPT_fdata_sections); @@ -5829,6 +5836,42 @@ 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, |