Skip to content

Instantly share code, notes, and snippets.

@icholy
Created December 13, 2012 14:26
Show Gist options
  • Save icholy/4276692 to your computer and use it in GitHub Desktop.
Save icholy/4276692 to your computer and use it in GitHub Desktop.

There are still a few caveats to using cling as a repl. The first one is lack of support for recursive compilation. This is a limitation of the JIT compiler. It is a problem if you're trying to pass a lambda as a parameter.

void f (std::function<void(void)> cb) {
  cb();
}

f([](){});

This will result in cling crapping out and a core dump.

Another issue which gets in the way of usability is no support for inline assembly. Although I don't have any in my applications, it's pervasively used in boost libraries.

I found the qling project on github which seems to be working on the latter of the two problems. Here is a snippet from the README.

Recently the "MC framework" has been included in llvm and MC's JIT does support inline assembly. Unfortunately cling needs to be patched to make use of that and I have not yet been successful in making this work correctly - it segfaults atm which seems to be some JIT-memory-manager issue that I have yet to figure out.

You have to keep in mind the llvm is still a pretty young project. Judging by the amount of support it's been recieving, all these issues should be resolved soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment