LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 25493 - The flag SymbolRef::SF_Export is never set in COFFObjectFile
Summary: The flag SymbolRef::SF_Export is never set in COFFObjectFile
Status: NEW
Alias: None
Product: libraries
Classification: Unclassified
Component: OrcJIT (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-11 13:00 PST by Sergei Zykov
Modified: 2016-07-25 14:35 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments
This patch fixes the problem for me (452 bytes, patch)
2016-07-19 07:03 PDT, Paul Rouschal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Zykov 2015-11-11 13:00:44 PST
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.
Comment 1 Paul Rouschal 2016-07-19 07:03:03 PDT
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.
Comment 2 Sergei Zykov 2016-07-19 14:52:51 PDT
It doesn't work in MSVC++. What compiler do you use?
Comment 3 Paul Rouschal 2016-07-25 10:59:10 PDT
(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.
Comment 4 Paul Rouschal 2016-07-25 11:20:13 PDT
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.
Comment 5 Sergei Zykov 2016-07-25 14:35:39 PDT
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.