Skip to content

Commit 3c44d59

Browse files
committedSep 12, 2019
lld-link: Make /linkrepro: take a filename, not a directory.
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
1 parent 646e1f7 commit 3c44d59

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed
 

‎lld/COFF/Driver.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
using namespace llvm;
5151
using namespace llvm::object;
5252
using namespace llvm::COFF;
53-
using llvm::sys::Process;
53+
using namespace llvm::sys;
5454

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

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

11441143
Expected<std::unique_ptr<TarWriter>> errOrWriter =
1145-
TarWriter::create(path, "repro");
1146-
1144+
TarWriter::create(path, path::stem(path));
11471145
if (errOrWriter) {
11481146
tar = std::move(*errOrWriter);
1147+
tar->append("version.txt", getLLDVersion() + "\n");
11491148
} else {
1150-
error("/linkrepro: failed to open " + path + ": " +
1151-
toString(errOrWriter.takeError()));
1149+
error("/linkrepro: " + toString(errOrWriter.takeError()));
11521150
}
11531151
}
11541152

‎lld/docs/ReleaseNotes.rst

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ ELF Improvements
2929
COFF Improvements
3030
-----------------
3131

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

3437
MinGW Improvements

‎lld/test/COFF/linkrepro-res.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# RUN: mkdir -p %t.dir/build
55
# RUN: cd %t.dir/build
66
# RUN: lld-link %p/Inputs/resource.res /subsystem:console /machine:x64 \
7-
# RUN: /entry:__ImageBase /linkrepro:. /out:%t.exe
7+
# RUN: /entry:__ImageBase /linkrepro:repro.tar /out:%t.exe
88
# RUN: tar xf repro.tar
99
# RUN: diff %p/Inputs/resource.res repro/%:p/Inputs/resource.res
1010
# RUN: FileCheck %s --check-prefix=RSP < repro/response.txt

‎lld/test/COFF/linkrepro.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66

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

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.