From 6e3b5be4d2c10d941c3503c5e3f7d0535bdf9619 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 17 Jan 2025 05:37:04 +0100 Subject: [PATCH] Fix remaining CI test failures on Linux This involves a bit of fiddling so we can cross-compile the standard library tests to musl while on a GNU host. This in turn is necessary as GitHub's runner doesn't support Alpine on ARM64 hosts for some reason (https://github.com/actions/runner/issues/801). --- .github/workflows/tests.yml | 14 ++++++++------ ci/linux.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100755 ci/linux.sh diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e1c1384b9..af7c5d5c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -110,18 +110,20 @@ jobs: runs-on: ${{ matrix.target.runner }} container: image: ghcr.io/inko-lang/ci:fedora + env: + # This is needed because when setting an explicit target, "ring" looks for + # `aarch64-linux-musl-gcc` instead of using `musl-gcc`. + CC_aarch64_unknown_linux_musl: musl-gcc steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: path: '${{ env.CARGO_HOME }}' key: ${{ matrix.target.name }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }} - - name: Build the runtime - run: cargo build -p rt --target=${{ matrix.target.triple }} - - name: Build the compiler - run: INKO_RT="${PWD}/target/${{ matrix.target.triple }}/debug" cargo build -p inko - - name: Run the tests - run: 'cd std && ../target/${{ matrix.target.triple }}/debug/inko test --opt=${{ matrix.level }} --target=${{ matrix.name }}' + - name: Build the runtime and compiler + run: ./ci/linux.sh ${{ matrix.target.name }} ${{ matrix.target.triple }} + - name: Run tests + run: 'cd std && ../target/debug/inko test --opt=${{ matrix.level }} --target=${{ matrix.target.name }}' compiler-mac: strategy: diff --git a/ci/linux.sh b/ci/linux.sh new file mode 100755 index 000000000..ed861319f --- /dev/null +++ b/ci/linux.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -e + +INKO_VERSION="$(cargo pkgid -p inko | cut -d\# -f2 | cut -d: -f2)" +INKO_TRIPLE="${1}" +RUST_TRIPLE="${2}" +INKO_RUNTIMES="${HOME}/.local/share/inko/runtimes/${INKO_VERSION}/${INKO_TRIPLE}" + +function rustup_lib { + local home + local toolchain + home="$(rustup show home)" + toolchain="$(rustup show active-toolchain | awk '{print $1}')" + + echo "${home}/toolchains/${toolchain}/lib/rustlib/${1}/lib/" +} + +# As the host is a GNU host, a bit of extra work is needed to get +# cross-compilation to musl to work. +if [[ "${INKO_TRIPLE}" == *-musl ]] +then + cargo build -p rt --target="${RUST_TRIPLE}" + mkdir -p "${INKO_RUNTIMES}" + cp "./target/${RUST_TRIPLE}/debug/libinko.a" "${INKO_RUNTIMES}/libinko.a" + cp "$(rustup_lib "${RUST_TRIPLE}")/self-contained/libunwind.a" \ + "${INKO_RUNTIMES}/libunwind.a" + + INKO_RT="${PWD}/target/${RUST_TRIPLE}/debug" cargo build -p inko +else + cargo build +fi