MCJIT + Windows = Incompatible object format

Is the MCJIT infrastructure supported on Windows? I’m getting an “LLVM ERROR: Incompatible object format!” when running my project with both VS 2013 and Mingw_w64 (GCC 4.8.2). Looks like this issue has been brought up before [1,2] and the answer is “almost”. Any help would be greatly appreciated.

v/r,
Josh

[1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-January/046670.html
[2] http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-August/052522.html

Hi Josh,

JIT/MCJIT works on Windows 32 bit (maybe 64 also) with ELF object file format:

-target i686-pc-mingw32-elf

Yaron

As Yaron said, you need to add “-elf” to the end of your target triple to get MCJIT to generate ELF object in memory on Windows. This should work with 32- or 64-bit targets.

-Andy

Bingo, thanks! Confirmed it works for both 32- and 64-bit targets.

Should sys::getProcessTriple() be updated with this change? According to the documentation:

/// getProcessTriple() - Return an appropriate target triple for generating
/// code to be loaded into the current process, e.g. when using the JIT.

I had to “-elf” to the result of this function for JIT to work on Windows.

v/r,
Josh

Hi Josh,

Glad to hear this worked for you.

I think there are problems with putting this into sys::getProcessTriple(). If that’s used for anything other than MCJIT (and I think it probably is) then appending “-elf” wouldn’t be appropriate. Also, MCJIT isn’t always generating code for the current process, so this wouldn’t cover all its bases.

Probably a better solution (at least until MCJIT supports COFF, if it ever will) is to have MCJIT check the target triple and automatically add this if the target OS is Windows-based. In general I don’t like MCJIT tinkering with client supplied settings, but since in this case the alternative is guaranteed to fail it’s probably a reasonable thing to do.

-Andy