C FFI: link error one most linkers

Hello!

Lately I have been trying to create ffi bindings to the pocketpy project, using bindgen. The c library is complied to a static lib and linked against. The issue is that, when running any code using the ffi bindings (like by using cargo test), I get link errors, and only when using any other linker than the default.
This also happened after creating an other external crate and adding the ffi bindings as a dependency, even with the default linker.

lld and gold will complain that the functions are undefined, and mold complains about an "onload" function that is unrelated to the c library.

Here is a link to the repo, so far I only tested it on linux on an x86_64 machine.

As far as I can tell, the library is being linked against, and when using strings on the compiled static lib, all the "undefined" methods seem to be present.

Does anyone have an idea of what might be wrong here?

Thank you for taking the time to read!

Update, I disabled IPO (Interprocedural optimization) when compiling the pocketpy library, that fixed the issue. Now looking into a potential way to keep IPO, because ofc disabling it reduces performance.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.