Skip to content

Commit

Permalink
lld-link: Make /linkrepro: take a filename, not a directory.
Browse files Browse the repository at this point in the history
This makes lld-link behave like ld.lld. I don't see a reason for
the two drivers to have different behavior here.

While here, also make lld-link add a version.txt to the tar, like
ld.lld does.

Differential Revision: https://reviews.llvm.org/D67461

llvm-svn: 371729
  • Loading branch information
nico committed Sep 12, 2019
1 parent 646e1f7 commit 3c44d59
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
12 changes: 5 additions & 7 deletions lld/COFF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
using namespace llvm;
using namespace llvm::object;
using namespace llvm::COFF;
using llvm::sys::Process;
using namespace llvm::sys;

namespace lld {
namespace coff {
Expand Down Expand Up @@ -1138,17 +1138,15 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
config->mingw = args.hasArg(OPT_lldmingw);

if (auto *arg = args.getLastArg(OPT_linkrepro)) {
SmallString<64> path = StringRef(arg->getValue());
sys::path::append(path, "repro.tar");
const char *path = arg->getValue();

Expected<std::unique_ptr<TarWriter>> errOrWriter =
TarWriter::create(path, "repro");

TarWriter::create(path, path::stem(path));
if (errOrWriter) {
tar = std::move(*errOrWriter);
tar->append("version.txt", getLLDVersion() + "\n");
} else {
error("/linkrepro: failed to open " + path + ": " +
toString(errOrWriter.takeError()));
error("/linkrepro: " + toString(errOrWriter.takeError()));
}
}

Expand Down
3 changes: 3 additions & 0 deletions lld/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ ELF Improvements
COFF Improvements
-----------------

* /linkrepro: now takes the filename of the tar archive it writes, instead
of the name of a directory that a file called "repro.tar" is created in,
matching the behavior of ELF lld.
* ...

MinGW Improvements
Expand Down
2 changes: 1 addition & 1 deletion lld/test/COFF/linkrepro-res.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# RUN: mkdir -p %t.dir/build
# RUN: cd %t.dir/build
# RUN: lld-link %p/Inputs/resource.res /subsystem:console /machine:x64 \
# RUN: /entry:__ImageBase /linkrepro:. /out:%t.exe
# RUN: /entry:__ImageBase /linkrepro:repro.tar /out:%t.exe
# RUN: tar xf repro.tar
# RUN: diff %p/Inputs/resource.res repro/%:p/Inputs/resource.res
# RUN: FileCheck %s --check-prefix=RSP < repro/response.txt
Expand Down
6 changes: 3 additions & 3 deletions lld/test/COFF/linkrepro.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

# RUN: cd %t.dir/build1
# RUN: lld-link %t.obj %p/Inputs/std32.lib /subsystem:console \
# RUN: /entry:main@0 /linkrepro:. /out:%t.exe
# RUN: /entry:main@0 /linkrepro:repro.tar /out:%t.exe
# RUN: tar xf repro.tar
# RUN: diff %t.obj repro/%:t.obj
# RUN: diff %p/Inputs/std32.lib repro/%:p/Inputs/std32.lib
# RUN: FileCheck %s --check-prefix=RSP < repro/response.txt

# RUN: cd %t.dir/build2
# RUN: lld-link %t.obj /libpath:%p/Inputs /defaultlib:std32 /subsystem:console \
# RUN: /entry:main@0 /linkrepro:. /out:%t.exe
# RUN: /entry:main@0 /linkrepro:repro.tar /out:%t.exe
# RUN: tar xf repro.tar
# RUN: diff %t.obj repro/%:t.obj
# RUN: diff %p/Inputs/std32.lib repro/%:p/Inputs/std32.lib
# RUN: FileCheck %s --check-prefix=RSP < repro/response.txt

# RUN: cd %t.dir/build3
# RUN: env LIB=%p/Inputs lld-link %t.obj /defaultlib:std32 /subsystem:console \
# RUN: /entry:main@0 /linkrepro:. /out:%t.exe
# RUN: /entry:main@0 /linkrepro:repro.tar /out:%t.exe
# RUN: tar xf repro.tar
# RUN: diff %t.obj repro/%:t.obj
# RUN: diff %p/Inputs/std32.lib repro/%:p/Inputs/std32.lib
Expand Down

0 comments on commit 3c44d59

Please sign in to comment.