Compile Cling on Visual Studio

I am trying to compile Cling on Visual Studio 2013.
There are a few compile errors here and there namely:

  • Use of inline namespaces
  • a few constexpr
  • cling::utils::platform::windows namespaces that needs to be fully specified when calling some functions
  • RegisterEHFrames and DeRegisterEHFrames use exception handling stuff not available in VS2013 on 32 bit build (looks like it’s 64 bit only stuff from MSDN).
  • Some of the /EXPORT: are leading to linking errors.

I have managed to compile somehow fixing these things and commenting the content of RegisterEHFrames and DeRegisterEHFrames but cling panics on a simple:


****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ int i = 0; i
Assertion failed: !DD && Handlers.empty() && "Debug/EH info didn't get finalized
", file Z:\Desktop\cling\cling-build-windows\cling-src\lib\CodeGen\AsmPrinter\As
mPrinter.cpp, line 117
Wrote crash dump file "C:\Users\Stefano\AppData\Local\Temp\cling.exe-98abc4.dmp"

0x00D9C7F9 (0x00000016 0xD68F0FA8 0x0724CF00 0x0724CE14), HandleAbort() + 0x9 by
tes(s), z:\desktop\cling\cling-build-windows\cling-src\lib\support\windows\signa
ls.inc, line 404
0x5937F7F9 (0x00000016 0x00D9C7F0 0x0724CE00 0x59379AC4), raise() + 0x2B9 bytes(
s)
0x5938B284 (0x0724CF00 0x0724CE14 0x000000B7 0x088587F0), abort() + 0x34 bytes(s
)
0x59379AC4 (0x0563B168 0x0563B0A8 0x00000075 0x0724CE50), _wassert() + 0xD4 byte
s(s)

So my questions are:

  • Does Cling compile with Visual Studio ?
  • If yes, does Cling work with VS 2013 or does it need VS2015+ ?

Thanks

Hi,

[quote=“pagghiu, post:1, topic:24214”]

  • Does Cling compile with Visual Studio ?
    [/quote]Yes

You need at least Visual Studio 2015

Cheers, Bertrand.

Thanks a lot for the answer!

I have a few questions then:

  • The language / compiler issues look trivial to fix between VS2013 and VS2015 (few constexpr and inline namespace).
    I assume that the main differences are in the injected exception handling code and symbol exports (/EXPORT: mangled names in the linker command line).
    Where should I look then if for some reasons I would need to get this to compile under VS2013?

  • Has this been tested with the latest VS2017?

Thanks!

Hi,

I remember there were more issues than that. For example, VS 2013 doesn’t fully support the C++11/14(/17) standard. And sorry, I don’t remember all the other issues I had… (since the master compiles just fine with VS 2015 anyway)
And nope, it has not been tested with VS 2017 (not yet)

Cheers, Bertrand.

Ok, I will give VS2015 and VS2017 a shot and investigate the differences in the case I will not be able to update our compilers from VS2013 to more recent.

Thanks again for your answers.

You’re very welcome! But note also that Cling on Windows is not really stable, and it might not work as expected…
Cheers, Bertrand.

I’ve used cmake -G “Visual Studio 14” and “Visual Studio 15” in an attempt to get cling to compile using visual studio 2015 with update 3, and also with visual studio 2017, and am having no luck.

Is there a specific branch i should be using to get it to compile on windows10 with vs2015/17?

Hi,

Following the build instructions should be enough

Cheers, Bertrand.

Ahh yess. They are definitely easy instructions. It’s just that they don’t work :stuck_out_tongue:

Which is why i tried to modify the cmake command by explicitly stating which version of visual studio to use…

In all attempts (including following the directions explicitly, or using the cpt.py file from https://github.com/vgvassilev/cling) I get a 'identifier “PRUNTIME_FUNCTION” is undefined" from obj.clingUtils project in file PlatformWin.cpp line 752. my winnt.h should have PRUNTIME_FUNCTION defined, along with RUNTIME_FUNCTION, but the error persists. Is there a particular update of VS2015 I should be using instead of Update 3? The same error exists using vs2017 as well.

cling-src\tools\cling\lib\Interpreter\DeclUnloader.cpp(876): error C2660: ‘clang::CodeGenerator::forgetDecl’ : function does not take 2 arguments

Thanks

Edit: The windows directions should be updated to include the -G “Visual Studio 14 2015 Win64” argument to cmake. Doing so I was able to complete the cmake --build . step.

Thanks for your time.

Hi,

Yes, it’s what I was about to reply (sorry for the delay). Cling only builds in 64 bit mode for the time being. (It should be only temporary…)

Cheers, Bertrand.