Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use cling or libclang for JIT C/C++ compilation in VM, and for tinycc backend replacement #705

Open
timotheecour opened this issue Apr 25, 2021 · 3 comments

Comments

@timotheecour
Copy link
Owner

timotheecour commented Apr 25, 2021

example use cases

  • for JIT compilation of importc procs (CT FFI)
  • for evaluating const foo {.importc:”C_ISSOCK”.} as a const
  • for replacement of tinycc backend (works on more platforms including osx, and supports C++)

links

mir c2m JIT c compiler

This code is in initial stages of development

cling

cling uses transactions (and c++), TinyCC is build to be fast and minimal.

@timotheecour timotheecour changed the title use cling or libclang for JIT C/C++ compilation in VM, and for tcc backend replacement use cling or libclang for JIT C/C++ compilation in VM, and for tinycc backend replacement Apr 25, 2021
@juancarlospaco
Copy link
Collaborator

juancarlospaco commented Apr 25, 2021

Cling has LibClang and LLVM as dependency, that adds 3 big dependencies to the Nim compiler.
🤔

@timotheecour
Copy link
Owner Author

timotheecour commented Apr 25, 2021

Whats a quick feature compare of Cling vs LibClang ?

one is based on the other; I'm still exploring but at least cling adds a REPL, and use as a binary instead of having to link in libclang as library dependency, but I'm definitely not discarding using libclang directly, this needs more though.

Does this really meant to be a new Backend?, or a replacement/evolution of the VM ?.

some of the use cases don't involve a new backend: (eg making things like this possible: const foo {.importc:”C_ISSOCK”.}, or making CT ffi easier); others involve speeding up VM by doing jitting of vm code for hotspots, and yet other use cases involve replacing the existing (or deprecated) tcc backend with have with cling (which supports C++, and more platforms, than tcc; we'll need performance comparisons)

Does Cling work with C ?, docs only mention C++.

see other docs: Cling
Cling is able to parse everything that clang can [...]
Clang has support of C, objC, objC++ and we are looking forward to having more use-cases and extend our tool in that direction.

Does that allow easy dynamic linking compilation?

still exploring but this could be an advantage over using libclang directly, ie by invoking cling as a binary instead of linking as a library. TBD.

Cling has LibClang and LLVM as dependency, that adds 3 big dependencies to the Nim compiler.

that's fine if the dependency is optional. on osx (and other platforms probably the same) it's as simple as brew install cling. If user can get CT speedup or CT FFI using this, it's good enough of a use case.

@juancarlospaco
Copy link
Collaborator

Another option to research:
https://www.keystone-engine.org/docs/beyond_llvm.html

Has projects using it to make REPL too.

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

No branches or pull requests

2 participants