Index: ELF/Config.h =================================================================== --- ELF/Config.h +++ ELF/Config.h @@ -17,6 +17,7 @@ #include "llvm/Support/CachePruning.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/Endian.h" +#include "llvm/Target/TargetOptions.h" #include @@ -180,6 +181,7 @@ unsigned LTOO; unsigned Optimize; unsigned ThinLTOJobs; + llvm::DebuggerKind LTODebuggerTune = llvm::DebuggerKind::Default; // The following config options do not directly correspond to any // particualr command line options. Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -589,6 +589,18 @@ return V; } +static DebuggerKind parseLTODebuggerTune(StringRef S, opt::Arg *Arg) { + if (S == "gdb") + return DebuggerKind::GDB; + if (S == "lldb") + return DebuggerKind::LLDB; + if (S == "sce") + return DebuggerKind::SCE; + error(Arg->getSpelling() + "=" + Arg->getValue() + ": unknown tune '" + S + + "'"); + return DebuggerKind::Default; +} + // Initializes Config members by the command line options. void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->AllowMultipleDefinition = @@ -697,6 +709,8 @@ Config->LTOPartitions = parseInt(S.substr(15), Arg); else if (S.startswith("jobs=")) Config->ThinLTOJobs = parseInt(S.substr(5), Arg); + else if (S.startswith("-debugger-tune=")) + Config->LTODebuggerTune = parseLTODebuggerTune(S.substr(15), Arg); else if (!S.startswith("/") && !S.startswith("-fresolution=") && !S.startswith("-pass-through=") && !S.startswith("mcpu=") && !S.startswith("thinlto") && S != "-function-sections" && Index: ELF/LTO.cpp =================================================================== --- ELF/LTO.cpp +++ ELF/LTO.cpp @@ -77,6 +77,8 @@ Conf.Options.FunctionSections = true; Conf.Options.DataSections = true; + Conf.Options.DebuggerTuning = Config->LTODebuggerTune; + if (Config->Relocatable) Conf.RelocModel = None; else if (Config->Pic) Index: test/ELF/lto/debugger-tune.s =================================================================== --- test/ELF/lto/debugger-tune.s +++ test/ELF/lto/debugger-tune.s @@ -0,0 +1,10 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -plugin-opt=-debugger-tune=gdb -o /dev/null +# RUN: ld.lld %t -plugin-opt=-debugger-tune=lldb -o /dev/null +# RUN: ld.lld %t -plugin-opt=-debugger-tune=sce -o /dev/null + +# RUN: not ld.lld %t -plugin-opt=-debugger-tune=xxx -o /dev/null 2>&1 | \ +# RUN: FileCheck %s --check-prefix=ERR +# ERR: error: --plugin-opt=-debugger-tune=xxx: unknown tune 'xxx'