[PATCH] D103812: [lld/mac] Add a test for -reexport_library + -dead_strip_dylibs

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 07:24:21 PDT 2021


thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
thakis requested review of this revision.

Our behavior here already matched ld64, now we have a test for it.

(ld64 even strips the library here if you also pass -needed_library bar.dylib.
That seems wrong to me, and lld honors needed_library in that case.)


https://reviews.llvm.org/D103812

Files:
  lld/test/MachO/dead-strip-dylibs.s


Index: lld/test/MachO/dead-strip-dylibs.s
===================================================================
--- lld/test/MachO/dead-strip-dylibs.s
+++ lld/test/MachO/dead-strip-dylibs.s
@@ -46,6 +46,14 @@
 # NOBARSTRIP: foo.dylib
 # NOBARSTRIP-NOT: bar-strip.dylib
 
+## Even libraries explicitly reexported with -reexport_library are stripped
+## if they are not referenced.
+# RUN: %lld -lSystem %t/main.o -o %t/main %t/foo_with_bar.dylib \
+# RUN:     -reexport_library %t/bar.dylib -dead_strip_dylibs
+# RUN: llvm-otool -L %t/main | FileCheck --check-prefix=NOBAR %s
+# RUN: llvm-otool -l %t/main | FileCheck --check-prefix=NOREEXPORT %s
+# NOREEXPORT-NOT: LC_REEXPORT_DYLIB
+
 ## But -needed_library and -needed-l win over -dead_strip_dylibs again.
 # RUN: %lld -lSystem %t/main.o -o %t/main %t/foo_with_bar.dylib \
 # RUN:     -needed_library %t/bar.dylib -dead_strip_dylibs


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103812.350285.patch
Type: text/x-patch
Size: 883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210607/cbcc798b/attachment.bin>


More information about the llvm-commits mailing list