forked from OSchip/llvm-project
Add support for passing the main file name down to the assembler
for location information. Part of PR14624 llvm-svn: 170391
This commit is contained in:
parent
906da23229
commit
45f2e71571
|
@ -37,6 +37,8 @@ def L : Flag<["-"], "L">,
|
|||
HelpText<"Save temporary labels in the symbol table. "
|
||||
"Note this may change .s semantics, it should almost never be used "
|
||||
"on compiler generated code!">;
|
||||
def main_file_name : Separate<["-"], "main-file-name">,
|
||||
HelpText<"Main file name to use for debug info">;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Frontend Options
|
||||
|
|
|
@ -1388,12 +1388,12 @@ static bool ShouldDisableCFI(const ArgList &Args,
|
|||
// The native darwin assembler doesn't support cfi directives, so
|
||||
// we disable them if we think the .s file will be passed to it.
|
||||
Default = Args.hasFlag(options::OPT_integrated_as,
|
||||
options::OPT_no_integrated_as,
|
||||
TC.IsIntegratedAssemblerDefault());
|
||||
options::OPT_no_integrated_as,
|
||||
TC.IsIntegratedAssemblerDefault());
|
||||
}
|
||||
return !Args.hasFlag(options::OPT_fdwarf2_cfi_asm,
|
||||
options::OPT_fno_dwarf2_cfi_asm,
|
||||
Default);
|
||||
options::OPT_fno_dwarf2_cfi_asm,
|
||||
Default);
|
||||
}
|
||||
|
||||
static bool ShouldDisableDwarfDirectory(const ArgList &Args,
|
||||
|
@ -3278,6 +3278,11 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
CmdArgs.push_back("-filetype");
|
||||
CmdArgs.push_back("obj");
|
||||
|
||||
// Set the main file name, so that debug info works even with
|
||||
// -save-temps or preprocessed assembly.
|
||||
CmdArgs.push_back("-main-file-name");
|
||||
CmdArgs.push_back(Clang::getBaseInputName(Args, Inputs));
|
||||
|
||||
if (UseRelaxAll(C, Args))
|
||||
CmdArgs.push_back("-relax-all");
|
||||
|
||||
|
@ -4367,10 +4372,10 @@ void darwin::Dsymutil::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
}
|
||||
|
||||
void darwin::VerifyDebug::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
const InputInfo &Output,
|
||||
const InputInfoList &Inputs,
|
||||
const ArgList &Args,
|
||||
const char *LinkingOutput) const {
|
||||
const InputInfo &Output,
|
||||
const InputInfoList &Inputs,
|
||||
const ArgList &Args,
|
||||
const char *LinkingOutput) const {
|
||||
ArgStringList CmdArgs;
|
||||
CmdArgs.push_back("--verify");
|
||||
CmdArgs.push_back("--debug-info");
|
||||
|
@ -5751,7 +5756,7 @@ void minix::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
CmdArgs.push_back("-lCompilerRT-Generic");
|
||||
CmdArgs.push_back("-L/usr/pkg/compiler-rt/lib");
|
||||
CmdArgs.push_back(
|
||||
Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
|
||||
Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
|
||||
}
|
||||
|
||||
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("ld"));
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace tools {
|
|||
|
||||
/// \brief Clang compiler tool.
|
||||
class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
|
||||
public:
|
||||
static const char *getBaseInputName(const ArgList &Args,
|
||||
const InputInfoList &Inputs);
|
||||
static const char *getBaseInputStem(const ArgList &Args,
|
||||
|
@ -37,6 +38,7 @@ namespace tools {
|
|||
static const char *getDependencyFileName(const ArgList &Args,
|
||||
const InputInfoList &Inputs);
|
||||
|
||||
private:
|
||||
void AddPreprocessingOptions(Compilation &C,
|
||||
const Driver &D,
|
||||
const ArgList &Args,
|
||||
|
@ -286,15 +288,15 @@ namespace darwin {
|
|||
class LLVM_LIBRARY_VISIBILITY VerifyDebug : public DarwinTool {
|
||||
public:
|
||||
VerifyDebug(const ToolChain &TC) : DarwinTool("darwin::VerifyDebug",
|
||||
"dwarfdump", TC) {}
|
||||
"dwarfdump", 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;
|
||||
const InputInfo &Output,
|
||||
const InputInfoList &Inputs,
|
||||
const ArgList &TCArgs,
|
||||
const char *LinkingOutput) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// REQUIRES: clang-driver
|
||||
// RUN: %clang -### -c -save-temps -integrated-as -g %s 2>&1 \
|
||||
// RUN: | FileCheck %s
|
||||
|
||||
// CHECK: main-file-name
|
||||
|
||||
#ifdef(1)
|
||||
foo:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
#endif
|
|
@ -84,6 +84,7 @@ struct AssemblerInvocation {
|
|||
unsigned GenDwarfForAssembly : 1;
|
||||
std::string DwarfDebugFlags;
|
||||
std::string DebugCompilationDir;
|
||||
std::string MainFileName;
|
||||
|
||||
/// @}
|
||||
/// @name Frontend Options
|
||||
|
@ -183,6 +184,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
|
|||
Opts.GenDwarfForAssembly = Args->hasArg(OPT_g);
|
||||
Opts.DwarfDebugFlags = Args->getLastArgValue(OPT_dwarf_debug_flags);
|
||||
Opts.DebugCompilationDir = Args->getLastArgValue(OPT_fdebug_compilation_dir);
|
||||
Opts.MainFileName = Args->getLastArgValue(OPT_main_file_name);
|
||||
|
||||
// Frontend Options
|
||||
if (Args->hasArg(OPT_INPUT)) {
|
||||
|
@ -309,6 +311,8 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
|
|||
Ctx.setDwarfDebugFlags(StringRef(Opts.DwarfDebugFlags));
|
||||
if (!Opts.DebugCompilationDir.empty())
|
||||
Ctx.setCompilationDir(Opts.DebugCompilationDir);
|
||||
if (!Opts.MainFileName.empty())
|
||||
Ctx.setMainFileName(StringRef(Opts.MainFileName));
|
||||
|
||||
// Build up the feature string from the target feature list.
|
||||
std::string FS;
|
||||
|
|
Loading…
Reference in New Issue