diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -338,14 +338,6 @@ if (!orderFile.empty()) parseOrderFile(orderFile); - // dyld requires us to load libSystem. Since we may run tests on non-OSX - // systems which do not have libSystem, we mock it out here. - // TODO: Replace this with a stub tbd file once we have TAPI support. - if (StringRef(getenv("LLD_IN_TEST")) == "1" && - config->outputType == MH_EXECUTE) { - inputFiles.push_back(DylibFile::createLibSystemMock()); - } - if (config->outputType == MH_EXECUTE && !isa(config->entry)) { error("undefined symbol: " + config->entry->getName()); return false; diff --git a/lld/MachO/InputFiles.h b/lld/MachO/InputFiles.h --- a/lld/MachO/InputFiles.h +++ b/lld/MachO/InputFiles.h @@ -89,11 +89,6 @@ static bool classof(const InputFile *f) { return f->kind() == DylibKind; } - // Do not use this constructor!! This is meant only for createLibSystemMock(), - // but it cannot be made private as we call it via make(). - DylibFile(); - static DylibFile *createLibSystemMock(); - StringRef dylibName; uint64_t ordinal = 0; // Ordinal numbering starts from 1, so 0 is a sentinel bool reexport = false; diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -397,16 +397,6 @@ reexported.push_back(make(document, umbrella)); } -DylibFile::DylibFile() : InputFile(DylibKind, MemoryBufferRef()) {} - -DylibFile *DylibFile::createLibSystemMock() { - auto *file = make(); - file->mb = MemoryBufferRef("", "/usr/lib/libSystem.B.dylib"); - file->dylibName = "/usr/lib/libSystem.B.dylib"; - file->symbols.push_back(symtab->addDylib("dyld_stub_binder", file)); - return file; -} - ArchiveFile::ArchiveFile(std::unique_ptr &&f) : InputFile(ArchiveKind, f->getMemoryBufferRef()), file(std::move(f)) { for (const object::Archive::Symbol &sym : file->symbols()) diff --git a/lld/test/MachO/link-search-order.s b/lld/test/MachO/link-search-order.s --- a/lld/test/MachO/link-search-order.s +++ b/lld/test/MachO/link-search-order.s @@ -10,7 +10,7 @@ # RUN: llvm-ar --format=darwin crs %t/libgoodbye.a %t/goodbye.o # # RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o -# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test -Z -L%t -lhello -lgoodbye %t/test.o +# RUN: lld -flavor darwinnew -arch x86_64 -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z -L%t -lhello -lgoodbye -lSystem %t/test.o # # RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck %s diff --git a/lld/test/MachO/symbol-order.s b/lld/test/MachO/symbol-order.s --- a/lld/test/MachO/symbol-order.s +++ b/lld/test/MachO/symbol-order.s @@ -5,7 +5,7 @@ # RUN: echo ".global f; .section __TEXT,test_f2; f: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/f2.o # RUN: echo ".global f, g; .section __TEXT,test_fg; f: ret; g: callq f" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/fg.o # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o -# RUN: lld -flavor darwinnew -arch x86_64 -dylib -o %t/libf1.dylib %t/f1.o +# RUN: lld -flavor darwinnew -arch x86_64 -L%S/MacOSX.sdk/usr/lib -dylib -o %t/libf1.dylib %t/f1.o -lSystem # RUN: rm -f %t/libf2_g.a # RUN: llvm-ar rcs %t/libf2_g.a %t/f2.o %t/g.o @@ -13,7 +13,7 @@ # RUN: rm -f %t/libfg.a # RUN: llvm-ar rcs %t/libfg.a %t/fg.o -# RUN: lld -flavor darwinnew -arch x86_64 %t/libf1.dylib %t/libf2_g.a %t/test.o -o %t/test.out +# RUN: lld -flavor darwinnew -arch x86_64 -L%S/Inputs/MacOSX.sdk/usr/lib %t/libf1.dylib %t/libf2_g.a %t/test.o -o %t/test.out -lSystem # RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix DYLIB-FIRST # DYLIB-FIRST: SYMBOL TABLE: # DYLIB-FIRST-DAG: __TEXT,test_g g @@ -21,7 +21,7 @@ # DYLIB-FIRST-NEXT: segment section address dylib symbol # DYLIB-FIRST-NEXT: __DATA __la_symbol_ptr {{[0-9a-z]+}} libf1 f -# RUN: lld -flavor darwinnew -arch x86_64 %t/libf2_g.a %t/libf1.dylib %t/test.o -o %t/test.out +# RUN: lld -flavor darwinnew -arch x86_64 -L%S/Inputs/MacOSX.sdk/usr/lib %t/libf2_g.a %t/libf1.dylib %t/test.o -o %t/test.out -lSystem # RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST # ARCHIVE-FIRST: SYMBOL TABLE: # ARCHIVE-FIRST-DAG: __TEXT,test_f2 f @@ -30,7 +30,7 @@ # ARCHIVE-FIRST-NEXT: segment section address dylib symbol # ARCHIVE-FIRST-EMPTY: -# RUN: lld -flavor darwinnew -arch x86_64 %t/libf1.dylib %t/libfg.a %t/test.o -o %t/test.out +# RUN: lld -flavor darwinnew -arch x86_64 -L%S/Inputs/MacOSX.sdk/usr/lib %t/libf1.dylib %t/libfg.a %t/test.o -o %t/test.out -lSystem # RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-PRIORITY # ARCHIVE-PRIORITY: SYMBOL TABLE: # ARCHIVE-PRIORITY-DAG: __TEXT,test_fg f