dynamic linkage for jit


I want to execute functions in a module, this module will have dependencies resolved in other modules. the modules might change (dynamic compilation environment) so i would prefer not not link all the dependencies in a single monolithic module, that is, if it can be avoided

I hope to use Linker::linkModules but this is always destructive. That is ok for one module depending on a single one, since if that one changed, is no big deal, but isn’t it overkill to rebuild and relink N-1 modules that did not change just because of a single one that changed?

I wonder if there is a non-destructive version of linkModules that can work for JIT execution.

Sorry if it comes out a bit pushy bumping my own question, but it’s been really difficult to find any info regarding this functionality
in the mailing list archives. Just some emails i’ve found from people working on NaCl:


is there a branch where this is being work on, or is internal chromium project so far? Also i’m not sure if this is exactly the same as what i’m looking for,
but it sounds similar enough

Hi Charllls, I didn't really get it. Are you saying that you would execute some
functions using the JIT then, later, those functions will be modified and thus
need to be re-jitted?

Ciao, Duncan.

Hi Duncan,

that is exactly it. My hope is to keep the need for rebuild isolated to the individual modules where the modifications occur, and relink appropiately.

I’ve discussed this with people that have worked on llvm frontends before, and they suggest that this would require keeping copies of all the modules around,
rebuild the modules that changed, and then relink everything into a single static fat module that the JIT can use, which is btw my default plan to implement, unless/until i learn a better alternative

the main drawback of that would be, i think, to have to relink all dependencies into the fat module everytime one of the modules change, since as far as i know, you cannot remove symbols already linked in a module and relink a new version

thanks for replying!

Another question that is more inmediately relevant to me (since it potentially affects or invalidates my current implementation plan) is about the transitivity of the mappings between
symbols of different modules. Let me explain with a minimal example;

say module A implements symbols used in module B, so B is built and when the Call/Invoke instructions are inserted in B for the A symbols, we need to add Global mappings for those symbols
in A manually and use those for the instruction creation. (this is my understand of how mappings for calls between modules is done).

So, now i want to JIT code in B that uses A, so i need to link both B and A into the fat static runtime jit module. Will the mappings (the A symbols used in B) will be preserved when the modules are link to the runtime JIT module?