[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 22:49:52 PDT 2020


int3 updated this revision to Diff 256508.
int3 added a comment.

update


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,14 @@
     }
   }
 
-  // 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"));
+  // dyld requires us to load libSystem. This environment variable is used in
+  // tests, as we may also run those tests on non-OSX systems which do not
+  // have libSystem.
+  if (StringRef(getenv("LLD_FORCE_LOAD_LIBSYSTEM")) == "1" &&
+      dylibOrdinal == 1 && config->outputType == MH_EXECUTE) {
+    headerSection->addLoadCommand(
+        make<LCLoadDylib>("/usr/lib/libSystem.B.dylib"));
+  }
 }
 
 void Writer::createHiddenSections() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77087.256508.patch
Type: text/x-patch
Size: 1180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200410/a70de9d6/attachment.bin>


More information about the llvm-commits mailing list