Build on Alpine Linux (Chroot) #122
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/alpine.yaml | |
| name: Build on Alpine Linux (Chroot) | |
| on: | |
| workflow_dispatch: NULL | |
| jobs: | |
| alpine-build: | |
| #name: Build on Alpine Linux for ${{matrix.target.guest}} with ${{matrix.compiler.GCC}} | |
| name: On ${{matrix.target.guest}} with ${{matrix.compiler.gcc}} | |
| strategy: | |
| fail-fast: FALSE | |
| matrix: | |
| #target: [ # empty MARCH is always sufficient (just by chance) --- TODO: add using -arm host! | |
| # x86_64, x86, aarch64, armhf, ppc64le, armv7, riscv64, loongarch64, s390x | |
| #] | |
| target: | |
| - { guest: x86_64 } | |
| - { guest: x86 } # -msse2 -mfpmath=sse is assumed | |
| - { guest: aarch64, host: -arm } | |
| - { guest: armv7, host: -arm } # -mthumb default in spec for gcc, but not for clang, -march=armv7-a is assumed | |
| - { guest: ppc64le, qemu: TRUE } | |
| - { guest: riscv64, qemu: TRUE } | |
| - { guest: armhf, host: -arm } | |
| - { guest: loongarch64, qemu: TRUE } | |
| - { guest: s390x, qemu: TRUE } | |
| compiler: | |
| - { apk: g++, gcc: gcc, gxx: g++ } | |
| - { apk: clang16, gcc: clang-16, gxx: clang++-16 } | |
| - { apk: clang18, gcc: clang-18, gxx: clang++-18 } | |
| - { apk: clang19, gcc: clang-19, gxx: clang++-19 } | |
| - { apk: clang20, gcc: clang-20, gxx: clang++-20 } | |
| # clang15 (partial), clang17 | |
| runs-on: ubuntu-2${{matrix.target.guest == 'loongarch64' && '4' || '2'}}.04${{matrix.target.host}} | |
| defaults: | |
| run: { shell: bash } | |
| steps: | |
| - name: Machine Information | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| lscpu; free -h; df -H . | |
| - name: System Information | |
| run: | | |
| exec 2>&1 | |
| date; uname -a; uptime | |
| set -x | |
| systemd-detect-virt || : | |
| cat /etc/os-release | |
| ls -C /boot || : | |
| - name: Context Information | |
| run: | | |
| exec 2>&1 | |
| tty || :; id; printf %s\\n SHELL="$SHELL" PATH="$PATH" | |
| set -x | |
| pwd | |
| ps -eH --sort pid -o pid,user:12,group:12,comm:24,rsz,vsz,thcount,bsdstart,state,tname | |
| - name: Host Setup | |
| if: (matrix.target.qemu) | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| sudo sed -i /azure/d /etc/apt/apt-mirrors.txt | |
| sudo apt-get update | |
| sudo apt-get install qemu-user-static | |
| - name: Chroot Setup | |
| run: | | |
| exec 2>&1 | |
| (set -x; wget --no-show-progress -O- \ | |
| https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/${{matrix.target.guest}}/alpine-minirootfs-3.22.2-${{matrix.target.guest}}.tar.gz) | | |
| (set -x; sudo mkdir /srv/alpine; sudo tar xz -C /srv/alpine) | |
| (for d in dev proc sys; do (set -x; sudo mount -R -r {,/srv/alpine}/"$d") done) | |
| (for d in run tmp; do (set -x; sudo mount {-t,}tmpfs /srv/alpine/"$d") done; set -x; sudo chmod 1777 /srv/alpine/tmp) | |
| (set -x; sudo cp -L /etc/resolv.conf /srv/alpine/etc) | |
| sudo chroot /srv/alpine /bin/su - <<'END' | |
| set -x | |
| adduser -D -u1001 -s/bin/ash runner | |
| END | |
| (set -x; sudo mount -R . /srv/alpine/home/runner) | |
| sudo chroot /srv/alpine /bin/su - <<'END' | |
| set -x | |
| apk update && apk add make ${{matrix.compiler.apk}} libc-dev | |
| END | |
| - name: Context Information | |
| run: | | |
| exec 2>&1 | |
| sudo chroot /srv/alpine /bin/su - runner <<'END' | |
| uname -a; id; printf %s\\n SHELL="$SHELL" PATH="$PATH" | |
| set -x | |
| pwd | |
| END | |
| - name: Build Tools Information | |
| run: | | |
| exec 2>&1 | |
| sudo chroot /srv/alpine /bin/su - runner <<'END' | |
| set -x | |
| make --version; ${{matrix.compiler.gcc}} --version | |
| END | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| #with: { ref: master } | |
| - name: Run Make (and Check) | |
| #if: matrix.target.guest != 's390x' | |
| run: | | |
| exec 2>&1 | |
| sudo chroot /srv/alpine /bin/su - runner <<'END' | |
| set -x | |
| echo 'double f(double a, double b) { return a + b; }' >main.cc | |
| ${{matrix.compiler.gxx}} -pipe -v -w -pthread -std=c++17 -fPIC -fno-math-errno -Wno-psabi -O3 \ | |
| -fno-stack-protector -fcf-protection=none -fno-stack-clash-protection -U_FORTIFY_SOURCE \ | |
| -include prelude.cc main.cc -S -o- | |
| #./a.out | |
| #make -j4 run GCC='${{matrix.compiler.gcc}}' GXX='${{matrix.compiler.gxx}}' \ | |
| # ${{matrix.target.march && format('MARCH=''{0}''', matrix.target.march)}} | |
| END | |
| - name: Upload Results | |
| if: matrix.target.guest != 's390x' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-${{matrix.target.guest}}-${{matrix.compiler.gcc}} | |
| path: build |