Hi all, I was playing around with the C++ Kaleidoscope tutorial<https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index.html> 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: { (<main>, { __real at 4024000000000000, __real at 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210107/525e3ab6/attachment.html>
Stefan Gränitz via llvm-dev
2021-Jan-07 16:14 UTC
[llvm-dev] Kaleidoscope tutorial help on Windows
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: { (<main>, { __real at 4024000000000000, > __real at 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: https://discord.com/channels/636084430946959380/687692371038830597/781079145030877205> 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 > <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?That's right. Well, coverage for the examples has been improved in he past: https://github.com/llvm/llvm-project/commit/ecfac6cd2ce0421 But Windows support lacks behind -- I guess simply because proper COMDAT support is still not there: https://github.com/llvm/llvm-project/commit/f4b86cb28e6793 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 On 07/01/2021 02:15, via llvm-dev wrote:> > Hi all, > > > > I was playing around with the C++ Kaleidoscope tutorial > <https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index.html> > 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: { (<main>, { > __real at 4024000000000000, __real at 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 > <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 > > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- https://flowcrypt.com/pub/stefan.graenitz at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210107/729169d6/attachment.html>