[lld] a61891d - [lld/mac] Support more flags for --reproduce

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 23 11:50:28 PDT 2021


Author: Nico Weber
Date: 2021-04-23T14:40:24-04:00
New Revision: a61891d491bdd991f837d02fedf66c99e69c9a1f

URL: https://github.com/llvm/llvm-project/commit/a61891d491bdd991f837d02fedf66c99e69c9a1f
DIFF: https://github.com/llvm/llvm-project/commit/a61891d491bdd991f837d02fedf66c99e69c9a1f.diff

LOG: [lld/mac] Support more flags for --reproduce

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

Added: 
    

Modified: 
    lld/MachO/DriverUtils.cpp
    lld/test/MachO/reproduce.s

Removed: 
    


################################################################################
diff  --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 064a509f47c8f..bbbc339c31772 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -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;

diff  --git a/lld/test/MachO/reproduce.s b/lld/test/MachO/reproduce.s
index 19055a035e509..f618277ac8382 100644
--- a/lld/test/MachO/reproduce.s
+++ b/lld/test/MachO/reproduce.s
@@ -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


        


More information about the llvm-commits mailing list