Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -98,7 +98,7 @@ // Newly created memory buffers are owned by this driver. void LinkerDriver::addFile(StringRef Path) { using namespace llvm::sys::fs; - if (Config->Verbose || Config->Trace) + if (Config->Verbose) llvm::outs() << Path << "\n"; auto MBOrErr = MemoryBuffer::getFile(Path); if (!MBOrErr) { Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -45,6 +45,15 @@ return false; } +// Returns "(internal)", "foo.a(bar.o)" or "baz.o". +static std::string getFilename(InputFile *F) { + if (!F) + return "(internal)"; + if (!F->ArchiveName.empty()) + return (F->ArchiveName + "(" + F->getName() + ")").str(); + return F->getName(); +} + // Add symbols in File to the symbol table. template void SymbolTable::addFile(std::unique_ptr File) { @@ -61,6 +70,9 @@ return; } + if (Config->Trace) + llvm::outs() << getFilename(FileP) << "\n"; + // .so file if (auto *F = dyn_cast>(FileP)) { // DSOs are uniquified not by filename but by soname. @@ -206,15 +218,6 @@ return nullptr; } -// Returns "(internal)", "foo.a(bar.o)" or "baz.o". -static std::string getFilename(InputFile *F) { - if (!F) - return "(internal)"; - if (!F->ArchiveName.empty()) - return (F->ArchiveName + "(" + F->getName() + ")").str(); - return F->getName(); -} - // Construct a string in the form of "Sym in File1 and File2". // Used to construct an error message. template Index: test/ELF/Inputs/trace-ar1.s =================================================================== --- test/ELF/Inputs/trace-ar1.s +++ test/ELF/Inputs/trace-ar1.s @@ -0,0 +1,2 @@ +.globl _used; +_used: Index: test/ELF/Inputs/trace-ar2.s =================================================================== --- test/ELF/Inputs/trace-ar2.s +++ test/ELF/Inputs/trace-ar2.s @@ -0,0 +1,2 @@ +.globl _notused; +_notused: Index: test/ELF/trace-ar.s =================================================================== --- test/ELF/trace-ar.s +++ test/ELF/trace-ar.s @@ -0,0 +1,15 @@ +# 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 %p/Inputs/trace-ar1.s -o %t.obj1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/trace-ar2.s -o %t.obj2.o +# RUN: llvm-ar rcs %t.boo.a %t.obj1.o %t.obj2.o + +## Check how -t works with achieves +# RUN: ld.lld %t.foo.o %t.boo.a -o %t.out -t 2>&1 | FileCheck %s +# CHECK: {{.*}}.foo.o +# CHECK-NEXT: {{.*}}.boo.a({{.*}}.obj1.o) +# CHECK-NOT: {{.*}}.boo.a({{.*}}.obj2.o) + +.globl _start, _used +_start: + call _used