Hey guys! I am trying to load some pre-compiled cranelift IR snippets emitted from rustc with cranelift-reader. My ultimate goal is to add those pre-compiled functions to JITModule. The problem i have now is some of those functions contain reference to external global value, like:
gv0 = symbol colocated userextname0 ; alloc3
gv1 = symbol colocated userextname2 ; alloc10
but i can't find the actual definition of them in any of the emitted clif files. Is there any workaround for this?
One thing that's potentially surprising about Cranelift, coming from a compiler like LLVM, is that the IR is mostly function-centric. The core compiler library (cranelift-codegen) is entirely built around functions, and knows only that and opaque references to "the rest of the world" (the UserExternalName you're seeing). cranelift-jit, cranelift-module, etc. form a second layer of software that does start to aggregate functions into modules, but we don't have a textual representation for that. We'd need such a textual representation if you wanted to serialize a whole module and load it back in.
Last updated: Dec 06 2025 at 06:05 UTC