xref: /freebsd/.github/workflows/cross-bootstrap-tools.yml (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1name: Cross-build Kernel
2
3on:
4  push:
5    branches: [ main, 'stable/13' ]
6  pull_request:
7    branches: [ main ]
8
9permissions:
10  contents: read
11
12jobs:
13  build:
14    name: ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }})
15    runs-on: ${{ matrix.os }}
16    strategy:
17      fail-fast: false
18      matrix:
19        target_arch: [ amd64, aarch64 ]
20        os: [ ubuntu-20.04, ubuntu-22.04, macos-latest ]
21        include:
22          # TODO: both Ubuntu and macOS have bmake packages, we should try them instead of bootstrapping our own copy.
23          - os: ubuntu-20.04
24            compiler: clang-12
25            cross-bindir: /usr/lib/llvm-12/bin
26            pkgs: bmake libarchive-dev clang-12 lld-12
27          - os: ubuntu-22.04
28            compiler: clang-14
29            cross-bindir: /usr/lib/llvm-14/bin
30            pkgs: bmake libarchive-dev clang-14 lld-14
31          - os: macos-latest
32            compiler: clang-13
33            cross-bindir: /usr/local/opt/llvm@13/bin
34            pkgs: bmake libarchive llvm@13
35          - target_arch: amd64
36            target: amd64
37          - target_arch: aarch64
38            target: arm64
39    steps:
40      - uses: actions/checkout@v3
41      - name: install packages (Ubuntu)
42        if: runner.os == 'Linux'
43        run: |
44          sudo apt-get update --quiet || true
45          sudo apt-get -yq --no-install-suggests --no-install-recommends install ${{ matrix.pkgs }}
46      - name: install packages (macOS)
47        if: runner.os == 'macOS'
48        run: |
49          brew update --quiet || true
50          brew install ${{ matrix.pkgs }} || true
51      - name: create environment
52        run: |
53          echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE"
54          if [ -n "${{ matrix.cross-bindir }}" ]; then
55            echo "EXTRA_BUILD_ARGS=--cross-bindir=${{ matrix.cross-bindir }}" >> $GITHUB_ENV
56          fi
57          mkdir -p ../build
58          echo "MAKEOBJDIRPREFIX=${PWD%/*}/build" >> $GITHUB_ENV
59          # heh, works on Linux/BSD/macOS ...
60          echo "NPROC=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1`" >> $GITHUB_ENV
61      - name: bootstrap bmake
62        run: ./tools/build/make.py --debug $EXTRA_BUILD_ARGS TARGET=${{ matrix.target }} TARGET_ARCH=${{ matrix.target_arch }} -n
63      - name: make kernel-toolchain
64        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
65      - name: make buildkernel
66        run: ./tools/build/make.py --debug $EXTRA_BUILD_ARGS TARGET=${{ matrix.target }} TARGET_ARCH=${{ matrix.target_arch }} KERNCONF=GENERIC NO_MODULES=yes buildkernel -s -j$NPROC $EXTRA_MAKE_ARGS
67