[llvm] [lli] Fix crash with --no-process-syms on MinGW (PR #151386)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 10:45:50 PDT 2025
https://github.com/jeremyd2019 updated https://github.com/llvm/llvm-project/pull/151386
>From bf391aba166417b622a5880bfe0b20e54dd8f09a Mon Sep 17 00:00:00 2001
From: Jeremy Drake <github at jdrake.com>
Date: Wed, 30 Jul 2025 13:09:07 -0700
Subject: [PATCH 1/2] [lli] Fix crash with --no-process-syms on MinGW
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. This returns a reference and thus cannot
be NULL.
Fixes #143080
---
llvm/tools/lli/lli.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index c322b4f6c9828..9fd9ba39669bd 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -1085,7 +1085,7 @@ 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(
+ ExitOnErr(J->getMainJITDylib().define(
orc::absoluteSymbols({{J->mangleAndIntern("__main"),
{orc::ExecutorAddr::fromPtr(mingw_noop_main),
JITSymbolFlags::Exported}}})));
>From dcc6a916eebba376ae765f4edfb775bb2f8c21ab Mon Sep 17 00:00:00 2001
From: Jeremy Drake <github at jdrake.com>
Date: Thu, 31 Jul 2025 10:45:34 -0700
Subject: [PATCH 2/2] apply review comment
---
llvm/tools/lli/lli.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 9fd9ba39669bd..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->getMainJITDylib().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