Skip to content

Again

Again #79

name: Cross-build
# XXX keep paths in sync
on:
push:
branches: [ main, 'stable/14', 'stable/13' ]
paths:
- 'sys/**'
- 'Makefile'
- 'Makefile.inc1'
- '**/cross-bootstrap-tools.yml'
pull_request:
branches: [ main ]
paths:
- 'sys/**'
- 'Makefile'
- 'Makefile.inc1'
- '**/cross-bootstrap-tools.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
setup:
name: setup
runs-on: ubuntu-latest
outputs:
archs: ${{ steps.match.outputs.archs }}
exclude: ${{ steps.match.outputs.exclude }}
make_targets: ${{ steps.match.outputs.make_targets }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: paths filter (kernel)
uses: dorny/paths-filter@v3
id: kern_filter
with:
base: ${{ github.ref_name }}
filters: |
amd64:
- 'sys/amd64/**'
i386:
- 'sys/i386/**'
aarch64:
- 'sys/arm64/**'
armv7:
- 'sys/arm/**'
powerpc: &ppc
- 'sys/powerpc/**'
powerpc64:
- *ppc
powerpc64le:
- *ppc
riscv64:
- 'sys/riscv/**'
all:
- '**/cross-bootstrap-tools.yml'
- name: paths filter (world)
uses: dorny/paths-filter@v3
id: world_filter
with:
base: ${{ github.ref_name }}
filters: |
amd64:
- 'sys/amd64/**.h'
i386:
- 'sys/i386/**.h'
aarch64:
- 'sys/arm64/**.h'
armv7:
- 'sys/arm/**.h'
powerpc: &ppc
- 'sys/powerpc/**.h'
powerpc64:
- *ppc
powerpc64le:
- *ppc
riscv64:
- 'sys/riscv/**.h'
all:
- '**/cross-bootstrap-tools.yml'
- name: match paths
shell: python
id: match
run: |
import os
import json
all = ["amd64", "armv7", "aarch64", "i386", "powerpc", "powerpc64", "powerpc64le", "riscv64"]
out = open(os.environ['GITHUB_OUTPUT'], "a")
kern_archs = []
kern_excl = set()
make_targets = []
if ${{ steps.kern_filter.outputs.changes }} != []:
make_targets.append("buildkernel")
if "${{ steps.kern_filter.outputs.all }}" == "true":
kern_archs = all
else:
kern_archs = ${{ steps.kern_filter.outputs.changes }}
kern_excl = set(all) ^ set(kern_archs)
world_archs = []
world_excl = set()
if ${{ steps.world_filter.outputs.changes }} != []:
make_targets.append("buildworld")
if "${{ steps.world_filter.outputs.all }}" == "true":
world_archs = all
else:
world_archs = ${{ steps.world_filter.outputs.changes }}
world_excl = set(all) ^ set(world_archs)
print("kern_archs: ", kern_archs)
print("world_archs: ", world_archs)
archs = set(world_archs + kern_archs)
# No need to exclude architectures we're not building.
kern_excl &= archs
world_excl &= archs
exclude = []
for a in kern_excl:
exclude += [{ "make_target": "buildkernel" }, { "target_arch": a }]
for a in world_excl:
exclude += [{ "make_target": "buildworld" }, { "target_arch": a }]
print("exclude=" + json.dumps(exclude) + '\n')
print("make_targets=" + json.dumps(make_targets) + '\n')
print("archs=" + json.dumps(list(archs)) + '\n')
out.write("exclude=" + json.dumps(exclude) + '\n')
out.write("make_targets=" + json.dumps(make_targets) + '\n')
out.write("archs=" + json.dumps(list(archs)) + '\n')
out.close()
build:
name: ${{ matrix.target_arch }} ${{ matrix.make_target }} on ${{ matrix.os }} (${{ matrix.compiler }})
runs-on: ${{ matrix.os }}
needs: setup
strategy:
fail-fast: false
matrix:
target_arch: [ powerpc64le, powerpc, powerpc64 ] #${{ fromJSON(needs.setup.outputs.archs) }}
make_target: [ buildkernel ] #${{ fromJSON(needs.setup.outputs.make_targets) }}
os: [ ubuntu-22.04, ubuntu-24.04, macos-latest ]
include:
# TODO: both Ubuntu and macOS have bmake packages, we should try them instead of bootstrapping our own copy.
- os: ubuntu-22.04
compiler: clang-14
cross-bindir: /usr/lib/llvm-14/bin
pkgs: bmake libarchive-dev clang-14 lld-14
- os: ubuntu-24.04
compiler: clang-18
cross-bindir: /usr/lib/llvm-18/bin
pkgs: bmake libarchive-dev clang-18 lld-18
- os: macos-latest
compiler: clang-18
cross-bindir: /opt/homebrew/opt/llvm@18/bin
pkgs: bmake libarchive llvm@18
# Correspoding TARGET for TARGET_ARCH
- target_arch: amd64
target: amd64
- target_arch: armv7
target: arm
- target_arch: aarch64
target: arm64
- target_arch: i386
target: i386
- target_arch: powerpc
target: powerpc
- target_arch: powerpc64
target: powerpc
- target_arch: powerpc64le
target: powerpc
- target_arch: riscv64
target: riscv
exclude: ${{ fromJSON(needs.setup.outputs.exclude) }}
steps:
- uses: actions/checkout@v4
- name: install packages (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update --quiet || true
sudo apt-get -yq --no-install-suggests --no-install-recommends install ${{ matrix.pkgs }}
- name: install packages (macOS)
if: runner.os == 'macOS'
run: |
brew update --quiet || true
brew install ${{ matrix.pkgs }} || true
- name: create environment
run: |
echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE"
if [ -n "${{ matrix.cross-bindir }}" ]; then
echo "EXTRA_BUILD_ARGS=--cross-bindir=${{ matrix.cross-bindir }}" >> $GITHUB_ENV
fi
if [ "${{ matrix.make_target }}" = "buildkernel" ]; then
args="KERNCONF=GENERIC NO_MODULES=yes"
elif [ "${{ matrix.make_target }}" = "buildworld" ]; then
args="WITHOUT_TOOLCHAIN=yes"
fi
mkdir -p ../build
echo "EXTRA_MAKE_ARGS=$args" >> $GITHUB_ENV
echo "MAKEOBJDIRPREFIX=${PWD%/*}/build" >> $GITHUB_ENV
# heh, works on Linux/BSD/macOS ...
echo "NPROC=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1`" >> $GITHUB_ENV
- name: bootstrap bmake
run: ./tools/build/make.py --debug $EXTRA_BUILD_ARGS TARGET=${{ matrix.target }} TARGET_ARCH=${{ matrix.target_arch }} -n
- name: make kernel-toolchain
if: ${{ matrix.make_target }} == buildkernel
run: ./tools/build/make.py --debug $EXTRA_BUILD_ARGS TARGET=${{ matrix.target }} TARGET_ARCH=${{ matrix.target_arch }} kernel-toolchain -s -j$NPROC -DWITH_DISK_IMAGE_TOOLS_BOOTSTRAP
- name: make ${{ matrix.make_target }}
run: ./tools/build/make.py --debug $EXTRA_BUILD_ARGS TARGET=${{ matrix.target }} TARGET_ARCH=${{ matrix.target_arch }} ${{ matrix.make_target }} -s -j$NPROC $EXTRA_MAKE_ARGS