Skip to content

Commit 65990d6

Browse files
authored
[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
1 parent 49a24b3 commit 65990d6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/tools/lli/lli.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,11 +1084,15 @@ int runOrcJIT(const char *ProgName) {
10841084

10851085
// If this is a Mingw or Cygwin executor then we need to alias __main to
10861086
// orc_rt_int_void_return_0.
1087-
if (J->getTargetTriple().isOSCygMing())
1088-
ExitOnErr(J->getProcessSymbolsJITDylib()->define(
1087+
if (J->getTargetTriple().isOSCygMing()) {
1088+
auto &WorkaroundJD = J->getProcessSymbolsJITDylib()
1089+
? *J->getProcessSymbolsJITDylib()
1090+
: J->getMainJITDylib();
1091+
ExitOnErr(WorkaroundJD.define(
10891092
orc::absoluteSymbols({{J->mangleAndIntern("__main"),
10901093
{orc::ExecutorAddr::fromPtr(mingw_noop_main),
10911094
JITSymbolFlags::Exported}}})));
1095+
}
10921096

10931097
// Regular modules are greedy: They materialize as a whole and trigger
10941098
// materialization for all required symbols recursively. Lazy modules go

0 commit comments

Comments
 (0)