Hi folks, I am newbie trying to learn cranelift. I am wondering how to call an external function (say sin from libmath) from the generated code when emitting .o files with cranelift-object. Is it as simple as declaring a function with module.declare_function("sin", Linkdage::Import, proper_signature) and then the linker would be able to link correctly?
Yes, it should be. Just make sure to add -lm to the linker invocation to depend on libm as that is where sin is defined.
Last updated: Dec 06 2025 at 06:05 UTC