Skip to content

Commit f44abb3

Browse files
authored
Merge pull request #314 from AdaWorldAPI/claude/dockerfile-cargo-config-copy
fix: COPY .cargo/ into both image builders (regression from #313), and correct the RUSTFLAGS fallback tier
2 parents dc10931 + a08bd40 commit f44abb3

4 files changed

Lines changed: 42 additions & 4 deletions

File tree

CLAUDE.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,19 @@ src/
141141

142142
`env -u RUSTFLAGS` is load-bearing: a RUSTFLAGS env var REPLACES every
143143
cargo-config rustflags entry, so it silently drops `-Ctarget-cpu=x86-64-v4`
144-
and the arm measures v3 while claiming v4 (the trap `scripts/masking-parity.sh`
145-
documents).
144+
and the arm does NOT measure v4 while claiming to (the trap
145+
`scripts/masking-parity.sh` documents).
146+
147+
> **CORRECTED 2026-09-16 (coderabbit, #313).** This read "*and the arm
148+
> measures v3*". Wrong, and this session's own measurement is what disproves
149+
> it: RUSTFLAGS replaces **every** config rustflags entry, so it drops the
150+
> DEFAULT config's target-cpu too, not just the overlay's. Measured on one
151+
> unit — `RUSTFLAGS="-D warnings"` produced **zero** `-Ctarget-cpu` flags,
152+
> against 65 with the env unset. What you actually get is rustc's own default
153+
> for the target, i.e. the `x86-64` baseline (SSE2), which is LOWER than v3
154+
> and is the tier `simd_avx2.rs`'s intrinsics SIGILL on. The sentence was
155+
> wrong before the native flip as well; the flip only changed which config
156+
> gets discarded.
146157
147158
**That same mechanism had silently disabled the whole config in CI, and it is
148159
the more serious half (found 2026-09-16).** `.github/workflows/ci.yaml` sets a

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ COPY ndarray-rand/benches/ ndarray-rand/benches/
7272
# detects AVX-512 at runtime via LazyLock<Tier> even when compiled for v3;
7373
# compile-time v3 just means the scalar/AVX2 fallback paths are used when the
7474
# runtime check fails. Both paths produce identical results.
75+
# The cargo CONFIG DIRECTORY, required by the `--config` flags below and easy to
76+
# forget: this Dockerfile COPYs selectively by design (see the note above), so a
77+
# file that is not named here does not exist in the image. Adding `--config
78+
# .cargo/config-v3.toml` without this line makes cargo fail on a missing
79+
# configuration file BEFORE it compiles anything — which is exactly what
80+
# happened on #313 and was caught in review after merge, not by a build (there
81+
# is no Docker daemon in the dev container, so neither image is built here).
82+
COPY .cargo/ .cargo/
83+
7584
# The tier is passed as a CONFIG, not as `ENV RUSTFLAGS` (changed 2026-09-16).
7685
# A RUSTFLAGS env REPLACES every cargo-config `rustflags` entry rather than
7786
# joining it, so `ENV RUSTFLAGS="-C target-cpu=x86-64-v3"` did set the tier —

Dockerfile.avx512

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ COPY examples/ examples/
5050
COPY benches/ benches/
5151
COPY ndarray-rand/benches/ ndarray-rand/benches/
5252

53+
# The cargo CONFIG DIRECTORY, required by the `--config` flags below. This
54+
# Dockerfile COPYs selectively, so a file not named here is absent from the
55+
# image and cargo fails on a missing configuration file before compiling.
56+
COPY .cargo/ .cargo/
57+
5358
# AVX-512 pinned: compile-time dispatch, everything inlined.
5459
#
5560
# Passed as a CONFIG, not `ENV RUSTFLAGS` (changed 2026-09-16): a RUSTFLAGS env

scripts/masking-parity.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,21 @@ case "$ARM" in
2626
# `env -u RUSTFLAGS`: a workflow-global RUSTFLAGS (CI sets "-D warnings")
2727
# REPLACES every cargo-config rustflags entry, so a `--config
2828
# .cargo/config-v4.toml` passed through CARGO_ARGS would silently lose its
29-
# `-Ctarget-cpu=x86-64-v4` and this arm would measure v3 while claiming
30-
# v4 — the exact trap the tier4 CI job hit. Clearing it lets the config win.
29+
# `-Ctarget-cpu=x86-64-v4` — the exact trap the tier4 CI job hit. Clearing
30+
# it lets the config win.
31+
#
32+
# What you get INSTEAD is not v3 (corrected 2026-09-16, coderabbit on #314;
33+
# this comment said "would measure v3"). RUSTFLAGS replaces EVERY entry,
34+
# including the DEFAULT `.cargo/config.toml`'s own `-Ctarget-cpu`, so no
35+
# target-cpu reaches rustc at all and the build lands on rustc's generic
36+
# `x86-64` baseline — SSE2, BELOW v3, and the tier `simd_avx2.rs`'s
37+
# intrinsics SIGILL on. Measured on one unit: `RUSTFLAGS="-D warnings"`
38+
# emitted ZERO `-Ctarget-cpu` flags against 65 with the env unset.
39+
#
40+
# This arm NAMES NO TIER by design: it builds with whatever config wins,
41+
# which by default is `target-cpu=native` (the host). Read the program's
42+
# own `avx512f=` header line for the tier; pin `.cargo/config-v3.toml`
43+
# through CARGO_ARGS when you specifically want AVX2.
3144
env -u RUSTFLAGS cargo ${CARGO_ARGS:-} build --release --manifest-path "$MANIFEST" --bin simd-masking-parity
3245
"$TD/release/simd-masking-parity"
3346
;;

0 commit comments

Comments
 (0)