[PATCH] D97905: [lld-macho] Include install name in error messages for dylibs from TBDs

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 3 19:07:44 PST 2021


int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added a project: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Since multiple dylibs can be defined in one TBD, this is
necessary to avoid confusion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97905

Files:
  lld/MachO/InputFiles.cpp
  lld/test/MachO/invalid/incompatible-target-tapi.test


Index: lld/test/MachO/invalid/incompatible-target-tapi.test
===================================================================
--- lld/test/MachO/invalid/incompatible-target-tapi.test
+++ lld/test/MachO/invalid/incompatible-target-tapi.test
@@ -6,5 +6,5 @@
 RUN:   -o /dev/null 2>&1 | FileCheck %s --check-prefix=ARCH
 RUN: not %lld -dylib -arch arm64 -platform_version ios-simulator 14.0 15.0 %t/arm64-test.o \
 RUN:   %S/Inputs/libincompatible.tbd -o /dev/null 2>&1 | FileCheck %s --check-prefix=PLATFORM
-ARCH:     error: {{.*}}libincompatible.tbd is incompatible with x86_64 (macOS)
-PLATFORM: error: {{.*}}libincompatible.tbd is incompatible with arm64 (iOS Simulator)
+ARCH:     error: {{.*}}libincompatible.tbd(/usr/lib/libincompatible.dylib) is incompatible with x86_64 (macOS)
+PLATFORM: error: {{.*}}libincompatible.tbd(/usr/lib/libincompatible.dylib) is incompatible with arm64 (iOS Simulator)
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -79,6 +79,12 @@
 std::string lld::toString(const InputFile *f) {
   if (!f)
     return "<internal>";
+
+  // Multiple dylibs can be defined in one .tbd file.
+  if (auto dylibFile = dyn_cast<DylibFile>(f))
+    if (f->getName().endswith(".tbd"))
+      return (f->getName() + "(" + dylibFile->dylibName + ")").str();
+
   if (f->archiveName.empty())
     return std::string(f->getName());
   return (path::filename(f->archiveName) + "(" + path::filename(f->getName()) +
@@ -699,6 +705,7 @@
 
   if (umbrella == nullptr)
     umbrella = this;
+  dylibName = saver.save(interface.getInstallName());
 
   if (!is_contained(interface.targets(), config->target)) {
     error(toString(this) + " is incompatible with " +
@@ -706,7 +713,6 @@
     return;
   }
 
-  dylibName = saver.save(interface.getInstallName());
   compatibilityVersion = interface.getCompatibilityVersion().rawValue();
   currentVersion = interface.getCurrentVersion().rawValue();
   DylibFile *exportingFile = isImplicitlyLinked(dylibName) ? this : umbrella;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97905.327987.patch
Type: text/x-patch
Size: 2093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/cb061e0b/attachment.bin>


More information about the llvm-commits mailing list