nfl
nfl

Reputation: 65

How to force compiler to use musl libc libraries and includes on glibc-based system?

I am on a glibc-based host system, although it has the musl libc installed.

How do I force the compiler to use the musl dynamic linker, use the musl headers and link against the musl libraries? Additionally, how do I ensure it loads the musl libraries at runtime? (patchelf is not an option as it applies after the build, meaning anything that relies on intermediate excusable will break)

Cross-compiling leads to issues as buildsystems (namely, autotools) incorrectly assume that binaries compiled for the musl target cannot run on the glibc host. If this can be resolved, then cross-compiling could work as long as I can also ensure that the cross-compiler will still use the hosts libraries for everything other than the libc.

I have tried passing -nostartfiles and manually listing every file provided by musl, as well as setting the musl directory as a sysroot while adding the host directories after, as well as trying a cross-compiler with a reconfigured sysroot.

I have been unable to link against the musl libraries at compile-time and also ensure they are used at runtime, as the default paths of the host gcc lead to glibc.

What compiler options will allow me to ensure gcc does not load the glibc files and instead loads the musl files? Setting paths seems to not have worked, is there a way I can prevent gcc from loading specifc filepaths (i.e. /usr/local/libc.so) and then force it to load an exact path? (i.e. /usr/local/x86_64-cros-linux-musl/lib/libc.so)

Upvotes: 0

Views: 382

Answers (0)

Related Questions