tangramdotdev / packages

A collection of community maintained Tangram packages.
https://www.tangram.dev
MIT License
8 stars 2 forks source link

Use SONAME to determine interpreter flavor on Linux #24

Open deciduously opened 7 months ago

deciduously commented 7 months ago

Currently, a std employs imperfect strategies to differentiate between ld-musl and ld-linux interpreters:

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.