Reputation: 2095
It appears that Kaleidoscope example in LLVM has been broken, at least in MSVC++ x64 for a quite while, maybe several months. It doesn't work in MCJIT and in their new Orc JIT framework for a same reason.
// Get the address of the JIT'd function in memory.
auto ExprSymbol = J.findUnmangledSymbol("__anon_expr");
This expression returns null and cause null pointer error as a result. I can't guess how to make workaround at this moment because call tree is too deep there and may require ~few days of debugging. But in theory, this code is educational and shouldn't cause trouble for newcomers. So maybe i'm doing something wrong.
Upvotes: 1
Views: 480
Reputation: 53
For me the easiest way to workaround this was to patch the findMangledSymbol
function, calling CompileLayer.findSymbolIn
with bExportedSymbolsOnly
set to false
. It doesn't fix the problem but avoids the symptom.
Upvotes: 1
Reputation: 2095
Lang Hames from the llvm mailing list was able to answer this question. It appears that method COFFObjectFile::getSymbolFlags doesn't enable SF_Export flag at all, thus making all created symbols invisible for the Kaleidoscope's findSymbol method in the Windows platform. It is possible to get access to non-exported symbols though, so some kind of workaround is possible.
Upvotes: 0