ci(build): restore -C target-cpu=x86-64-v3 on published x86_64 builds (#20) #22

Merged
pbwraith merged 1 commits from issue-20 into main 2026-08-26 08:45:19 +02:00
Owner

Restore -C target-cpu=x86-64-v3 for the published x86_64 release builds

!17 (#16) made the AVX2/BMI2 baseline opt-in via RUSTFLAGS and removed it
from .cargo/config.toml, but no workflow set it — so every release binary
silently compiled at the plain x86-64 baseline. This PR sets RUSTFLAGS per
matrix row on the two x86_64 entries only:

  • build-linux, x86_64-unknown-linux-gnu (artifact gopher64-linux-x86_64):
    RUSTFLAGS="-C target-cpu=x86-64-v3"
  • build-windows, x86_64-pc-windows-msvc (artifact gopher64-windows-x86_64.exe):
    RUSTFLAGS="-C target-cpu=x86-64-v3 -C link-arg=/STACK:8388608"
    — the Windows row carries the 8 MB stack link-arg across because
    RUSTFLAGS REPLACES the config's rustflags rather than appending
    (the trap !17 documents at .cargo/config.toml:31).

Implementation note: the flags are applied by a small if: step that writes
RUSTFLAGS into $GITHUB_ENV only when matrix.target is the x86_64 row.
Deliberately NOT a RUSTFLAGS: ${{ matrix.rustflags }} env on the Build step:
an empty-string RUSTFLAGS (what an undefined matrix key evaluates to) also
REPLACES config rustflags, which would silently drop the aarch64-rows'
-fuse-ld=lld / /STACK:8388608 link-args. The aarch64 / macOS / android
jobs are therefore byte-identical to main.

Verification

  • grep -rc RUSTFLAGS .github/workflows/build.yml → 9 (non-zero).
  • grep -rc RUSTFLAGS .github/workflows/lint.yml / sec.yml → 0 / 0; the only
    RUSTFLAGS= lines in build.yml are the two new steps
    (.github/workflows/build.yml:78 linux, :134 windows).
  • The two intended payloads, verbatim:
    • linux: echo "RUSTFLAGS=-C target-cpu=x86-64-v3" >> $GITHUB_ENV
    • windows: echo "RUSTFLAGS=-C target-cpu=x86-64-v3 -C link-arg=/STACK:8388608" >> $env:GITHUB_ENV
  • .cargo/config.toml is byte-identical to origin/main (git diff origin/main -- .cargo/config.toml is empty — acceptance criterion 3).
  • Flag strings validated end-to-end on a cargo 1.98.0 toolchain:
    RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build -v → the rustc invocation
    carries -C target-cpu=x86-64-v3; and rustc -C target-cpu=x86-64-v3 -C link-arg=/STACK:8388608 --print cfg parses both flags cleanly (no errors).
  • git diff --check clean; workflow YAML parses (jobs: unchanged list:
    build-linux, build-windows, build-macos, build-android, collect-artifacts).

Out of scope per the issue: .cargo/config.toml left alone (including the
x86-64-v2 comment, which would require touching that file), aarch64/macOS
entries untouched, default baseline decision unchanged.

Closes #20

## Restore `-C target-cpu=x86-64-v3` for the published x86_64 release builds `!17` (#16) made the AVX2/BMI2 baseline opt-in via `RUSTFLAGS` and removed it from `.cargo/config.toml`, but no workflow set it — so every release binary silently compiled at the plain x86-64 baseline. This PR sets `RUSTFLAGS` per matrix row on the **two x86_64 entries only**: - `build-linux`, `x86_64-unknown-linux-gnu` (artifact `gopher64-linux-x86_64`): `RUSTFLAGS="-C target-cpu=x86-64-v3"` - `build-windows`, `x86_64-pc-windows-msvc` (artifact `gopher64-windows-x86_64.exe`): `RUSTFLAGS="-C target-cpu=x86-64-v3 -C link-arg=/STACK:8388608"` — the Windows row carries the 8 MB stack link-arg across because `RUSTFLAGS` REPLACES the config's rustflags rather than appending (the trap `!17` documents at `.cargo/config.toml:31`). Implementation note: the flags are applied by a small `if:` step that writes `RUSTFLAGS` into `$GITHUB_ENV` only when `matrix.target` is the x86_64 row. Deliberately NOT a `RUSTFLAGS: ${{ matrix.rustflags }}` env on the Build step: an empty-string `RUSTFLAGS` (what an undefined matrix key evaluates to) also REPLACES config rustflags, which would silently drop the aarch64-rows' `-fuse-ld=lld` / `/STACK:8388608` link-args. The aarch64 / macOS / android jobs are therefore byte-identical to `main`. ## Verification - `grep -rc RUSTFLAGS .github/workflows/build.yml` → **9** (non-zero). - `grep -rc RUSTFLAGS .github/workflows/lint.yml` / `sec.yml` → 0 / 0; the only `RUSTFLAGS=` lines in `build.yml` are the two new steps (`.github/workflows/build.yml:78` linux, `:134` windows). - The two intended payloads, verbatim: - linux: `echo "RUSTFLAGS=-C target-cpu=x86-64-v3" >> $GITHUB_ENV` - windows: `echo "RUSTFLAGS=-C target-cpu=x86-64-v3 -C link-arg=/STACK:8388608" >> $env:GITHUB_ENV` - `.cargo/config.toml` is byte-identical to `origin/main` (`git diff origin/main -- .cargo/config.toml` is empty — acceptance criterion 3). - Flag strings validated end-to-end on a cargo 1.98.0 toolchain: `RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build -v` → the rustc invocation carries `-C target-cpu=x86-64-v3`; and `rustc -C target-cpu=x86-64-v3 -C link-arg=/STACK:8388608 --print cfg` parses both flags cleanly (no errors). - `git diff --check` clean; workflow YAML parses (`jobs:` unchanged list: build-linux, build-windows, build-macos, build-android, collect-artifacts). Out of scope per the issue: `.cargo/config.toml` left alone (including the x86-64-v2 comment, which would require touching that file), aarch64/macOS entries untouched, default baseline decision unchanged. Closes #20
pbwraith added 1 commit 2026-08-26 04:53:08 +02:00
ci(build): restore -C target-cpu=x86-64-v3 on published x86_64 builds
Some checks failed
Rust / build-linux (linux-x86_64, X64, ubuntu-24.04, x86_64-unknown-linux-gnu) (pull_request) Failing after 4s
Rust / build-android (29.0.14206865, ubuntu-24.04, 33) (pull_request) Failing after 3s
Rust-lint / lint-linux (pull_request) Failing after 15s
Rust / build-linux (linux-aarch64, ARM64, ubuntu-24.04-arm, aarch64-unknown-linux-gnu) (pull_request) Has been cancelled
Rust / build-windows (windows-aarch64, woa64, windows-11-arm, aarch64-pc-windows-msvc) (pull_request) Has been cancelled
Rust / build-windows (windows-x86_64, win64, windows-2025, x86_64-pc-windows-msvc) (pull_request) Has been cancelled
Rust / build-macos (macos-aarch64, ARM64, aarch64-apple-darwin) (pull_request) Has been cancelled
Rust / Collect release artifacts (pull_request) Has been cancelled
f56f42a3e8
Issue #20: !17 (#16) made the x86-64-v3 baseline opt-in via RUSTFLAGS but
nothing set it, so release binaries silently fell back to the plain x86-64
baseline. Set RUSTFLAGS per matrix row on the two x86_64 entries only:

- linux  x86_64-unknown-linux-gnu: -C target-cpu=x86-64-v3
- windows x86_64-pc-windows-msvc: -C target-cpu=x86-64-v3
  -C link-arg=/STACK:8388608 (carries the 8 MB stack link-arg that the
  repo config supplies for Windows, because RUSTFLAGS REPLACES config
  rustflags rather than appending)

The aarch64 rows keep the config's link-args untouched (no RUSTFLAGS at
all), and macOS / android jobs plus .cargo/config.toml are unchanged.

Closes #20
Author
Owner

Merged - and it gets the RUSTFLAGS-replacement trap right

Restores -C target-cpu=x86-64-v3 for published x86_64 artifacts only, set
per matrix row in CI rather than in .cargo/config.toml.

The load-bearing detail, which this PR handles correctly: RUSTFLAGS
replaces the config's rustflags wholesale
, it does not append. So the
Windows row must carry the stack link-arg alongside the CPU flag, and it does:

RUSTFLAGS=-C target-cpu=x86-64-v3 -C link-arg=/STACK:8388608

Dropping that /STACK:8388608 would have silently cut the Windows binary's
main-thread stack from 8 MiB back to the default -- which matters more than it
looks: size_of::<Device>() is 307,968 bytes and this repo genuinely needs
that headroom (see #23). The aarch64 rows are correctly left without any
RUSTFLAGS, so their -fuse-ld=lld link-arg survives.

Keeps #16's portability fix intact: the default build stays x86-64-v2 for the
Sandy Bridge review box, and the optimised baseline stays opt-in.

Gate, against the composed MERGE RESULT

Not each PR alone -- main + !21 + !22 + !14 merged into one warm clone on the
review box (WSL), then ./scripts/gate.sh:

GATE step 1/3: cargo check --all-targets
GATE step 2/3: cargo test --no-run
GATE step 3/3: cargo test --lib
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; finished in 57.65s
GATE_OK

Control on origin/main @ 8a46ac5 in the same clone: gate_exit=0, but
step 3 ran 0 tests. So this set also makes gate step 3 non-vacuous for the
first time -- 0 -> 4 real tests.

## Merged - and it gets the RUSTFLAGS-replacement trap right Restores `-C target-cpu=x86-64-v3` for published x86_64 artifacts only, set per matrix row in CI rather than in `.cargo/config.toml`. The load-bearing detail, which this PR handles correctly: **`RUSTFLAGS` replaces the config's rustflags wholesale**, it does not append. So the Windows row must carry the stack link-arg alongside the CPU flag, and it does: ```yaml RUSTFLAGS=-C target-cpu=x86-64-v3 -C link-arg=/STACK:8388608 ``` Dropping that `/STACK:8388608` would have silently cut the Windows binary's main-thread stack from 8 MiB back to the default -- which matters more than it looks: `size_of::<Device>()` is 307,968 bytes and this repo genuinely needs that headroom (see #23). The aarch64 rows are correctly left without any `RUSTFLAGS`, so their `-fuse-ld=lld` link-arg survives. Keeps #16's portability fix intact: the default build stays x86-64-v2 for the Sandy Bridge review box, and the optimised baseline stays opt-in. ### Gate, against the composed MERGE RESULT Not each PR alone -- `main` + !21 + !22 + !14 merged into one warm clone on the review box (WSL), then `./scripts/gate.sh`: ``` GATE step 1/3: cargo check --all-targets GATE step 2/3: cargo test --no-run GATE step 3/3: cargo test --lib test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; finished in 57.65s GATE_OK ``` Control on `origin/main` @ `8a46ac5` in the same clone: `gate_exit=0`, but step 3 ran **0 tests**. So this set also makes gate step 3 non-vacuous for the first time -- 0 -> 4 real tests.
pbwraith merged commit f0d0fc370f into main 2026-08-26 08:45:19 +02:00
This repo is archived. You cannot comment on pull requests.
No description provided.