Currently, a std employs imperfect strategies to differentiate between ld-musl and ld-linux interpreters:
Check the file name for the string ld-musl or ld-linux. This strategy is Incorrect when the interpreter file is referred to by ID, we don't have this string.
Execute the interpreter with the --help argument and search for the string musl in the resulting stderr. This is always correct, but incurs a wasteful amount of overhead.
Instead, we can parse the ELF header and search for the SONAME field. In the case of glibc, this field will always be set and include the full ld-linux name. For musl, the toolchains we produce will contain ld-musl interpreters which are just symlinks to libc.so. This file does not have SONAME set, and therefore cannot be an ld-linux interpreter. This strategy can be implemented in both std.wrap and the ld proxy.
On Fedora, installing musl via the package manager does produce an actual ELF file with a SONAME containing ld-musl, instead of a symlink. We could consider producing our musl toolchains in this manner as well, but the bootstrap toolchain we obtain from musl.cc will still only contain the symlink, so we will need to handle this case as well.
Currently, a
std
employs imperfect strategies to differentiate betweenld-musl
andld-linux
interpreters:ld-musl
orld-linux
. This strategy is Incorrect when the interpreter file is referred to by ID, we don't have this string.--help
argument and search for the stringmusl
in the resultingstderr
. This is always correct, but incurs a wasteful amount of overhead.Instead, we can parse the ELF header and search for the SONAME field. In the case of glibc, this field will always be set and include the full
ld-linux
name. Formusl
, the toolchains we produce will containld-musl
interpreters which are just symlinks tolibc.so
. This file does not have SONAME set, and therefore cannot be anld-linux
interpreter. This strategy can be implemented in bothstd.wrap
and theld
proxy.On Fedora, installing
musl
via the package manager does produce an actual ELF file with a SONAME containingld-musl
, instead of a symlink. We could consider producing our musl toolchains in this manner as well, but the bootstrap toolchain we obtain frommusl.cc
will still only contain the symlink, so we will need to handle this case as well.