Skip to content

Commit

Permalink
Fix remaining CI test failures on Linux
Browse files Browse the repository at this point in the history
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
(actions/runner#801).
  • Loading branch information
yorickpeterse committed Jan 17, 2025
1 parent 651aca0 commit 6e3b5be
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 32 additions & 0 deletions ci/linux.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6e3b5be

Please sign in to comment.