Question as title says. I was reading about the JIT here: https://docs.rs/cranelift-jit/latest/cranelift_jit/struct.JITBuilder.html#method.symbol in preparation of trying to use some extern calls. It appears that there is some fallback path for symbol search (when symbol resolution does not resolve in the internal table).
How can I expose a runtime which I write to the JIT?
Perhaps I need to add a https://docs.rs/cranelift-jit/latest/cranelift_jit/struct.JITBuilder.html#method.symbol_lookup_fn symbol_lookup_fn
(?) Is there a simple example of extern
function usage with the JIT I could look at somewhere?
Edit: Found an answer in the simple jit.
McCoy has marked this topic as resolved.
Not sure if this is helpful beyond the example, but here's how I declared external symbols for a JIT I wrote recently: https://github.com/sampsyo/bril/blob/58b9794db5eefd4afbd4daf4566177cd03a84b1c/brilift/src/main.rs#L307
Namely, just calling builder.symbol
is sufficient to make it possible to then use module.declare_function
with import linkage:
https://github.com/sampsyo/bril/blob/58b9794db5eefd4afbd4daf4566177cd03a84b1c/brilift/src/main.rs#L202-L207
@Adrian Sampson thanks for the tip! Love your compile course material btw.
Last updated: Dec 23 2024 at 12:05 UTC