C API for hooking MCJIT's resolving of out-of-module references?

I am trying to port the Kaleidoscope tutorials to use the C API.

This worked up to part 3, but the code for part 4 (where MCJIT support is added), creates a custom memory manager, in C++, that is then added with setMCJITMemoryManager().

The custom memory manager is used in order to resolve references from a module to symbols outside the module, e.g. to symbols representing code jitted in other modules.

So, how can I hook the way MCJIT resolves out-of-module references, using only the C API? Alternatively, is there some other way to handle cross module references?

I briefly looked at the WebKit FTL code. They (mostly) use the C API but I could not see how symbol references were handled.

(I use the C API because the surrounding application is written in C, so adding my own C wrappers for unexposed functionality is not an attractive option.)

Thanks in advance,

Per Mildner
Per.Mildner@sics.se

Hi Per,

It doesn’t look like there’s any way to do this with the existing C-API. I suspect this isn’t an issue for the FTL developers as they resolve most (perhaps all?) of their symbols at the IR level.

I think it would be possible to extend the C-API to support symbol resolution callbacks: We could add a new variant of the LLVMCreateSimpleMCJITMemoryManager function which also takes a symbol resolution callback.

Cheers,
Lang.