Repository navigation
fix(build): stop the Makefile from overwriting the caller's RUSTFLAGS - #3688
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makefile:28definedRUSTFLAGS := 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 setsRUSTFLAGS: "-D warnings"and, since #3636, runsmake verify-clippy-xla, so rustc gotRUSTFLAGS="-Cas an input file name and the job has failed on main and every PR since59f281bde.NATIVE_RUSTFLAGS; the five release recipes use it andmake -n releasestill printsRUSTFLAGS="-C target-cpu=native" cargo build --release.scripts/ci/makefile_env_passthrough_test.shchecks RUSTFLAGS and RUSTDOCFLAGS reach recipes unchanged when set, stay unset when not, and that the release prefix survives. It runs asmake verify-makefile-env(part ofmake verify), in the unfiltered env-var-docs job, and in the OpenXLA job before the clippy step.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-xlapasses locally on GB10, so restoring -D warnings to the job surfaces no new Rust warnings.Closes #3682