Skip to content

Instantly share code, notes, and snippets.

@bencord0
Last active August 23, 2020 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bencord0/f09905ecbb0a147d91d20d7e68debb73 to your computer and use it in GitHub Desktop.
Save bencord0/f09905ecbb0a147d91d20d7e68debb73 to your computer and use it in GitHub Desktop.
crossdev musl
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
# Set the compiler toolchain to musl-gcc
# In gentoo, create the toolchain with crossdev
#
# crossdev -t x86_64-pc-linux-musl -S
#
CC = x86_64-pc-linux-musl-gcc
# The toolchain sets the ELF Interpreter to /lib/ld-musl-x86_64.so.1
# Either, set the interpreter in the binary to the musl dynamic loader,
# which is the same file as the libc, or symlink the expected loader.
#
# ln -s /usr/x86_64-pc-linux-musl/usr/lib/libc.so /lib/ld-musl-x86_64.so.1
#
# Uncomment this line to compile the location of the linker into the binary
#LDFLAGS += -Wl,--dynamic-linker=/usr/x86_64-pc-linux-musl/usr/lib/libc.so
# For programs that link against other libraries too, add the musl variants
# to their RPATH, this way, you don't need LD_PRELOAD tricks.
LDFLAGS += -Wl,-rpath,/usr/x86_64-pc-linux-musl/usr/lib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment