[llvm] 65990d6 - [lli] Fix crash with --no-process-syms on MinGW (#151386)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 1 18:16:10 PDT 2025


Author: jeremyd2019
Date: 2025-08-01T18:16:07-07:00
New Revision: 65990d61486c44186daec8e3c0831a32780b3e1d

URL: https://github.com/llvm/llvm-project/commit/65990d61486c44186daec8e3c0831a32780b3e1d
DIFF: https://github.com/llvm/llvm-project/commit/65990d61486c44186daec8e3c0831a32780b3e1d.diff

LOG: [lli] Fix crash with --no-process-syms on MinGW (#151386)

In this case, `J->getProcessSymbolsJITDylib()` returns a NULL pointer.
In order to make sure `__main` is still defined, add the symbol to
`J->getMainJITDylib()` instead in that case. This returns a reference
and thus cannot be NULL.

Fixes #143080

Added: 
    

Modified: 
    llvm/tools/lli/lli.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index c322b4f6c9828..875ec1b7fe64a 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -1084,11 +1084,15 @@ int runOrcJIT(const char *ProgName) {
 
   // If this is a Mingw or Cygwin executor then we need to alias __main to
   // orc_rt_int_void_return_0.
-  if (J->getTargetTriple().isOSCygMing())
-    ExitOnErr(J->getProcessSymbolsJITDylib()->define(
+  if (J->getTargetTriple().isOSCygMing()) {
+    auto &WorkaroundJD = J->getProcessSymbolsJITDylib()
+                             ? *J->getProcessSymbolsJITDylib()
+                             : J->getMainJITDylib();
+    ExitOnErr(WorkaroundJD.define(
         orc::absoluteSymbols({{J->mangleAndIntern("__main"),
                                {orc::ExecutorAddr::fromPtr(mingw_noop_main),
                                 JITSymbolFlags::Exported}}})));
+  }
 
   // Regular modules are greedy: They materialize as a whole and trigger
   // materialization for all required symbols recursively. Lazy modules go


        


More information about the llvm-commits mailing list