Skip to content

Commit

Permalink
[lld/mac] Support more flags for --reproduce
Browse files Browse the repository at this point in the history
I went through the callers of `readFile()` and `addFile()` in Driver.cpp
and checked that the options that use them all get rewritten in the
--reproduce response file. -(un)exported_symbols_list and -bundle_loader
weren't, so add them.

Also spruce up the test for reproduce a bit and actually try linking
with the exptracted repro archive.

Motivated by the response file in PR50098 complaining abou the
-exported_symbols_list path being wrong :)

Differential Revision: https://reviews.llvm.org/D101182
  • Loading branch information
nico committed Apr 23, 2021
1 parent f2819ee commit a61891d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
9 changes: 6 additions & 3 deletions lld/MachO/DriverUtils.cpp
Expand Up @@ -140,12 +140,15 @@ std::string macho::createResponseFile(const InputArgList &args) {
for (StringRef path : args::getLines(*buffer))
os << quote(rewritePath(path)) << "\n";
break;
case OPT_force_load:
case OPT_rpath:
case OPT_syslibroot:
case OPT_F:
case OPT_L:
case OPT_bundle_loader:
case OPT_exported_symbols_list:
case OPT_force_load:
case OPT_order_file:
case OPT_rpath:
case OPT_syslibroot:
case OPT_unexported_symbols_list:
os << arg->getSpelling() << " " << quote(rewritePath(arg->getValue()))
<< "\n";
break;
Expand Down
29 changes: 20 additions & 9 deletions lld/test/MachO/reproduce.s
Expand Up @@ -3,35 +3,46 @@
# RUN: rm -rf %t.dir
# RUN: mkdir -p %t.dir/build1
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.dir/build1/foo.o
# RUN: echo '_main' > %t.dir/main.exports
# RUN: cd %t.dir
# RUN: %lld -platform_version macos 10.10.0 11.0 build1/foo.o -o bar --reproduce repro1.tar
# RUN: tar xOf repro1.tar repro1/%:t.dir/build1/foo.o > build1-foo.o
# RUN: cmp build1/foo.o build1-foo.o
# RUN: %lld -platform_version macos 10.10.0 11.0 \
# RUN: -exported_symbols_list main.exports \
# RUN: build1/foo.o -o bar --reproduce repro1.tar

# RUN: tar xf repro1.tar repro1/response.txt repro1/version.txt
# RUN: tar tf repro1.tar | FileCheck -DPATH='%:t.dir' --check-prefix=LIST %s
# LIST: repro1/response.txt
# LIST: [[PATH]]/main.exports
# LIST: [[PATH]]/build1/foo.o

# RUN: tar xf repro1.tar
# RUN: cmp build1/foo.o repro1/%:t.dir/build1/foo.o
# RUN: diff main.exports repro1/%:t.dir/main.exports
# RUN: FileCheck %s --check-prefix=RSP1 < repro1/response.txt
# RSP1: {{^}}-platform_version macos 10.10.0 11.0{{$}}
# RSP1-NEXT: -exported_symbols_list [[BASEDIR:.+]]/main.exports
# RSP1-NOT: {{^}}repro1{{[/\\]}}
# RSP1-NEXT: {{[/\\]}}foo.o
# RSP1-NEXT: [[BASEDIR]]/build1/foo.o
# RSP1-NEXT: -o bar
# RSP1-NOT: --reproduce

# RUN: FileCheck %s --check-prefix=VERSION < repro1/version.txt
# VERSION: LLD

# RUN: cd repro1; ld64.lld @response.txt

# RUN: mkdir -p %t.dir/build2/a/b/c
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.dir/build2/foo.o
# RUN: cd %t.dir/build2/a/b/c
# RUN: echo ./../../../foo.o > %t.dir/build2/filelist
# RUN: env LLD_REPRODUCE=repro2.tar %lld -filelist %t.dir/build2/filelist -o /dev/null
# RUN: tar xOf repro2.tar repro2/%:t.dir/build2/foo.o > build2-foo.o
# RUN: cmp %t.dir/build2/foo.o build2-foo.o

# RUN: tar xf repro2.tar repro2/response.txt repro2/version.txt
# RUN: tar xf repro2.tar
# RUN: cmp %t.dir/build2/foo.o repro2/%:t.dir/build2/foo.o
# RUN: FileCheck %s --check-prefix=RSP2 < repro2/response.txt
# RSP2-NOT: {{^}}repro2{{[/\\]}}
# RSP2: {{[/\\]}}foo.o

# RUN: cd repro2; ld64.lld @response.txt

.globl _main
_main:
ret

0 comments on commit a61891d

Please sign in to comment.