[lld] 0d4dadc - [lld-macho] Include install name in error messages for dylibs from TBDs
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 4 11:37:15 PST 2021
Author: Jez Ng
Date: 2021-03-04T14:36:49-05:00
New Revision: 0d4dadc64c4f3e072bf0410dc522e5e1f2731c01
URL: https://github.com/llvm/llvm-project/commit/0d4dadc64c4f3e072bf0410dc522e5e1f2731c01
DIFF: https://github.com/llvm/llvm-project/commit/0d4dadc64c4f3e072bf0410dc522e5e1f2731c01.diff
LOG: [lld-macho] Include install name in error messages for dylibs from TBDs
Since multiple dylibs can be defined in one TBD, this is
necessary to avoid confusion.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D97905
Added:
Modified:
lld/MachO/InputFiles.cpp
lld/test/MachO/invalid/incompatible-target-tapi.test
Removed:
################################################################################
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index cf2b8cc16c20..6dd211a29e8a 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -79,6 +79,12 @@ using namespace lld::macho;
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()) +
@@ -697,15 +703,16 @@ DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella,
if (umbrella == nullptr)
umbrella = this;
+ dylibName = saver.save(interface.getInstallName());
+ compatibilityVersion = interface.getCompatibilityVersion().rawValue();
+ currentVersion = interface.getCurrentVersion().rawValue();
+
if (!is_contained(interface.targets(), config->target)) {
error(toString(this) + " is incompatible with " +
std::string(config->target));
return;
}
- dylibName = saver.save(interface.getInstallName());
- compatibilityVersion = interface.getCompatibilityVersion().rawValue();
- currentVersion = interface.getCurrentVersion().rawValue();
DylibFile *exportingFile = isImplicitlyLinked(dylibName) ? this : umbrella;
auto addSymbol = [&](const Twine &name) -> void {
symbols.push_back(symtab->addDylib(saver.save(name), exportingFile,
diff --git a/lld/test/MachO/invalid/incompatible-target-tapi.test b/lld/test/MachO/invalid/incompatible-target-tapi.test
index 47d54527a945..f99f63c67e78 100644
--- a/lld/test/MachO/invalid/incompatible-target-tapi.test
+++ b/lld/test/MachO/invalid/incompatible-target-tapi.test
@@ -6,5 +6,5 @@ RUN: not %lld -dylib -arch x86_64 %S/Inputs/libincompatible.tbd %t/x86_64-test.o
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)
More information about the llvm-commits
mailing list