Kaleidoscope tutorial help on Windows

Hi all,

I was playing around with the C++ Kaleidoscope tutorial recently and noticed that once JIT support is added (Chapter 4) it doesn’t appear to work on Windows.

When the application is built in Debug mode using Visual Studio I can’t even seem to execute simple statements such as 2+2. I see the error:

“Assertion failed: I != MR.SymbolFlags.end() && “Resolving symbol outside this responsibility set”, file C:\Dev\llvm-project\llvm\lib\ExecutionEngine\Orc\Core.cpp, line 2629”

However, when I build the application in Release mode I am able to execute simple arithmetic statements, but I can’t make any function calls. When I attempt to call a function like the tutorial documentation suggest, I get an error similar to the following:

“JIT session error: Failed to materialize symbols: { (, { __real@4024000000000000, __real@4010000000000000 }) }”

I’m by no means a JIT expert (hence why I was doing the tutorial), so I was hoping someone could take a look and help out or point me in the right direction.

I also noticed that the test config marks tests for the examples as unsupported if the platform is windows:

https://github.com/llvm/llvm-project/blob/main/llvm/test/Examples/lit.local.cfg

Is there a reason for this? Perhaps this issue of the broken Kaleidoscope example on Windows could have been caught earlier via the associated tests?

Thanks in advance for any help/information you can provide,

-Justice

Hi Justice, thanks for reporting your observations. I’m cc’ing Lang as I believe he is the best to answer this (or correct my notes).

When I attempt to call a function like the tutorial documentation suggest, I get an error similar to the following: “JIT session error: Failed to materialize symbols: { (, { __real@4024000000000000, __real@4010000000000000 }) }”

This seems to be an issue with floating point constants on Windows: the compiler groups them in a constant-pool section per object file and marks it as COMDAT, so that duplicates won’t cause errors when the linker merges them. However, ORC/JITLink don’t fully support COMDAT yet. Did you try using different constants or not having constants at all?

A similar issue came up recently in the Discord channel and the magical solution was to switch to LLJIT:
That’s right. Well, coverage for the examples has been improved in he past: But Windows support lacks behind – I guess simply because proper COMDAT support is still not there: There is no JITLink backend for a native Windows target and I guess there are reasons why this is not implemented in RuntimeDyLd (the old ORC linker). So far, no one volunteered to work on it and it doesn’t look like that happens anytime soon. Instead people (like me) work around this limitation and target ELF or MachO even on non-native platforms. This is fine as long as you have no native dependencies, but it’s still a hack and it doesn’t seem right to “teach” this in the tutorials. So, long story short: Not sure what would be the best way to improve the situation. Maybe add a note for Windows users in Kaleidoscope? Best, Stefan