[lld] r264708 - [ELF, PR27091] - Implemented -t/--trace option
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 29 01:45:41 PDT 2016
Author: grimar
Date: Tue Mar 29 03:45:40 2016
New Revision: 264708
URL: http://llvm.org/viewvc/llvm-project?rev=264708&view=rev
Log:
[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
Added:
lld/trunk/test/ELF/trace.s
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=264708&r1=264707&r2=264708&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Tue Mar 29 03:45:40 2016
@@ -79,6 +79,7 @@ struct Configuration {
bool StripAll;
bool SysvHash = true;
bool Threads;
+ bool Trace;
bool Verbose;
bool WarnCommon;
bool ZExecStack;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=264708&r1=264707&r2=264708&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Mar 29 03:45:40 2016
@@ -90,7 +90,8 @@ static std::vector<MemoryBufferRef> getA
// 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::Inpu
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);
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=264708&r1=264707&r2=264708&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Tue Mar 29 03:45:40 2016
@@ -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<["-"]
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>;
Added: lld/trunk/test/ELF/trace.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/trace.s?rev=264708&view=auto
==============================================================================
--- lld/trunk/test/ELF/trace.s (added)
+++ lld/trunk/test/ELF/trace.s Tue Mar 29 03:45:40 2016
@@ -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
More information about the llvm-commits
mailing list