Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Problem with setEngineKind(EngineKind::JIT) - JIT has not been linked in. r232318 #22909

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR22910
Status NEW
Importance P normal
Reported by Kaveh Rassoulzadegan (kv@ok-roms.com)
Reported on 2015-03-15 08:22:43 -0700
Last modified on 2015-08-17 07:43:58 -0700
Version trunk
Hardware PC Windows NT
CC alex.moiseenko@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Hello,

Using windows 8.1, VS2013 and the r232318, I get ("Fibonacci.exe: Failed to
construct ExecutionEngine: JIT has not been linked in.") if I leave the JIT
creation as-is :

ExecutionEngine *EE =
    EngineBuilder(std::move(Owner))
    .setErrorStr(&errStr)
    .setEngineKind(EngineKind::JIT)
    .create();

Fibonacci sample runs fine when removing ".setEngineKind(EngineKind::JIT)".

Is it normal ?

Thanks,
Kaveh
Quuxplusone commented 9 years ago

Same problem for me: Windows 8.1 x64, Visual Studio 2015.

Quuxplusone commented 9 years ago

Forgot to mention that I am using LLVM 3.7.0 RC.

Quuxplusone commented 9 years ago
Ok, I have added linking by including "llvm/ExecutionEngine/MCJIT.h" and adding
static link to LLVMMCJIT.lib.

After this was done, there is a crash on line "GenericValue GV = EE-
>runFunction(FibF, Args);", in particular, "Target does not support MC
emission!". The target string in this case is "x86_64-pc-windows-msvc".

So I added the following:
    llvm::InitializeNativeTargetAsmPrinter();
    llvm::InitializeNativeTargetAsmParser();

which requires to add a static link to LLVMX86AsmParser.lib.

Now the failure is in MCJIT.cpp line 524 (Exception thrown at
0x000000AD644B0000 in Fibonacci.exe: 0xC0000005: Access violation executing
location 0x000000AD644B0000).

So, basically something is not working on Windows 8 x64, maybe some other
systems.

Kaveh, please confirm if you have the same behavior.
Quuxplusone commented 9 years ago
Hi Alexey,

What you tried happens with vs 2013 here too but with a slight difference.
Although my setup was upgraded from Win 8.1 to Win 10, 2 weeks ago so Win 10
Pro is likely to be impacted too.
BTW, since the upgrade from a 8.x flavor does not appear to mess any aplication
I previously installed (I don't know if upgrading from 7 is also seamless), VS
2013 appear to be working as well as if I was still under 8.1.
The rest of the LLVM setup / revision is the same as when I first posted
(r232318, I did not sync to anything newer since then), so I could try directly
and after applying all the steps you tried, fibonacci.exe prints :

Unsupported target for RuntimeDyldCoff.
UNREACHABLE executed at
C:\LLVM\llvm\lib\ExecutionEngine\RuntimeDyld\RuntimeDyldCOFF.cpp:46!

I recently installed vs 2015, so I tried also with it and after rebuilding /
retargeting all, I still get the same results.

One last note : after focusing on the "Target does not support MC emission!"
error and before pursuing with the next steps you tried, the access violation
breaks at "EnterCriticalSection(&CriticalSection);" (line 437 of Signals.inc).
After doing all you tried, a breakpoint is triggered at line 117 of
errorHandling.cpp (abort();).

Best,
K
Quuxplusone commented 9 years ago
Thank you for the fest response, Kaveh!
I just found the resolution for the problems I described above: one need to
call exec_engine_->finalizeObject() before getting function
address(exec_engine_->getFunctionAddress). It does some remapping for
addresses, and is needed only when JITing, not interpreting. I also had to
apply "-elf" to target for everything to work fine: target_options->Triple =
sys::getDefaultTargetTriple() + "-elf"
Hope it helps you too! Let us know.