timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

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

Open timotheecour opened 3 years ago

timotheecour commented 3 years ago

example use cases

links

mir c2m JIT c compiler

cling

juancarlospaco commented 3 years ago

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

timotheecour commented 3 years ago

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 commented 3 years ago

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

Has projects using it to make REPL too.