Skip to content

Build on Alpine Linux (Chroot) #98

Build on Alpine Linux (Chroot)

Build on Alpine Linux (Chroot) #98

Workflow file for this run

# .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}} with ${{matrix.compiler.GCC}}
strategy:
fail-fast: FALSE
matrix:
target: [ # empty MARCH is always sufficient (just by chance)
x86_64, x86, aarch64, armhf, ppc64le, armv7, riscv64, loongarch64, s390x
]
compiler:
- { label: gcc, apk: g++, gcc: gcc, gxx: g++ }
- { label: clang16, apk: clang16, gcc: clang-16, gxx: clang++-16 }
- { label: clang18, apk: clang18, gcc: clang-18, gxx: clang++-18 }
- { label: clang19, apk: clang19, gcc: clang-19, gxx: clang++-19 }
- { label: clang20, apk: clang20, gcc: clang-20, gxx: clang++-20 }
# clang15 (partial), clang17
runs-on: ubuntu-2${{matrix.target == 'loongarch64' && '4' || '2'}}.04
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
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}}/alpine-minirootfs-3.22.2-${{matrix.target}}.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 != 's390x'
run: |
exec 2>&1
sudo chroot /srv/alpine /bin/su - runner <<'END'
set -x
echo 'int main() {}' >main.cc
${{matrix.compiler.gxx}} -pipe -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
readelf -h a.out
#make -j4 run GCC='${{matrix.compiler.gcc}}' GXX='${{matrix.compiler.gxx}}'
END
- name: Upload Results
if: matrix.target != 's390x'
uses: actions/upload-artifact@v4
with:
name: build-${{matrix.target}}-${{matrix.compiler.label}}
path: build