Skip to content

Commit 86da9e9

Browse files
authored
Use host toolchain and explicit target in CI script (#1109)
This fixes a problem of installing i686 toolchain on an x86_64 host when running "Minimal tests - mmtk-core" on GitHub CI. Instead, we use the x86_64 toolchain, but add the i686 target and force all cargo commands to use that target using the `CARGO_BUILD_TARGET` environment variable. Fixes: #1107
1 parent 0540bb5 commit 86da9e9

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.github/scripts/ci-common.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
arch=`rustc --print cfg | grep target_arch | cut -f2 -d"\""`
2-
os=`rustc --print cfg | grep target_os | cut -f2 -d"\""`
1+
# Note: cargo-rustc is influenced by the environment variable CARGO_BUILD_TARGET
2+
# which is specified in minimal-tests-core.yml
3+
arch=`cargo rustc -- --print cfg | grep target_arch | cut -f2 -d"\""`
4+
os=`cargo rustc -- --print cfg | grep target_os | cut -f2 -d"\""`
35

46
project_root=$(dirname "$0")/../..
57

.github/scripts/ci-doc.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ if ! cat $project_root/src/plan/mod.rs | grep -q "pub mod mygc;"; then
2222
fi
2323
cargo build
2424

25-
# Install mdbook using the stable toolchain
25+
# Install mdbook using the stable toolchain and the default target
26+
unset CARGO_BUILD_TARGET
2627
cargo +stable install mdbook
2728
mdbook build $project_root/docs/userguide

.github/workflows/minimal-tests-core.yml

+16-3
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,30 @@ jobs:
4242
name: minimal-tests-core/${{ matrix.target.triple }}/${{ matrix.rust }}
4343
runs-on: ${{ matrix.target.os }}
4444

45+
env:
46+
# This determines the default target which cargo-build, cargo-test, etc. use.
47+
CARGO_BUILD_TARGET: "${{ matrix.target.triple }}"
48+
4549
steps:
4650
- uses: actions/checkout@v4
4751
- name: Install Rust
4852
run: |
49-
rustup toolchain install ${{ matrix.rust }}-${{ matrix.target.triple }}
50-
rustup override set ${{ matrix.rust }}-${{ matrix.target.triple }}
53+
# "rustup toolchain install" should always install the host toolchain,
54+
# so we don't specify the triple.
55+
rustup toolchain install ${{ matrix.rust }}
56+
rustup override set ${{ matrix.rust }}
57+
58+
# Ensure we install the target support for the target we are testing for.
59+
# This is especially important for i686-unknown-linux-gnu
60+
# because it's different from the host.
61+
rustup target add ${{ matrix.target.triple }}
62+
5163
rustup component add rustfmt clippy
5264
53-
# Show the Rust toolchain we are actually using
65+
# Show the Rust toolchain and target we are actually using
5466
- run: rustup show
5567
- run: cargo --version
68+
- run: cargo rustc -- --print cfg
5669

5770
# Setup Environments
5871
- name: Setup Environments

0 commit comments

Comments
 (0)