diff options
Diffstat (limited to 'lld/ELF/Driver.cpp')
-rw-r--r-- | lld/ELF/Driver.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 0a5123c2daf..e828700a97e 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -434,14 +434,18 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { for (StringRef S : Config->Undefined) Symtab.addUndefinedOpt(S); + // -save-temps creates a file based on the output file name so we want + // to set it right before LTO. This code can't be moved to option parsing + // because linker scripts can override the output filename using the + // OUTPUT() directive. + if (Config->OutputFile.empty()) + Config->OutputFile = "a.out"; + Symtab.addCombinedLtoObject(); for (auto *Arg : Args.filtered(OPT_wrap)) Symtab.wrap(Arg->getValue()); - if (Config->OutputFile.empty()) - Config->OutputFile = "a.out"; - // Write the result to the file. Symtab.scanShlibUndefined(); if (Config->GcSections) |