I want to find the libc.so file that's being used in a Rust build so that I can query it with --version
. (Some libcs expose their version information via C macros, so an alternative for them would be to use the cc
crate in a build script. But others like musl don't.)
I can figure out which libstd-*.so
file a rust binary or library will be linked against. When this libstd.so
is linked against the host's libc, then running ldd
on it shows that libc.so
. But when the host system is using glibc and the targeted environment is musl, this doesn't work ("Invalid ELF header"). Instead of ldd
, I could instead use readelf -d
or objdump -p
on the libstd.so
. But these only show the filename of the libc.so
file it uses, not its full path. And that libc.so
isn't at any of the directories in LD_LIBRARY_PATH
. (I do know where it is on my own systems, but I'm trying to find it programmatically on arbitrary systems.)
Running ldconfig -p
only gives me information about the libc for the host system.
It would be great if there were a rustc equivalent of gcc's and clang's -print-file-name=libc.so
, so that I could do something like rustc --target=$TARGET --print-file-name=libc.so
.
Other ideas about how I could get this information?