[PATCH] D103428: [lld/mac] Make -t work correctly with -flat_namespace

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 31 15:32:20 PDT 2021


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

Fixes PR49514.


https://reviews.llvm.org/D103428

Files:
  lld/MachO/Driver.cpp
  lld/MachO/DriverUtils.cpp
  lld/test/MachO/flat-namespace.s


Index: lld/test/MachO/flat-namespace.s
===================================================================
--- lld/test/MachO/flat-namespace.s
+++ lld/test/MachO/flat-namespace.s
@@ -14,7 +14,12 @@
 
 # With flat_namespace, the linker automatically looks in foo.dylib and
 # bar.dylib too, but it doesn't add a LC_LOAD_DYLIB for it.
-# RUN: %lld -flat_namespace -lSystem %t/main.o %t/baz.dylib -o %t/out
+# RUN: %lld -flat_namespace -lSystem %t/main.o %t/baz.dylib -o %t/out -t | \
+# RUN:   FileCheck --check-prefix=T %s
+# T: main.o
+# T-NEXT: baz.dylib
+# T-NEXT: bar.dylib
+# T-NEXT: foo.dylib
 # RUN: llvm-objdump --macho --all-headers %t/out \
 # RUN:     | FileCheck --check-prefix=HEADERBITS %s
 # RUN: llvm-objdump --macho --bind --lazy-bind --weak-bind %t/out \
Index: lld/MachO/DriverUtils.cpp
===================================================================
--- lld/MachO/DriverUtils.cpp
+++ lld/MachO/DriverUtils.cpp
@@ -215,6 +215,8 @@
       return {};
     }
     file = make<DylibFile>(**result, umbrella, isBundleLoader);
+    if (config->printEachFile)
+      message(toString(file));
 
     // parseReexports() can recursively call loadDylib(). That's fine since
     // we wrote DylibFile we just loaded to the loadDylib cache via the `file`
@@ -229,6 +231,8 @@
            magic == file_magic::macho_executable ||
            magic == file_magic::macho_bundle);
     file = make<DylibFile>(mbref, umbrella, isBundleLoader);
+    if (config->printEachFile)
+      message(toString(file));
 
     // parseLoadCommands() can also recursively call loadDylib(). See comment
     // in previous block for why this means we must copy `file` here.
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -315,7 +315,8 @@
   if (newFile) {
     // printArchiveMemberLoad() prints both .a and .o names, so no need to
     // print the .a name here.
-    if (config->printEachFile && magic != file_magic::archive)
+    if (config->printEachFile && magic != file_magic::archive &&
+        !isa<DylibFile>(newFile))
       message(toString(newFile));
     inputFiles.insert(newFile);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103428.348865.patch
Type: text/x-patch
Size: 2195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210531/aa780893/attachment.bin>


More information about the llvm-commits mailing list