[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
       
    Sun Apr 12 23:01:28 PDT 2020
    
    
  
int3 marked an inline comment as done.
int3 added inline comments.
================
Comment at: lld/MachO/Writer.cpp:357-361
+  if (StringRef(getenv("LLD_FORCE_LOAD_LIBSYSTEM")) == "1" &&
+      dylibOrdinal == 1 && config->outputType == MH_EXECUTE) {
+    headerSection->addLoadCommand(
+        make<LCLoadDylib>("/usr/lib/libSystem.B.dylib"));
+  }
----------------
ruiu wrote:
> I may be missing something, but doesn't this force lld to always link against /usr/lib/libSystem.B.dylib when it is ran in test, which will fail on non-macOS systems that don't have the dylib file?
This just adds an additional load command to the output file, but it doesn't actually cause lld to read and link against libSystem. I.e. we won't create a DylibFile / InputFile for libSystem. It's just an output-time hack.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77087/new/
https://reviews.llvm.org/D77087
    
    
More information about the llvm-commits
mailing list