[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
This commit is contained in:
Jez Ng 2021-03-04 14:36:49 -05:00
parent 55a32812fa
commit 0d4dadc64c
2 changed files with 12 additions and 5 deletions

View File

@ -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,

View File

@ -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)