Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Driver/ToolChains/Clang.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 492 Lines • ▼ Show 20 Lines | static codegenoptions::DebugInfoKind DebugLevelToInfoKind(const Arg &A) { | ||||
if (A.getOption().matches(options::OPT_g0) || | if (A.getOption().matches(options::OPT_g0) || | ||||
A.getOption().matches(options::OPT_ggdb0)) | A.getOption().matches(options::OPT_ggdb0)) | ||||
return codegenoptions::NoDebugInfo; | return codegenoptions::NoDebugInfo; | ||||
if (A.getOption().matches(options::OPT_gline_tables_only) || | if (A.getOption().matches(options::OPT_gline_tables_only) || | ||||
A.getOption().matches(options::OPT_ggdb1)) | A.getOption().matches(options::OPT_ggdb1)) | ||||
return codegenoptions::DebugLineTablesOnly; | return codegenoptions::DebugLineTablesOnly; | ||||
if (A.getOption().matches(options::OPT_gline_directives_only)) | if (A.getOption().matches(options::OPT_gline_directives_only)) | ||||
return codegenoptions::DebugDirectivesOnly; | return codegenoptions::DebugDirectivesOnly; | ||||
return codegenoptions::LimitedDebugInfo; | return codegenoptions::DebugInfoConstructor; | ||||
} | } | ||||
static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) { | static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) { | ||||
switch (Triple.getArch()){ | switch (Triple.getArch()){ | ||||
default: | default: | ||||
return false; | return false; | ||||
case llvm::Triple::arm: | case llvm::Triple::arm: | ||||
case llvm::Triple::thumb: | case llvm::Triple::thumb: | ||||
▲ Show 20 Lines • Show All 1,865 Lines • ▼ Show 20 Lines | for (StringRef Value : A->getValues()) { | ||||
TakeNextArg = true; | TakeNextArg = true; | ||||
} else if (Value.startswith("-gdwarf-")) { | } else if (Value.startswith("-gdwarf-")) { | ||||
// "-gdwarf-N" options are not cc1as options. | // "-gdwarf-N" options are not cc1as options. | ||||
unsigned DwarfVersion = DwarfVersionNum(Value); | unsigned DwarfVersion = DwarfVersionNum(Value); | ||||
if (DwarfVersion == 0) { // Send it onward, and let cc1as complain. | if (DwarfVersion == 0) { // Send it onward, and let cc1as complain. | ||||
CmdArgs.push_back(Value.data()); | CmdArgs.push_back(Value.data()); | ||||
} else { | } else { | ||||
RenderDebugEnablingArgs(Args, CmdArgs, | RenderDebugEnablingArgs(Args, CmdArgs, | ||||
codegenoptions::LimitedDebugInfo, | codegenoptions::DebugInfoConstructor, | ||||
DwarfVersion, llvm::DebuggerKind::Default); | DwarfVersion, llvm::DebuggerKind::Default); | ||||
} | } | ||||
} else if (Value.startswith("-mcpu") || Value.startswith("-mfpu") || | } else if (Value.startswith("-mcpu") || Value.startswith("-mfpu") || | ||||
Value.startswith("-mhwdiv") || Value.startswith("-march")) { | Value.startswith("-mhwdiv") || Value.startswith("-march")) { | ||||
// Do nothing, we'll validate it later. | // Do nothing, we'll validate it later. | ||||
} else if (Value == "-defsym") { | } else if (Value == "-defsym") { | ||||
if (A->getNumValues() != 2) { | if (A->getNumValues() != 2) { | ||||
D.Diag(diag::err_drv_defsym_invalid_format) << Value; | D.Diag(diag::err_drv_defsym_invalid_format) << Value; | ||||
▲ Show 20 Lines • Show All 1,256 Lines • ▼ Show 20 Lines | if (DwarfFission != DwarfFissionKind::None && | ||||
!checkDebugInfoOption(SplitDWARFArg, Args, D, TC)) { | !checkDebugInfoOption(SplitDWARFArg, Args, D, TC)) { | ||||
DwarfFission = DwarfFissionKind::None; | DwarfFission = DwarfFissionKind::None; | ||||
SplitDWARFInlining = false; | SplitDWARFInlining = false; | ||||
} | } | ||||
if (const Arg *A = | if (const Arg *A = | ||||
Args.getLastArg(options::OPT_g_Group, options::OPT_gsplit_dwarf, | Args.getLastArg(options::OPT_g_Group, options::OPT_gsplit_dwarf, | ||||
options::OPT_gsplit_dwarf_EQ)) { | options::OPT_gsplit_dwarf_EQ)) { | ||||
DebugInfoKind = codegenoptions::LimitedDebugInfo; | DebugInfoKind = codegenoptions::DebugInfoConstructor; | ||||
// If the last option explicitly specified a debug-info level, use it. | // If the last option explicitly specified a debug-info level, use it. | ||||
if (checkDebugInfoOption(A, Args, D, TC) && | if (checkDebugInfoOption(A, Args, D, TC) && | ||||
A->getOption().matches(options::OPT_gN_Group)) { | A->getOption().matches(options::OPT_gN_Group)) { | ||||
DebugInfoKind = DebugLevelToInfoKind(*A); | DebugInfoKind = DebugLevelToInfoKind(*A); | ||||
// For -g0 or -gline-tables-only, drop -gsplit-dwarf. This gets a bit more | // For -g0 or -gline-tables-only, drop -gsplit-dwarf. This gets a bit more | ||||
// complicated if you've disabled inline info in the skeleton CUs | // complicated if you've disabled inline info in the skeleton CUs | ||||
// (SplitDWARFInlining) - then there's value in composing split-dwarf and | // (SplitDWARFInlining) - then there's value in composing split-dwarf and | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | if (!Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info, | ||||
CmdArgs.push_back("-gno-column-info"); | CmdArgs.push_back("-gno-column-info"); | ||||
// FIXME: Move backend command line options to the module. | // FIXME: Move backend command line options to the module. | ||||
// If -gline-tables-only or -gline-directives-only is the last option it wins. | // If -gline-tables-only or -gline-directives-only is the last option it wins. | ||||
if (const Arg *A = Args.getLastArg(options::OPT_gmodules)) | if (const Arg *A = Args.getLastArg(options::OPT_gmodules)) | ||||
if (checkDebugInfoOption(A, Args, D, TC)) { | if (checkDebugInfoOption(A, Args, D, TC)) { | ||||
if (DebugInfoKind != codegenoptions::DebugLineTablesOnly && | if (DebugInfoKind != codegenoptions::DebugLineTablesOnly && | ||||
DebugInfoKind != codegenoptions::DebugDirectivesOnly) { | DebugInfoKind != codegenoptions::DebugDirectivesOnly) { | ||||
DebugInfoKind = codegenoptions::LimitedDebugInfo; | DebugInfoKind = codegenoptions::DebugInfoConstructor; | ||||
CmdArgs.push_back("-dwarf-ext-refs"); | CmdArgs.push_back("-dwarf-ext-refs"); | ||||
CmdArgs.push_back("-fmodule-format=obj"); | CmdArgs.push_back("-fmodule-format=obj"); | ||||
} | } | ||||
} | } | ||||
if (T.isOSBinFormatELF() && !SplitDWARFInlining) | if (T.isOSBinFormatELF() && !SplitDWARFInlining) | ||||
CmdArgs.push_back("-fno-split-dwarf-inlining"); | CmdArgs.push_back("-fno-split-dwarf-inlining"); | ||||
// After we've dealt with all combinations of things that could | // After we've dealt with all combinations of things that could | ||||
// make DebugInfoKind be other than None or DebugLineTablesOnly, | // make DebugInfoKind be other than None or DebugLineTablesOnly, | ||||
// figure out if we need to "upgrade" it to standalone debug info. | // figure out if we need to "upgrade" it to standalone debug info. | ||||
// We parse these two '-f' options whether or not they will be used, | // We parse these two '-f' options whether or not they will be used, | ||||
// to claim them even if you wrote "-fstandalone-debug -gline-tables-only" | // to claim them even if you wrote "-fstandalone-debug -gline-tables-only" | ||||
bool NeedFullDebug = Args.hasFlag( | bool NeedFullDebug = Args.hasFlag( | ||||
options::OPT_fstandalone_debug, options::OPT_fno_standalone_debug, | options::OPT_fstandalone_debug, options::OPT_fno_standalone_debug, | ||||
DebuggerTuning == llvm::DebuggerKind::LLDB || | DebuggerTuning == llvm::DebuggerKind::LLDB || | ||||
TC.GetDefaultStandaloneDebug()); | TC.GetDefaultStandaloneDebug()); | ||||
if (const Arg *A = Args.getLastArg(options::OPT_fstandalone_debug)) | if (const Arg *A = Args.getLastArg(options::OPT_fstandalone_debug)) | ||||
(void)checkDebugInfoOption(A, Args, D, TC); | (void)checkDebugInfoOption(A, Args, D, TC); | ||||
if (DebugInfoKind == codegenoptions::LimitedDebugInfo && NeedFullDebug) | if ((DebugInfoKind == codegenoptions::LimitedDebugInfo || | ||||
DebugInfoKind == codegenoptions::DebugInfoConstructor) && | |||||
NeedFullDebug) | |||||
DebugInfoKind = codegenoptions::FullDebugInfo; | DebugInfoKind = codegenoptions::FullDebugInfo; | ||||
if (Args.hasFlag(options::OPT_gembed_source, options::OPT_gno_embed_source, | if (Args.hasFlag(options::OPT_gembed_source, options::OPT_gno_embed_source, | ||||
false)) { | false)) { | ||||
// Source embedding is a vendor extension to DWARF v5. By now we have | // Source embedding is a vendor extension to DWARF v5. By now we have | ||||
// checked if a DWARF version was stated explicitly, and have otherwise | // checked if a DWARF version was stated explicitly, and have otherwise | ||||
// fallen back to the target default, so if this is still not at least 5 | // fallen back to the target default, so if this is still not at least 5 | ||||
// we emit an error. | // we emit an error. | ||||
▲ Show 20 Lines • Show All 2,757 Lines • ▼ Show 20 Lines | void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType, | ||||
} | } | ||||
// Emit CodeView if -Z7, -Zd, or -gline-tables-only are present. | // Emit CodeView if -Z7, -Zd, or -gline-tables-only are present. | ||||
if (Arg *DebugInfoArg = | if (Arg *DebugInfoArg = | ||||
Args.getLastArg(options::OPT__SLASH_Z7, options::OPT__SLASH_Zd, | Args.getLastArg(options::OPT__SLASH_Z7, options::OPT__SLASH_Zd, | ||||
options::OPT_gline_tables_only)) { | options::OPT_gline_tables_only)) { | ||||
*EmitCodeView = true; | *EmitCodeView = true; | ||||
if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7)) | if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7)) | ||||
*DebugInfoKind = codegenoptions::LimitedDebugInfo; | *DebugInfoKind = codegenoptions::DebugInfoConstructor; | ||||
else | else | ||||
*DebugInfoKind = codegenoptions::DebugLineTablesOnly; | *DebugInfoKind = codegenoptions::DebugLineTablesOnly; | ||||
} else { | } else { | ||||
*EmitCodeView = false; | *EmitCodeView = false; | ||||
} | } | ||||
const Driver &D = getToolChain().getDriver(); | const Driver &D = getToolChain().getDriver(); | ||||
EHFlags EH = parseClangCLEHFlags(D, Args); | EHFlags EH = parseClangCLEHFlags(D, Args); | ||||
▲ Show 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, | ||||
codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo; | codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo; | ||||
if (SourceAction->getType() == types::TY_Asm || | if (SourceAction->getType() == types::TY_Asm || | ||||
SourceAction->getType() == types::TY_PP_Asm) { | SourceAction->getType() == types::TY_PP_Asm) { | ||||
// You might think that it would be ok to set DebugInfoKind outside of | // You might think that it would be ok to set DebugInfoKind outside of | ||||
// the guard for source type, however there is a test which asserts | // the guard for source type, however there is a test which asserts | ||||
// that some assembler invocation receives no -debug-info-kind, | // that some assembler invocation receives no -debug-info-kind, | ||||
// and it's not clear whether that test is just overly restrictive. | // and it's not clear whether that test is just overly restrictive. | ||||
DebugInfoKind = (WantDebug ? codegenoptions::LimitedDebugInfo | DebugInfoKind = (WantDebug ? codegenoptions::DebugInfoConstructor | ||||
: codegenoptions::NoDebugInfo); | : codegenoptions::NoDebugInfo); | ||||
// Add the -fdebug-compilation-dir flag if needed. | // Add the -fdebug-compilation-dir flag if needed. | ||||
addDebugCompDirArg(Args, CmdArgs, C.getDriver().getVFS()); | addDebugCompDirArg(Args, CmdArgs, C.getDriver().getVFS()); | ||||
addDebugPrefixMapArg(getToolChain().getDriver(), Args, CmdArgs); | addDebugPrefixMapArg(getToolChain().getDriver(), Args, CmdArgs); | ||||
// Set the AT_producer to the clang version when using the integrated | // Set the AT_producer to the clang version when using the integrated | ||||
// assembler on assembly source files. | // assembler on assembly source files. | ||||
▲ Show 20 Lines • Show All 296 Lines • Show Last 20 Lines |