Skip to content

Commit f9d127a

Browse files
committed
fix(ci): Phase 6 — split target rustflags from build-script rustflags
The previous iteration of tier4-avx512-check set `RUSTFLAGS= "-Ctarget-cpu=x86-64-v4"` as a job-level env. That env applies to BOTH the target compilation AND host build scripts (`build.rs` artifacts cargo runs natively). On a GH-hosted runner without AVX-512 silicon, those v4-baked build scripts SIGILL during dep compilation — the job exited in 23 s before our own crate even started compiling. Fix: use `CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS` (the env form that's documented to apply only when cargo produces artifacts for that triple, NOT to host build scripts) plus explicit `--target=x86_64- unknown-linux-gnu` so cargo distinguishes host from target even when they share the triple. Result: v4 reaches our crate, baseline reaches build scripts. Cargo doc reference: https://doc.rust-lang.org/cargo/reference/config.html #target<triple>rustflags — "These flags only apply to the final artifact, and won't affect dependencies."
1 parent 45b1bfe commit f9d127a

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,23 +185,31 @@ jobs:
185185
# catches type mismatches and dispatch-arm holes that the v3
186186
# default never touches.
187187
#
188-
# The job-level `RUSTFLAGS` env overrides the global
189-
# `RUSTFLAGS="-D warnings"` set at the top of this file so the v4
190-
# target-cpu actually applies. Without the override, `.cargo/
191-
# config-avx512.toml`'s rustflags would be ignored (env wins over
192-
# config file in cargo's precedence).
188+
# # Why `CARGO_TARGET_<triple>_RUSTFLAGS` instead of plain `RUSTFLAGS`:
189+
#
190+
# The first iteration used `env: RUSTFLAGS: "-Ctarget-cpu=x86-64-v4"`
191+
# and failed in ~23 s — RUSTFLAGS env applies to BOTH the target
192+
# compilation AND host build scripts (`build.rs` artifacts that
193+
# cargo runs natively). On a GH runner without AVX-512 silicon,
194+
# those v4-baked build scripts SIGILL during the dep build.
195+
#
196+
# `CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS` is documented to
197+
# apply only when cargo is producing artifacts for that triple, NOT
198+
# to host build scripts. Combined with explicit `--target` (so cargo
199+
# distinguishes host from target even when they're the same triple),
200+
# this gives us "v4 for our crate, baseline for build scripts."
193201
runs-on: ubuntu-latest
194202
name: tier4-avx512-check
195203
env:
196-
RUSTFLAGS: "-D warnings -Ctarget-cpu=x86-64-v4"
204+
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-D warnings -Ctarget-cpu=x86-64-v4"
197205
steps:
198206
- uses: actions/checkout@v4
199207
- uses: dtolnay/rust-toolchain@stable
200208
- uses: Swatinem/rust-cache@v2
201209
- name: cargo check (v4 / AVX-512 dispatch arm)
202-
run: cargo check -p ndarray --features approx,serde,rayon
210+
run: cargo check --target=x86_64-unknown-linux-gnu -p ndarray --features approx,serde,rayon
203211
- name: cargo check (v4 / AVX-512 + hpc-extras)
204-
run: cargo check -p ndarray --features approx,serde,rayon,hpc-extras
212+
run: cargo check --target=x86_64-unknown-linux-gnu -p ndarray --features approx,serde,rayon,hpc-extras
205213

206214
blas-msrv:
207215
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)