[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
Mon Apr 27 13:28:17 PDT 2020


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

rebase


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


Index: lld/MachO/Writer.cpp
===================================================================
--- lld/MachO/Writer.cpp
+++ lld/MachO/Writer.cpp
@@ -372,10 +372,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_IN_TEST")) == "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.260435.patch
Type: text/x-patch
Size: 857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/e32020dd/attachment.bin>


More information about the llvm-commits mailing list