[PATCH] D88877: [ELF] Drop --whole-archive before processing dependent libraries.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 22 23:46:56 PDT 2020


ikudrin updated this revision to Diff 300179.
ikudrin marked 4 inline comments as done.
ikudrin added a comment.

- Updated the test as suggested. Thanks, @bd1976llvm!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88877/new/

https://reviews.llvm.org/D88877

Files:
  lld/ELF/Driver.cpp
  lld/test/ELF/deplibs-ignore-whole-archive.s


Index: lld/test/ELF/deplibs-ignore-whole-archive.s
===================================================================
--- /dev/null
+++ lld/test/ELF/deplibs-ignore-whole-archive.s
@@ -0,0 +1,25 @@
+# REQUIRES: x86
+
+## Check that the dependent libraries are processed in --no-whole-archive mode
+## even if there is an unterminated --whole-archive on the command line. This
+## behaviour is desirable because, applying --whole-archive to the "invisible"
+## dependent libraries is confusing, and not all build-systems support allowing
+## developers to add --no-whole-archive to the very end of the command line.
+
+# RUN: rm -rf %t.dir
+# RUN: mkdir -p %t.dir
+# RUN: cd %t.dir
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o main.o
+# RUN: echo ".global foo; foo:" | \
+# RUN:   llvm-mc -filetype=obj -triple=x86_64 - -o foo.o
+# RUN: echo ".global bar; bar:" | \
+# RUN:   llvm-mc -filetype=obj -triple=x86_64 - -o bar.o
+# RUN: llvm-ar rc libfoobar.a foo.o bar.o
+
+# RUN: ld.lld -o %t --whole-archive -L. -u foo main.o
+# RUN: llvm-nm %t | FileCheck %s
+
+# CHECK-NOT: bar
+
+  .section ".deplibs","MS", at llvm_dependent_libraries,1
+  .asciz  "foobar"
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1419,6 +1419,9 @@
 
   if (files.empty() && errorCount() == 0)
     error("no input files");
+
+  // Dependent libraries should be linked in --no-whole-archive mode.
+  inWholeArchive = false;
 }
 
 // If -m <machine_type> was not given, infer it from object files.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88877.300179.patch
Type: text/x-patch
Size: 1571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201023/a0a5f2f8/attachment.bin>


More information about the llvm-commits mailing list