diff options
author | Davide Italiano <davide@freebsd.org> | 2016-04-03 02:16:56 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2016-04-03 02:16:56 +0000 |
commit | 887d76c392998d3948d3157aa902c565b0e389f8 (patch) | |
tree | 6750cda40b19355d262e97cad051f0f01108c1c1 | |
parent | d4f5a059e06c9dba9c5fb63c60cb044b673f5c17 (diff) | |
download | bcm5719-llvm-887d76c392998d3948d3157aa902c565b0e389f8.tar.gz bcm5719-llvm-887d76c392998d3948d3157aa902c565b0e389f8.zip |
[LTO] Fix -save-temps in case -o is not specified.
Currently we create a file called .lto.bc. In UNIX,
ls(1) by default doesn't show up files starting with
a dot, as they're (only by convention) hidden.
This makes the output of -save-temps a little bit
hard to find. Use "a.out.lto.bc" instead if the
output file is not specified.
While here, change an existing -save-temps test to
exercise this more interesting behaviour.
llvm-svn: 265254
-rw-r--r-- | lld/ELF/Driver.cpp | 10 | ||||
-rw-r--r-- | lld/test/ELF/lto/save-temps.ll | 12 |
2 files changed, 13 insertions, 9 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) diff --git a/lld/test/ELF/lto/save-temps.ll b/lld/test/ELF/lto/save-temps.ll index a7fe96708d7..5c47741e575 100644 --- a/lld/test/ELF/lto/save-temps.ll +++ b/lld/test/ELF/lto/save-temps.ll @@ -1,12 +1,12 @@ ; REQUIRES: x86 -; RUN: rm -f %t %t.lto.bc %t.lto.o +; RUN: rm -f a.out a.out.lto.bc a.out.lto.o ; RUN: llvm-as %s -o %t.o ; RUN: llvm-as %p/Inputs/save-temps.ll -o %t2.o -; RUN: ld.lld -shared -m elf_x86_64 %t.o %t2.o -o %t -save-temps -; RUN: llvm-nm %t | FileCheck %s -; RUN: llvm-nm %t.lto.bc | FileCheck %s -; RUN: llvm-nm %t.lto.o | FileCheck %s -; RUN: llvm-dis %t.lto.bc +; RUN: ld.lld -shared -m elf_x86_64 %t.o %t2.o -save-temps +; RUN: llvm-nm a.out | FileCheck %s +; RUN: llvm-nm a.out.lto.bc | FileCheck %s +; RUN: llvm-nm a.out.lto.o | FileCheck %s +; RUN: llvm-dis a.out.lto.bc target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |