[lld] 7331297 - lld: remove old test support path

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 16 15:58:24 PDT 2020


Author: Saleem Abdulrasool
Date: 2020-06-16T15:57:58-07:00
New Revision: 73312976ad8c541d2bb769c26f1172ccc26ad531

URL: https://github.com/llvm/llvm-project/commit/73312976ad8c541d2bb769c26f1172ccc26ad531
DIFF: https://github.com/llvm/llvm-project/commit/73312976ad8c541d2bb769c26f1172ccc26ad531.diff

LOG: lld: remove old test support path

This removes the stub library that lld injected to satisfy the
dependency on the libSystem.  Now with TBD support, we can provide the
stub library to permit the tests to function properly as they would on a
real system.

Reviewed By: smeenai
Differential Revision: https://reviews.llvm.org/D81418

Added: 
    

Modified: 
    lld/MachO/Driver.cpp
    lld/MachO/InputFiles.cpp
    lld/MachO/InputFiles.h
    lld/test/MachO/link-search-order.s
    lld/test/MachO/symbol-order.s

Removed: 
    


################################################################################
diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 1bc18cb0c1b7..adef35be717d 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -389,14 +389,6 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
   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<Defined>(config->entry)) {
     error("undefined symbol: " + config->entry->getName());
     return false;

diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index af80d528e513..ec46daf91f7e 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -398,16 +398,6 @@ DylibFile::DylibFile(std::shared_ptr<llvm::MachO::InterfaceFile> interface,
     reexported.push_back(make<DylibFile>(document, umbrella));
 }
 
-DylibFile::DylibFile() : InputFile(DylibKind, MemoryBufferRef()) {}
-
-DylibFile *DylibFile::createLibSystemMock() {
-  auto *file = make<DylibFile>();
-  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<llvm::object::Archive> &&f)
     : InputFile(ArchiveKind, f->getMemoryBufferRef()), file(std::move(f)) {
   for (const object::Archive::Symbol &sym : file->symbols())

diff  --git a/lld/MachO/InputFiles.h b/lld/MachO/InputFiles.h
index 992e7b774b0f..bc5ad86ccaa9 100644
--- a/lld/MachO/InputFiles.h
+++ b/lld/MachO/InputFiles.h
@@ -89,11 +89,6 @@ class DylibFile : public InputFile {
 
   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/test/MachO/link-search-order.s b/lld/test/MachO/link-search-order.s
index 545b58ef44e9..ba1aadc5d32f 100644
--- 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
index 7ea97c4e9a36..04a392be78f3 100644
--- 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/Inputs/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


        


More information about the llvm-commits mailing list