cling goes public!
Hi,
We, the cling team, have announced cling, our C++ interpreter prototype! (note: its SVN repository has changed compared with the announcement email; see the build instructions)
To a large extend thanks to Vassil's impressive commitment, cling now behaves like a good C++ interpreter: it runs C++ code that's entered, and prints the results.
[cling]$ #include <cmath> [cling]$ double x = std::sin(3.1) (double) 4.158066e-02 [cling]$ .L libz [cling]$ #include "zlib.h" [cling]$ zlibVersion() (const char * const) "1.2.3.4"
$ echo 'extern "C" const char* zlibVersion(); zlibVersion()' | cling -lz (const char * const) "1.2.3.4"
We have of course already added a few features that we liked from CINT - but cling is a completely new development, based on clang and llvm, a set of compiler libraries (to simplify the matter a bit :-) Vassil will present the innards of cling probably in October; I will post the slides here.
So what's special about cling? It's based on a production-grade compiler and it's designed taking decades of experience with CINT into account. And it doesn't need dictionaries! (Disclaimer: that does not mean that ROOT can do without, automatically. But that's our goal, of course.)
The next steps will be the ones most relevant for High Energy Physics: integration into ROOT (Paul is already working on that) and reloading of changed code (.x myCode.C, edit, .x myCode.C). That latter part is horrible for a compiler.
If you want to check cling out you can simply compile it yourself - it's really easy. I'd love to have an interactive, web-based interface once, but an online C++ interpreter is an invitation for script kiddies to hack the server :-( If you have an idea how to do it please let me know!
Cheers,

Safety idea
The webpage of geordi-prime: http://www.eelis.net/geordi/
Cling is really great !!! I
I was able to integrate it in my System on Windows and not I can use C++11 interactively.
Unfortunately there are still some problems with it.
If I try to do following:
#include "my_header.h"
and header includes some other headers that Cling can not find then it will
CRASH in ASTNodeEraser.cpp .
Re: cling on Windows
Hi Devid,
Thanks for trying it out! As we said quite a few times already: cling is not supported on Windows yet. I'm surprised it even starts up. Sorry. This is only going to change next year. We do welcome patches even before, though!
Cheers, Axel
Problem interpreting a function
[cling]$ void ff() { [cling]$ ? int mm; [cling]$ ? mm = 5; [cling]$ ? } input_line_4:2:11: error: expected ';' at end of declaration void ff() { ^ ; [cling]$This is expected behaviour or am I doing something wrong ?Use .rawInput
The preparseing doesn't work yet and defining a function should happen with the meta command:
[cling]$.rawInput [cling]! void ff() { [cling]! ? int mm; [cling]! ? mm = 5; [cling]! ? } [cling]$.rawInputVassilbuild time of cling
Re: Build time
Hi Armin,
No way does it take 12h, something must be terribly wrong with your setup. It should take < 30 minutes even on a laptop. Nevertheless you can pick up a binary version of cling here: https://ecsft.cern.ch/dist/cling Don't be scared by the invalid SSL certificate: it's the best CERN can give to us...
Cheers, Axel
clang/cling for Windows 32/64 - is there any progress ?
Re: Win progress
Hi Vladimir,
Not that I am aware of. We will only get to that next year - unless someone else contributes patches before.
Cheers, Axel.
minor windoze build issue
Re: minor windoze build issue
Hi,
Okay, so you are building with GCC on Windows - which one, MingW or cygwin? None of that has ever been tried to my knowledge, and it's unfortunate that the linker doesn't cope with the exports table.
The local_cxa_atexit symbol might not even be needed when building with GCC. Could you open a bug report at https://savannah.cern.ch/bugs/?func=additem&group=savroot? I cannot promise that this will get fixed soon, foryhour configuration, but I would nonetheless like to have a reminder that this issue exists.
For now you are much better off building cling on Linux or MacOS. Take a virtual machine and off you go!
Cheers, Axel
I'm sorry but i'm total noob
Re: mingw build
Hi,
Sorry - if you cannot get it to work on Windows yourself you're out of luck for now... We will attack cling on Windows only next year.
Cheers, Axel.
Hi Axl, I build latest cling
Re: libz on Windows
Hi,
"zlib" and "libz" are not the same words :-) Try to rename it to libz.dll, or try .L zlib. And please remember that Windows support is still limited for cling due to clang not fully supporting the Windows C++ API yet.
I'm happy to hear that you like cling, even though you take the rocky Windows road!
Cheers, Axel
This time I tried diagnose it
Re: Windows dlopen
Hi,
Sorry, we'll be able to help with the Windows build only next year.
Cheers, Axel.
Syntax Error
Re: Syntax Error
Hi,
Can you submit a bug report at https://savannah.cern.ch/bugs/?func=additem&group=savroot, giving the full build log and the output of "svn diff /home/ryan/Documents/llvm"? My suspicion in that you moved / renamed directories after configuring...
Cheers, Axel
clang++
Actually clang++ works just
Re: clang++
Hi,
Please discuss clang issues at the clang mailing list cfe-dev@cs.uiuc.edu.
Cheers, Axel.
"LastKnownGoodSVNRevision" of cling for ROOT?
i.e. some way of telling which revision of Cling does the currently checked-out ROOT revision compile (and link) with?
cheers,
Constantin
Re: cling and ROOT
Hi Constantin!
Thanks for your question. cling is now distributed as part of ROOT, so there cannot be any revision mismatch.
I have updated the build instructions - maybe it's now clearer that one should not build cling next to clang if using ROOT. And I assume that's what's happening in your case, because you seem to have an old libCling used by a new rootcling.
Also, please submit bug reports like this to Savannah, that help's us triaging them properly. Thanks!
Cheers, Axel
osx link issue
Re: link issue
Hi,
Thanks for your report - should be fixed! But please future report bugs at our bug tracker.
Cheers, Axel.
Thanks for the fix. I'll use
Re: bug tracker
Hi,
Thanks for your reports; these things just happen because we still haven't integrated cling into our continuous integration system. I assume it was you who submitted this as a bug on savannah, that's really helpful, thanks a lot!
Cheers, Axel
osx link issue
Re: link issue
Hi,
Thanks for your report - should be fixed! But please future report bugs at our bug tracker.
Cheers, Axel.
cling.exe hangs up ...
Re: cling on Windows
Hi Vladimir,
Thanks for your report! C++ on Windows is still only rudimentary supported by clang. And cling depends on clang. The available features have already much improved over the last few months - but e.g. the ValuePrinter template instantiation (needed to print the value of the expression when omitting the ';') still causes an infinite loop on Windows. That's Vassil's diagnosis.
As templates are pretty fundamental for C++, and as work on the Windows C++ ABI has been picked up recently, there is hope that this will get fixed in the near future. We at CERN also need cling to work on Windows...
On Windows, today, cling should work in C-mode (
cling -x c).Cheers, Axel
Hi Axel, I'm a bit confused.
Re: cling on Windows
Hi Vladimir,
As I said, I expect cling on Windows to only work in C mode for the time being. The other bug will affect cling on Windows, too, whether C mode or not - it's about input buffer handling which is the same everywhere. I hope that clarifies the situation. As it is right now I would not recommend cling for production use on Windows. But I cannot predict how long it will take clang to support (most of) Windows C++ ABI: could be months, could be days.
Cheers, Axel
"using namespace std" and c++11 lambdas don't work?
$ ./cling **** Welcome to the cling prototype! **** * Type C code and press enter to run it * * Type .q, exit or ctrl+D to quit * ***************************************** [cling]$ #include iostream // NB: the html wouldnt let me send angle brackets around iostream, but they were there! [cling]$ using namespace std; Declaration name has no FETokenInfo UNREACHABLE executed at DeclarationName.cpp:339! Illegal instruction $ cd ~/pkg/llvm-post-3.0-svn/llvm/tools/cling/lib/Interpreter # patch previously mentioned... to get compilation. $ svn diff Index: DynamicLookup.cpp =================================================================== --- DynamicLookup.cpp (revision 43039) +++ DynamicLookup.cpp (working copy) @@ -416,7 +416,7 @@ // resolution of the constructors and then initializes the new // variable with it ExprResult InitExprResult - = m_Sema->ActOnParenListExpr(m_NoSLoc, + = m_Sema->ActOnParenOrParenListExpr(m_NoSLoc, m_NoELoc, move_arg(Inits)); m_Sema->AddInitializerToDecl(HandlerInstance,...also the C++11 lambda feature doesn't seem to work; any clue why? (see below for example)
Thanks!
Jason
Re: using namespace std
Hi Jason,
I have converted your comment into this bug report. Thanks! Note that it does work if you toggle to
.rawInputfor the using directiveusing namespace std;- but that's just a woraround.The mismatch in DynamicLookup.cpp should get fixed later.
Cheers, Axel
Re: Lambda expressions
Hi Jason,
Thanks for your feedback; the compilation problem will get fixed today!
Regarding the lambda, you first need to enable the C++11 standard (you just enabled a warning kind):
Cheers, Axel
small adjustment needed to compile DynamicLookup.cpp
Regards,
Jason
svn diff ===================== --- DynamicLookup.cpp (revision 43039) +++ DynamicLookup.cpp (working copy) @@ -416,7 +416,7 @@ // resolution of the constructors and then initializes the new // variable with it ExprResult InitExprResult - = m_Sema->ActOnParenListExpr(m_NoSLoc, + = m_Sema->ActOnParenOrParenListExpr(m_NoSLoc, m_NoELoc, move_arg(Inits)); m_Sema->AddInitializerToDecl(HandlerInstance, svn info Path: . URL: http://root.cern.ch/svn/root/trunk/cint/cling/lib/Interpreter Repository Root: http://root.cern.ch/svn/root Repository UUID: 27541ba8-7e3a-0410-8455-c3a389f83636 Revision: 43039 Node Kind: directory Schedule: normal Last Changed Author: vvassilev Last Changed Rev: 42986 Last Changed Date: 2012-02-13 13:20:45 -0600 (Mon, 13 Feb 2012)Re: trunk
Hi Jason,
Thanks to Vassil this is now fixed, including a proper llvm / clang revision number that works. Again, thanks for your report!
Cheers, Axel
Multi-line mode
Re: multi-line mode
Hi Vladimir,
Thanks for your suggestion! Another option would be start editor-like behavior, where one moves up and down with the cursor keys, until one sends off the input using shift- or ctrl-enter. What do you think?
Note: this is just brainstorming - I'm not claiming that we have the time to implement it in 2012 :-) But if somebody is looking for something to contribute then this could be a nice extension!
Cheers, Axel
I think cling standalone is
re: cling binary
Hi Vladimir,
There are several possible modes of using the cling binary; for your context it's probably for evaluation. Yes, we need ".help". You do know that cling can run (.x) text files, too, right? For complex input that's usually what people do.
Just to remind you: we are building on almost two decades of experience with CINT, and it being used in production by tens of thousands of people. So when I say "people usually edit files" then that's the result of this experience :-) But that doesn't stop us from making fundamental changes, so who knows: if someone designs (with us) and contributed a nice multiline mode I wouldn't mind uploading it!
Cheers, Axel
cling compilation error
Cling Compilation
Keeping cling in sync with two repos is not an easy job :) I believe it is fixed now!
Cheers, Vassilcling compile 2 days later ;)
Re: targets=host!
Hi Matt,
You must configure with --enable-targets=host, else you will pull in all possible targets. As you are the second one reporting this we should probably work around that on the cling side...
Cheers, Axel.
Thank you !
Re: last good revsision
Hi Vladimir,
I prefer not to include llvm + clang in cling's repository. Instead cling now contains a file "LastKnownGoodLLVMSVNRevision.txt" which holds the highest revision number that is known to work. It gets updated by the Makefile, so there is a reasonable chance that this number stays relevant. Thanks for your suggestion!
Cheers, Axel
Is cling stable enough to be used in production application ?