I have been able to compile cling using VS2013 with only a small number of modifications.
It seems to work quite well. But I have not tested more then simple C functions.
apparently somewhere windows defines a macro called IN. That is why one needs to to apply this little change to /lib/Interpreter/IncrementalParser.cpp :
532,533c532,533
< for (NamespaceDecl::decl_iterator _IN = ND->decls_begin(),
< EN = ND->decls_end(); _IN != EN; ++_IN) {
for (NamespaceDecl::decl_iterator IN = ND->decls_begin(),
EN = ND->decls_end(); IN != EN; ++IN) {
536,537c536,537
< if (!shouldIgnore(_IN))
< getCodeGenerator()->HandleTopLevelDecl(DeclGroupRef(_IN));
if (!shouldIgnore(*IN))
in include/Interpreter/RuntimeUniverse.h you need to remove the #ifdef _WIN32 block
and most things will start to work.
You had asked me privately about the mingw compilation we got working. I replied but I think it was private. Lets make it public now so others can see it, I will repost it all here.
I have also attached a patch file and build instructions.
run cling.exe directly from the directory where it is located. It includes several proof-of-concept workarounds that are sensitive to the working directory.
You need to run this batch file first as well: QueryCppIncludes.bat
I remember that we may have had to replace this .bat’s contents with the below on certain systems if it didn’t work (am just reading from my old emails):
@echo off
set CLING_BIN=%~dp0
echo %CLING_BIN%…/lib/gcc/mingw32/4.7.2/include/c++
echo %CLING_BIN%…/lib/gcc/mingw32/4.7.2/include/c++/mingw32
echo %CLING_BIN%…/lib/gcc/mingw32/4.7.2/include/c++/backward
echo %CLING_BIN%…/lib/gcc/mingw32/4.7.2/include
echo %CLING_BIN%…/lib/gcc/mingw32/4.7.2/…/…/…/…/include
echo %CLING_BIN%…/lib/gcc/mingw32/4.7.2/include-fixed
gbrill Archive.zip (384 KB)
Just for reference, the current master builds just fine with MSVC2013, no additional patches needed. We are working on fixing C++ support for cling on MSVC, too.
I would like to get these merged into the main project if possible and
I have another patch I would like to merge also that helps with searching gcc for paths.
Thanks, apart for a minor modification (LLVM_ON_WIN32 instead of _WIN32 in cling) they are good to go; I have committed them. Thank you for your patches!
This fixes windows x64 bit building.
void* is not the same length as an unsigned long on this platform.
size_t seems like the best solution to this
gist.github.com/martell/1a2e3539f503257a0fcc
By invoking bash it helps cygwin and msys2 on windows find the include dirs.
Other platforms shouldn’t be affected by this change but a test would be nice
Current head seems more broken than it was in the past.
cling
****************** CLING ******************
Type C++ code and press enter to run it *
Type .q to exit *
#include <stdio.h>
printf(“hello”);
Caught an interpreter exception!
Incompatible object format!
I believe this is because MCJIT is only available via elf mode on windows atm.
This patch may help. freedesktop.org/patch/25959/
Could this be worked into cling ?
That’s great. I’m super excited about the support of inline asm
I think we talked about this before.
Basically on mingw-w64 when you try to even do something as simple as printf it fails to find the location of the function and all other functions it needs to hook up to within cling.exe itself
gbrill came up with the idea of creating a table using nm and patching the lookup function to hack it.
I am not sure if this is a cling issue or a clang issue to be honest.
Compiler Error C2797: List initialization inside member initializer list or non-static data member initializer is not implemented.[/code]
I worked around it by removing “= ATOMIC_FLAG_INIT” and adding m_AtExitFuncsSpinLock.clear() in the constructor.
The build was successful, however, when I try to use Cling i am greeted by yet another error:
[cling]$ int x = 0;
>>> Caught an interpreter exception!
>>> Incompatible object format!
So, how are you guys able to run cling windows?
Are there any patches that one must apply?
I have also experienced exactly this problem, including all details (building cling with VS2013, having to work around “m_AtExitFuncsSpinLock = ATOMIC_FLAG_INIT”, getting “Caught an interpreter exception! Incompatible object format!”).
I am happy to hear that you are working on it. If you know any work-around in the mean time, I would be very appreciative.
Great to hear that! however, I am still getting the “Caught an interpreter exception! Incompatible object format!” error on Windows (MSVC2013). The same error also applies when building Cling in Cygwin.