The flag SymbolRef::SF_Export flag is never set in the COFFObjectFile::getSymbolFlags method. Because Kaleidoscope-Orc expects that its compiled expressions will be exported, in Windows environment it gets null pointer instead of valid symbol reference and crush.
Created attachment 16765 [details] This patch fixes the problem for me Because I am not yet familiar enough with LLVM and not at all familiar with PE/COFF, I am not sure if there are any potential downsides to setting this flag or if there are cases where setting it based on "isExternal()" is not actually valid, so this would have to be checked. The JIT tutorial seems to work well, however.
It doesn't work in MSVC++. What compiler do you use?
(In reply to comment #2) > It doesn't work in MSVC++. What compiler do you use? I use Visual Studio 2013 Community. I compiled the Debug version of SVN revision 274558. According to my notes I did not set any cmake options except for the python executable, since it would not find the right one by itself. What error do you receive? Does it compile? I just tried the BuildingAJIT Chapter 1 Tutorial and the Kaleidoscope-Ch4.exe. Previously these would crash as you described whenever a top-level expression was entered, as the newly created function computing it would not be found. I now get the correct answer.
Looking at the history of the file, Lang Hames already tried a similar patch in January, but then reverted it the next day. He also started a discussion on the Mailing list with regards to setting this flag, and it seems the proposed solution was not to rely on it in the JIT, rather than changing the flag, which would not have matched what the COFF linker does. Sorry for not consulting the "history" before.
AFAIR llvm extensively uses C++14 features and therefore it compiles with VC++ 2015 only. I am using VC++ 2015 community + git version of the llvm + Lang's patch.