diff options
author | George Rimar <grimar@accesssoftek.com> | 2016-03-29 08:45:40 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2016-03-29 08:45:40 +0000 |
commit | 1e4b39f18448db4c7e77341a861847752ddce875 (patch) | |
tree | f8ba4d3e0926ef3142a58e417ea3f54a000cf1e3 | |
parent | 86971050cb3263e4fa3f7735365e21e797f6a1bc (diff) | |
download | bcm5719-llvm-1e4b39f18448db4c7e77341a861847752ddce875.tar.gz bcm5719-llvm-1e4b39f18448db4c7e77341a861847752ddce875.zip |
[ELF, PR27091] - Implemented -t/--trace option
-t/--trace
Print the names of the input files as ld processes them.
This fixes https://llvm.org/bugs/show_bug.cgi?id=27091.
Differential revision: http://reviews.llvm.org/D18517
llvm-svn: 264708
-rw-r--r-- | lld/ELF/Config.h | 1 | ||||
-rw-r--r-- | lld/ELF/Driver.cpp | 4 | ||||
-rw-r--r-- | lld/ELF/Options.td | 4 | ||||
-rw-r--r-- | lld/test/ELF/trace.s | 20 |
4 files changed, 28 insertions, 1 deletions
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index b75a599d7c2..591b62546d4 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -79,6 +79,7 @@ struct Configuration { bool StripAll; bool SysvHash = true; bool Threads; + bool Trace; bool Verbose; bool WarnCommon; bool ZExecStack; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 68dce6f72cb..9ec302e8d02 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -90,7 +90,8 @@ static std::vector<MemoryBufferRef> getArchiveMembers(MemoryBufferRef MB) { // Newly created memory buffers are owned by this driver. void LinkerDriver::addFile(StringRef Path) { using namespace llvm::sys::fs; - log(Path); + if (Config->Verbose || Config->Trace) + llvm::outs() << Path << "\n"; auto MBOrErr = MemoryBuffer::getFile(Path); if (!MBOrErr) { error(MBOrErr, "cannot open " + Path); @@ -250,6 +251,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->Shared = Args.hasArg(OPT_shared); Config->StripAll = Args.hasArg(OPT_strip_all); Config->Threads = Args.hasArg(OPT_threads); + Config->Trace = Args.hasArg(OPT_trace); Config->Verbose = Args.hasArg(OPT_verbose); Config->WarnCommon = Args.hasArg(OPT_warn_common); diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td index 11b7c1fba9d..6b4ead28005 100644 --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -126,6 +126,9 @@ def sysroot : Joined<["--"], "sysroot=">, def threads : Joined<["--"], "threads">; +def trace: Flag<["--"], "trace">, + HelpText<"Print the names of the input files">; + def undefined : Joined<["--"], "undefined=">, HelpText<"Force undefined symbol during linking">; @@ -169,6 +172,7 @@ def alias_shared_Bshareable : Flag<["-"], "Bshareable">, Alias<shared>; def alias_soname_h : JoinedOrSeparate<["-"], "h">, Alias<soname>; def alias_soname_soname : Separate<["-"], "soname">, Alias<soname>; def alias_script_T : JoinedOrSeparate<["-"], "T">, Alias<script>; +def alias_trace : Flag<["-"], "t">, Alias<trace>; def alias_strip_all: Flag<["-"], "s">, Alias<strip_all>; def alias_undefined_u : JoinedOrSeparate<["-"], "u">, Alias<undefined>; def alias_wrap_wrap : Joined<["--", "-"], "wrap=">, Alias<wrap>; diff --git a/lld/test/ELF/trace.s b/lld/test/ELF/trace.s new file mode 100644 index 00000000000..59db2ffbc8a --- /dev/null +++ b/lld/test/ELF/trace.s @@ -0,0 +1,20 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.foo.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.bar.o + +## Check -t +# RUN: ld.lld -shared %t.foo.o -o %t.so -t 2>&1 | FileCheck %s +# CHECK: {{.*}}.foo.o + +## Check --trace alias +# RUN: ld.lld -shared %t.foo.o -o %t.so -t 2>&1 | FileCheck %s + +## Check output messages order (1) +# RUN: ld.lld -shared %t.foo.o %t1.bar.o -o %t.so -t 2>&1 | FileCheck -check-prefix=ORDER1 %s +# ORDER1: {{.*}}.foo.o +# ORDER1: {{.*}}.bar.o + +## Check output messages order (2) +# RUN: ld.lld -shared %t1.bar.o %t.foo.o -o %t.so -t 2>&1 | FileCheck -check-prefix=ORDER2 %s +# ORDER2: {{.*}}.bar.o +# ORDER2: {{.*}}.foo.o |