Stream: general

Topic: Call external function in generated code


view this post on Zulip Tianyu Geng (Nov 04 2023 at 20:48):

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?

view this post on Zulip bjorn3 (Nov 05 2023 at 10:00):

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: Oct 23 2024 at 20:03 UTC