fix(perf): refuse compiler overrides in build-at-ref (#10965)
Closes #10965
build-at-ref.sh now exits 1 when the binary would come from a compiler other than the ref's toolchain. That also makes --rustc-out (#10751) record the compiler that actually built it.
- Env:
RUSTC,RUSTC_WRAPPER,RUSTC_WORKSPACE_WRAPPER,RUSTUP_TOOLCHAIN,RUSTC_BOOTSTRAPand theCARGO_BUILD_*forms are refused before any worktree is created. An empty wrapper,RUSTUP_TOOLCHAINorRUSTC_BOOTSTRAPmeans no override, and an emptyRUSTC_*WRAPPERcancels itsCARGO_BUILD_*counterpart, as in cargo. - Config: after checkout,
--injectand--patch, the script asks cargo for its resolved config (cargo -Z unstable-options config get, withRUSTC_BOOTSTRAP=1for that query only) and refusesbuild.rustc,build.rustc-wrapperorbuild.rustc-workspace-wrapper. The message names the file. If the query fails, the build is refused. On a non-nightly cargo the query dropsCARGO_UNSTABLE_*and an[unstable]table is refused, because the stable build ignores them while the bootstrapped query would apply them (reproduced on cargo 1.90).
Rebased onto main after #10751. The only conflict was the --help line range.
Testing: node --test scripts/perf/build-at-ref.test.mjs passes 30/30, including with CI=1 and RUSTC_WRAPPER=sccache exported. The tests cover every env name and each empty-wrapper pairing, each config key in all TOML string forms, CARGO_HOME, ancestor and injected config, the fail-closed path, and the empty-wrapper pass path. Mutation runs confirmed each branch is covered. ShellCheck is clean at warning level. #10751's cache-stream-report.test.mjs still passes. I checked cargo's empty-wrapper precedence by hand with real builds.
Out of scope:
ab.shanddm-e2e-abbuild the branch side before calling this script.- RUSTFLAGS and
CARGO_PROFILE_*still pass through. - A cargo earlier on PATH than rustup is not detected.
- A relative
--worktree-rootbreaks the run, but no caller passes one.
All four were true before this change.
This PR is not critical, so it got an independent reviewer instead of paid CodeRabbit.
š¤ Generated with Claude Code
Summary by CodeRabbit
- Bug Fixes
- Performance builds now stop when compiler overrides are configured through environment variables or Cargo settings, helping prevent builds from using an unexpected compiler.
- Failures to determine or record the compiler version now return an error.
- Documentation
- Help text now explains compiler override checks and compiler-version recording.