Skip to content

fix(build): stop the Makefile from overwriting the caller's RUSTFLAGS - #3688

Merged
inureyes merged 1 commit into
mainfrom
fix/3682-makefile-rustflags
Dec 2, 2026
Merged

inureyes merged 1 commit into
mainfrom
fix/3682-makefile-rustflags

Conversation

@inureyes

@inureyes inureyes commented Dec 2, 2026

Copy link
Copy Markdown
Member

Makefile:28 defined RUSTFLAGS := RUSTFLAGS="-C target-cpu=native" as a prefix for the release build lines. Because GNU make exports a variable that shadows an environment variable, any caller with RUSTFLAGS set had it replaced in every recipe by that literal string. The OpenXLA feature compile job sets RUSTFLAGS: "-D warnings" and, since #3636, runs make verify-clippy-xla, so rustc got RUSTFLAGS="-C as an input file name and the job has failed on main and every PR since 59f281bde.

  • The prefix is renamed to NATIVE_RUSTFLAGS; the five release recipes use it and make -n release still prints RUSTFLAGS="-C target-cpu=native" cargo build --release.
  • scripts/ci/makefile_env_passthrough_test.sh checks RUSTFLAGS and RUSTDOCFLAGS reach recipes unchanged when set, stay unset when not, and that the release prefix survives. It runs as make verify-makefile-env (part of make verify), in the unfiltered env-var-docs job, and in the OpenXLA job before the clippy step.
  • No other Makefile variable shadows a cargo or rustc environment variable.

Validation: the guard fails against the old Makefile (RUSTFLAGS='-D warnings' reached recipes as 'RUSTFLAGS="-C target-cpu=native"') and passes on this branch. RUSTFLAGS="-D warnings" make verify-clippy-xla passes locally on GB10, so restoring -D warnings to the job surfaces no new Rust warnings.

Closes #3682

The Makefile defined `RUSTFLAGS := RUSTFLAGS="-C target-cpu=native"` as a command prefix for the release builds. GNU make exports a variable that shadows an environment variable, so whenever RUSTFLAGS was set in the environment every recipe saw the literal string `RUSTFLAGS="-C target-cpu=native"`. The OpenXLA CI job sets RUSTFLAGS=-D warnings and, since #3636, lints through `make verify-clippy-xla`, so rustc received `RUSTFLAGS="-C` as an input file name and the job failed on main and every PR; the job's -D warnings was also lost.

The prefix is renamed to NATIVE_RUSTFLAGS and the five release recipes use it, so `make -n release` still shows the native-CPU prefix. A new guard, scripts/ci/makefile_env_passthrough_test.sh, checks that RUSTFLAGS and RUSTDOCFLAGS reach recipes unchanged when set and stay unset otherwise, and that the release prefix survives. It is exposed as `make verify-makefile-env`, included in `make verify`, and runs in the unfiltered env-var-docs job and in the OpenXLA job before the clippy step.

Validated: the guard fails against the old Makefile and passes now, and `RUSTFLAGS="-D warnings" make verify-clippy-xla` passes locally on GB10.

Closes #3682
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:high High priority labels Dec 2, 2026
@inureyes
inureyes merged commit 97b63a2 into main Dec 2, 2026
36 checks passed
@inureyes inureyes added status:done Completed and removed status:review Under review labels Dec 2, 2026
@inureyes
inureyes deleted the fix/3682-makefile-rustflags branch December 2, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high High priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Makefile RUSTFLAGS variable breaks make verify-clippy-xla in CI

1 participant