How to specify my own libc library when using libc crate?

My project uses a customized musl library. Is it possible to specify my musl library for the standard rust libc crate, so that I can use the libc crate in my project? Otherwise, I need to build a FFI for my musl library, which is not a good solution in my opinion.

The libc crate is not responsible for linking to an actual libc—that happens as part of the build process based on the target you're compiling for. The libc crate just contains a bunch of target-dependent extern "C" declarations that mirror what's exported from the libc being linked to (check out the source code to see what I mean).

To use your custom musl with Rust, it may be sufficient to put the .a or .so file somewhere that rustc/LLVM can find it and then compile for the appropriate *-unknown-linux-musl target. You might also have to use the nightly-only -Z build-std option to Cargo, I'm not sure.

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.