diff options
author | Kevin Enderby <enderby@apple.com> | 2011-12-22 19:31:58 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2011-12-22 19:31:58 +0000 |
commit | 567003e572eed69cf1e8a04601076c8803355c7a (patch) | |
tree | 51bf6fcb9d8baaba6aefab4c8746119715add509 /lib/Driver/Tools.cpp | |
parent | cf15cef8447e8b3ae08e81ad25ae9eb443038acf (diff) |
Last part of support for generating dwarf for assembly source files. This gets
the clang driver to enable this when assembling a .s file. rdar://9275556
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r-- | lib/Driver/Tools.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index d99b4f2fce..7ee4b4c126 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2501,7 +2501,32 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, // Ignore explicit -force_cpusubtype_ALL option. (void) Args.hasArg(options::OPT_force__cpusubtype__ALL); - // FIXME: Add -g support, once we have it. + // Same as Clang::ConstructJob() we special case debug options to only pass + // -g to clang. I guess if it is wrong there then it is wrong here too :) . + Args.ClaimAllArgs(options::OPT_g_Group); + if (Arg *A = Args.getLastArg(options::OPT_g_Group)) + if (!A->getOption().matches(options::OPT_g0)) { + CmdArgs.push_back("-g"); + } + + // Optionally embed the -cc1as level arguments into the debug info, for build + // analysis. + if (getToolChain().UseDwarfDebugFlags()) { + ArgStringList OriginalArgs; + for (ArgList::const_iterator it = Args.begin(), + ie = Args.end(); it != ie; ++it) + (*it)->render(Args, OriginalArgs); + + llvm::SmallString<256> Flags; + const char *Exec = getToolChain().getDriver().getClangProgramPath(); + Flags += Exec; + for (unsigned i = 0, e = OriginalArgs.size(); i != e; ++i) { + Flags += " "; + Flags += OriginalArgs[i]; + } + CmdArgs.push_back("-dwarf-debug-flags"); + CmdArgs.push_back(Args.MakeArgString(Flags.str())); + } // FIXME: Add -static support, once we have it. |