From 1911d3d768960801b53c5bab31d6efb82a828b30 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 13 Nov 2025 00:30:36 +0100 Subject: [PATCH] Cross-compile Docker container updated to include musl --- .github/workflows/build_docker_image.yml | 2 +- .github/workflows/build_wheels.yml | 2 +- .github/workflows/ci.yml | 2 +- tools/cross_compiler_unix/Dockerfile | 5 +++++ tools/cross_compiler_unix/build_musl.sh | 23 +++++++++++++++++++++++ tools/cross_compiler_unix/packobjs.sh | 16 ++++++++++++++++ 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 tools/cross_compiler_unix/build_musl.sh create mode 100644 tools/cross_compiler_unix/packobjs.sh diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml index 220d388..6f9ab27 100644 --- a/.github/workflows/build_docker_image.yml +++ b/.github/workflows/build_docker_image.yml @@ -25,7 +25,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Set image name - run: echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/cross_compiler_unix:1" >> $GITHUB_ENV + run: echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/cross_compiler_unix:2" >> $GITHUB_ENV - name: Build Docker image run: docker build -t $IMAGE_NAME ./tools/cross_compiler_unix/ diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index be81ad1..7fe78b9 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -10,7 +10,7 @@ jobs: build_stencils: runs-on: ubuntu-latest container: - image: ghcr.io/nonannet/cross_compiler_unix:1 + image: ghcr.io/nonannet/cross_compiler_unix:2 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 280efe6..021eafb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: build_stencils: runs-on: ubuntu-latest container: - image: ghcr.io/nonannet/cross_compiler_unix:1 + image: ghcr.io/nonannet/cross_compiler_unix:2 steps: - uses: actions/checkout@v4 diff --git a/tools/cross_compiler_unix/Dockerfile b/tools/cross_compiler_unix/Dockerfile index d186276..7c23b36 100644 --- a/tools/cross_compiler_unix/Dockerfile +++ b/tools/cross_compiler_unix/Dockerfile @@ -5,6 +5,7 @@ WORKDIR /home RUN apt-get update && apt-get install -y \ build-essential \ gcc-13 \ + gcc-12-i686-linux-gnu \ gcc-13-arm-linux-gnueabihf \ gcc-13-mips-linux-gnu \ gcc-13-mipsel-linux-gnu \ @@ -13,3 +14,7 @@ RUN apt-get update && apt-get install -y \ gcc-13-multilib \ python3 \ git + +COPY *.sh ./ + +RUN sh build_musl.sh && ls build/ \ No newline at end of file diff --git a/tools/cross_compiler_unix/build_musl.sh b/tools/cross_compiler_unix/build_musl.sh new file mode 100644 index 0000000..dc4f03b --- /dev/null +++ b/tools/cross_compiler_unix/build_musl.sh @@ -0,0 +1,23 @@ + +#!/bin/sh + +git clone --single-branch --branch master --depth 1 https://git.musl-libc.org/git/musl +cd musl + +./configure CFLAGS="-O2 -fno-stack-protector -ffast-math" +sh packobjs.sh x86_64 + +./configure CFLAGS="-O2 -fno-stack-protector" CC=i686-linux-gnu-gcc-13 +sh packobjs.sh x86 + +./configure CFLAGS="-O2 -fno-stack-protector" CC=aarch64-linux-gnu-gcc-13 +sh packobjs.sh arm64 + +#./configure CFLAGS="-O2 -fno-stack-protector" CC=mips-linux-gnu-gcc-13 +#sh packobjs.sh mips + +#./configure CFLAGS="-O2 -fno-stack-protector" CC=riscv64-linux-gnu-gcc-13 +#sh packobjs.sh riscv64 + + + diff --git a/tools/cross_compiler_unix/packobjs.sh b/tools/cross_compiler_unix/packobjs.sh new file mode 100644 index 0000000..af9233d --- /dev/null +++ b/tools/cross_compiler_unix/packobjs.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +ARCH=$1 + +mkdir -p ../build/stencil_objs + +cd ../build/stencil_objs +ar x ../../../musl/lib/libc.a sinf.lo cosf.lo tanf.lo asinf.lo acosf.lo atanf.lo atan2f.lo +ar x ../../../musl/lib/libc.a sqrtf.lo logf.lo expf.lo sqrt.lo +ar x ../../../musl/lib/libc.a logf_data.lo __tandf.lo __cosdf.lo __sindf.lo __rem_pio2f.lo __math_invalidf.lo __stack_chk_fail.lo __math_divzerof.lo __math_oflowf.lo __rem_pio2_large.lo scalbn.lo floor.lo exp2f_data.lo powf.lo powf_data.lo __math_uflowf.lo __math_xflowf.lo +ar x ../../../musl/lib/libc.a fabsf.lo + +ld -r *.lo -o ../musl_objects_{$ARCH}.o + +rm ../build/stencil_objs/* +cd ../../musl \ No newline at end of file