From 8b7f05db0453d0a8af6bd89631be977d4fe8cf16 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Tue, 5 Dec 2023 14:16:36 +0100 Subject: gcc-musl-static: Support cross-compiler build --- README.md | 5 +++-- src/compilers/gcc-13-musl-static.TARGETS | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e297796..76fc9a4 100644 --- a/README.md +++ b/README.md @@ -47,16 +47,17 @@ Details about toolchain variants: the target system*) - **supports fully static linking (unlike *glibc* toolchains)** - **supports cross-compilation for project's `TARGET_ARCH`** -- `-musl-static`: statically linked compiler with musl support +- `-musl-static`: statically linked *cross* compiler with musl support - runs on systems without any existing C library - **links against bundled *musl libc*** (*note that dynamically linked binaries require a working musl ld+libc on the target system*) - **supports fully static linking (unlike *glibc* toolchains)** + - **supports cross-compilation for project's `TARGET_ARCH`** - `+tools` (e.g., `gcc-13.2.0-native+tools`) - `` bundled with all latest tools (see `tools-all` above) -Non-static `musl` variants support cross-compilation. In your project, make sure +All `musl` variants support cross-compilation. In your project, make sure that the variables `ARCH` and `TARGET_ARCH` are set to one of the following values: `x86`, `x86_64`, `arm`, or `arm64`. diff --git a/src/compilers/gcc-13-musl-static.TARGETS b/src/compilers/gcc-13-musl-static.TARGETS index 6f7ee9c..58f29b2 100644 --- a/src/compilers/gcc-13-musl-static.TARGETS +++ b/src/compilers/gcc-13-musl-static.TARGETS @@ -77,11 +77,13 @@ , "printf '#!/bin/sh\\nexec \"%s\" -static \"$@\"' \"${CC}\" >${TMPDIR}/cc" , "printf '#!/bin/sh\\nexec \"%s\" -static \"$@\"' \"${CXX}\" >${TMPDIR}/c++" , "chmod +x ${TMPDIR}/cc ${TMPDIR}/c++" + , "export CC=\"${TMPDIR}/cc\"" + , "export CXX=\"${TMPDIR}/c++\"" , "mv musl-latest.orig musl.readonly" , "cp -r musl.readonly musl-latest.orig && chmod -R +w musl-latest.orig" , "export check_msgfmt=no # do not use system's msgfmt, if available" - , "${MAKE} -j${NJOBS} TARGET=${TARGET} CC=${TMPDIR}/cc CXX=${TMPDIR}/c++ LDFLAGS='-static' LDFLAGS_FOR_TARGET='-static' >build.log 2>&1 || (cat build.log && exit 1)" - , "${MAKE} -j${NJOBS} TARGET=${TARGET} CC=${TMPDIR}/cc CXX=${TMPDIR}/c++ LDFLAGS='-static' LDFLAGS_FOR_TARGET='-static' OUTPUT= DESTDIR=${DESTDIR} install >>build.log 2>&1 || (cat build.log && exit 1)" + , "${MAKE} -j${NJOBS} TARGET=${TARGET} LDFLAGS='-static' LDFLAGS_FOR_TARGET='-static' >build.log 2>&1 || (cat build.log && exit 1)" + , "${MAKE} -j${NJOBS} TARGET=${TARGET} LDFLAGS='-static' LDFLAGS_FOR_TARGET='-static' OUTPUT= DESTDIR=${DESTDIR} install >>build.log 2>&1 || (cat build.log && exit 1)" , "cd ${DESTDIR}" , "STRIP=${LOCALBASE}/bin/strip" , "find ./bin/ ./${TARGET}/bin/ ./libexec/gcc/ -type f -exec sh -c \"${STRIP} {} 2>/dev/null\" \\;" -- cgit v1.2.3