[PATCH] D77087: [lld-macho] Only mock out libSystem.dylib loading in tests

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 16:35:15 PDT 2020


int3 updated this revision to Diff 256444.
int3 retitled this revision from "[lld-macho] Require executables to link against libSystem.dylib" to "[lld-macho] Only mock out libSystem.dylib loading in tests".
int3 added a comment.

remove error check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77087/new/

https://reviews.llvm.org/D77087

Files:
  lld/MachO/Writer.cpp
  lld/test/MachO/lit.local.cfg


Index: lld/test/MachO/lit.local.cfg
===================================================================
--- lld/test/MachO/lit.local.cfg
+++ lld/test/MachO/lit.local.cfg
@@ -1,3 +1,4 @@
+config.environment['LLD_FORCE_LOAD_LIBSYSTEM'] = '1'
 config.substitutions += [
     ('%lld', 'lld -flavor darwinnew'),
 ]
Index: lld/MachO/Writer.cpp
===================================================================
--- lld/MachO/Writer.cpp
+++ lld/MachO/Writer.cpp
@@ -351,10 +351,13 @@
     }
   }
 
-  // TODO: dyld requires libSystem to be loaded. libSystem is a universal
-  // binary and we don't have support for that yet, so mock it out here.
-  headerSection->addLoadCommand(
-      make<LCLoadDylib>("/usr/lib/libSystem.B.dylib"));
+  if (dylibOrdinal == 1 && config->outputType == MH_EXECUTE) {
+    // Used in tests, as we also run those tests on non-OSX systems.
+    if (StringRef(getenv("LLD_FORCE_LOAD_LIBSYSTEM")) == "1") {
+      headerSection->addLoadCommand(
+          make<LCLoadDylib>("/usr/lib/libSystem.B.dylib"));
+    }
+  }
 }
 
 void Writer::createHiddenSections() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77087.256444.patch
Type: text/x-patch
Size: 1086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200409/61580e81/attachment-0001.bin>


More information about the llvm-commits mailing list