[PATCH] D107084: [Kaleidoscope] Fix Kaleidoscope JIT symbol resolution error on Windows

Justice Adams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 29 09:13:59 PDT 2021


justice_adams created this revision.
justice_adams added reviewers: lhames, bkramer.
justice_adams added a project: LLVM.
justice_adams requested review of this revision.

Currently, when a user builds and runs the Kaleidoscope tutorial on Windows they will run into the following error when attempting to execute basic statements through the JIT

  Assertion failed: (KV.second.getFlags() & ~WeakFlags) == (I->second & ~WeakFlags) && "Resolving symbol with incorrect flags", file llvm\lib\ExecutionEngine\Orc\Core.cpp, line 2674

This patch fixes the issue by claiming responsibility for COFF symbols when the user is running on Windows. This is exactly how LLJIT does it, so I mimicked it here.
https://reviews.llvm.org/source/llvm-github/browse/main/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp$669


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107084

Files:
  llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h


Index: llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h
===================================================================
--- llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h
+++ llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h
@@ -57,6 +57,11 @@
     MainJD.addGenerator(
         cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
             DL.getGlobalPrefix())));
+
+    if (JTMB.getTargetTriple().isOSBinFormatCOFF()) {
+      ObjectLayer.setOverrideObjectFlagsWithResponsibilityFlags(true);
+      ObjectLayer.setAutoClaimResponsibilityForObjectSymbols(true);
+    }
   }
 
   ~KaleidoscopeJIT() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107084.362800.patch
Type: text/x-patch
Size: 632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210729/6a23b461/attachment.bin>


More information about the llvm-commits mailing list