[PATCH] D149996: [test] [ExecutionEngine] Skip the ExecutionEngine tests on mingw targets

Lang Hames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 7 19:02:35 PDT 2023


lhames added a comment.

@mstorsjo I think I see the underlying issue here: https://github.com/llvm/llvm-project/blob/79702f7f593dece7afb67fec03df884d50525b96/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp#L268

Could you please try this fix instead:

  diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
  index bc1c9cecbb77..fade24c57898 100644
  --- a/llvm/tools/lli/lli.cpp
  +++ b/llvm/tools/lli/lli.cpp
  @@ -824,6 +824,16 @@ loadModule(StringRef Path, orc::ThreadSafeContext TSCtx) {
     return orc::ThreadSafeModule(std::move(M), std::move(TSCtx));
   }
   
  +int mingw_noop_main(void) {
  +  // Cygwin and Mingw insert calls to __main from the generated main. The
  +  // __main function is usually defined in a standard library and responsible
  +  // for setting up main's environment (e.g. running static ctors), but in our
  +  // case the host executor will have taken care of non-JIT ctors, and ORC will
  +  // take care of JIT'd ones. To avoid a missing symbol error we can just
  +  // point __main at this noop function.
  +  return 0;
  +}
  +
   int runOrcJIT(const char *ProgName) {
     // Start setting up the JIT environment.
   
  @@ -989,6 +999,16 @@ int runOrcJIT(const char *ProgName) {
                                                         Mangle));
     }
   
  +  // 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(
  +        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
     // through partitioning and they replace outgoing calls with reexport stubs

If that works then I'll commit it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149996/new/

https://reviews.llvm.org/D149996



More information about the llvm-commits mailing list