Incremental compilation

Basile Starynkevitch basile@starynkevitch.net
Mon Jan 1 00:00:00 GMT 2018


On 12/29/18 4:31 PM, Marc Nieper-Wißkirchen wrote:
> Hi!
I am guessing that you use libgccjit on Linux.
>
> I need to compile a number of functions incrementally. Eventually, I
> would like to compile all the functions to a dynamic library file.
Notice that, if you are compiling each function incrementally, it has to 
be some exported function (GCC_JIT_FUNCTION_EXPORTED), otherwise you 
won't see it between your different compilations.
>
> Can this be achieved with libgccjit without recompiling the functions?

Probably not, and I don't understand why you need that in practice.

The common wisdom would be to compile each function separately (perhaps 
into its own shared object on Linux).

Be aware that it is perfectly acceptable to have a big lot (e.g. many 
hundred thousands) of shared objects on Linux.

My manydl.c program (which does not use libgccjit) on 
https://github.com/bstarynk/misc-basile/blob/master/manydl.c is 
generating some C code, compiling it as a plugin, and dlopen-ing it. It  
can repeat that a lot of times.

The only caveat when compiling small functions separately is that you 
have to spend one (or a few) pages (of 4Kbytes) on every compilation, 
since the result of a compilation fits in a separate page (e.g. in 
different *.so files). So if the function is tiny and takes only a 
hundred byte, you lose some virtual address space. In practice, that is 
no much a problem (at least on x86-64 under Linux).

My guess is that you are sort-of implementing some Read Eval Print Loop 
and JIT-compiling at every interaction. In practice, that works very 
well (even when emitting C code instead of using libgccjit). I was able 
to do that in my old GCC MELT project (which generated a C code, 
compiled it into a plugin, at every REPL interaction).

Happy new year to everyone.

-- 

Basile STARYNKEVITCH   == http://starynkevitch.net/Basile
opinions are mine only - les opinions sont seulement miennes
Bourg La Reine, France



More information about the Jit mailing list