I am using Rust to write infrastructures of my team, which includes some executables and some static libraries for others to use. Other members in my team do not use Rust, and develop with different Linux versions. So for better compatibility, I prefer to compile executables in my Rust workspace with x86_64-unknown-linux-musl
target since it is statically linked and can be distributed to others with no dependencies.
However, I also need to distribute the static libraries (with FFIs I have written) for others to use. Since cargo does not support per-package target configurations, the whole packages in my workspaces are either be compiled with x86_64-unknown-linux-musl
or x86_64-unknown-linux-gnu
. In my understanding, the static library itself does not contain any actual codes of libc, and the musl and glibc have same interface, so does this mean we can link a Rust static library (which is compiled with x86_64-unknown-linux-musl
) in a C program compiled with glibc
(which is the default libc implementation in most Linux distributions)?