Repository navigation
fix(release): keep macos pgo instrumentation rust-only - #11129
Conversation
The cc crate mirrors -Cprofile-generate/-Cprofile-use from RUSTFLAGS into C compiler flags, so vendored C code (openssl, lua) was being instrumented by Apple clang, whose profile-runtime format follows Xcode's LLVM rather than rustc's. On the release runners (Xcode 16, raw profile version 8) this clashes with rustc 1.97 (version 10) and every profile write aborted with: LLVM Profile Error: Runtime and instrumentation version mismatch leaving zero .profraw files and failing build-tarball-macos-arm64 on every release since PGO landed. Override with -fno-profile-generate/ -fno-profile-use via CFLAGS/CXXFLAGS, which cc appends after the rustc-inherited flags. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PGO script now detects macOS and disables Rust/cc profiling instrumentation for C and C++ compilation by adding compiler flags to ChangesmacOS PGO instrumentation
Estimated code review effort: 1 (Trivial) | ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis fix resolves a macOS release-tarball regression introduced when PGO landed: the
Confidence Score: 5/5Safe to merge — the change is a minimal, targeted two-line export guarded by uname -s, validated with a full end-to-end run on the actual CI runner. The fix is two lines, Darwin-only, validated end-to-end on the real runner (54 profraw collected, optimized binary produced). Linux PGO is unaffected. The only finding is a cosmetic leading-space nit. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(release): keep macos pgo instrumenta..." | Re-trigger Greptile |
| export CFLAGS="${CFLAGS:-} -fno-profile-generate -fno-profile-use" | ||
| export CXXFLAGS="${CXXFLAGS:-} -fno-profile-generate -fno-profile-use" |
There was a problem hiding this comment.
When
CFLAGS (or CXXFLAGS) is unset, ${CFLAGS:-} expands to an empty string, so the exported value begins with a leading space (e.g., -fno-profile-generate -fno-profile-use). This is harmless for clang/gcc in practice, but the ${VAR:+$VAR } idiom avoids it cleanly.
| export CFLAGS="${CFLAGS:-} -fno-profile-generate -fno-profile-use" | |
| export CXXFLAGS="${CXXFLAGS:-} -fno-profile-generate -fno-profile-use" | |
| export CFLAGS="${CFLAGS:+$CFLAGS }-fno-profile-generate -fno-profile-use" | |
| export CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }-fno-profile-generate -fno-profile-use" |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.7.7 x -- echo |
23.3 ± 1.5 | 20.5 | 30.4 | 1.00 |
mise x -- echo |
24.1 ± 1.5 | 19.8 | 29.4 | 1.04 ± 0.09 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.7.7 env |
24.2 ± 1.5 | 20.1 | 31.3 | 1.03 ± 0.09 |
mise env |
23.5 ± 1.5 | 19.4 | 29.0 | 1.00 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.7.7 hook-env |
25.4 ± 1.5 | 21.3 | 30.6 | 1.05 ± 0.10 |
mise hook-env |
24.2 ± 1.7 | 20.2 | 30.5 | 1.00 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.7.7 ls |
22.3 ± 1.6 | 17.9 | 29.0 | 1.04 ± 0.12 |
mise ls |
21.4 ± 1.9 | 16.7 | 28.2 | 1.00 |
xtasks/test/perf
| Command | mise-2026.7.7 | mise | Variance |
|---|---|---|---|
| install (cached) | 199ms | 201ms | +0% |
| ls (cached) | 83ms | 79ms | +5% |
| bin-paths (cached) | 84ms | 85ms | -1% |
| task-ls (cached) | 171ms | 170ms | +0% |
Fixes the
build-tarball-macos-arm64failure that has broken every release since PGO landed in #11031:Root cause
The
cccrate mirrors-Cprofile-generate/-Cprofile-usefrom RUSTFLAGS onto the C compiler command line (-fprofile-generate/-fprofile-use). The macOS tarball builds vendored C code (openssl/vendored,vfox/vendored-lua), so those objects were instrumented by Apple clang, whose profile format follows Xcode's LLVM — not rustc's:profiler_builtins→ raw profile version 10At link, the C objects' version-8
__llvm_profile_raw_versionwon symbol coalescing (verified in the CI-built binary:__TEXT,__constvalue0x…08), while the Rust profile runtime doing the writes expects 10 → every profile write aborts → training produces zero.profrawfiles.This is why #11071 (toolchain pinning) couldn't fix it — the rogue instrumentation comes from the C compiler, not a mismatched rust toolchain — and why it doesn't reproduce on machines where Xcode's LLVM happens to match rustc's generation (e.g. clang 21 also uses version 10).
Fix
Export
-fno-profile-generate -fno-profile-useviaCFLAGS/CXXFLAGSon Darwin inscripts/pgo.bash.ccappends environment flags after the rustc-inherited ones, so the overrides win and PGO stays Rust-only. C-side PGO could never work here anyway: Apple clang 16 can't consume profdata merged by rustup's LLVM-22llvm-profdata, so phase 3b would have failed next.Linux PGO is untouched (it's green today; gcc's gcov-style flags don't hit this conflict).
Validation
Ran on the actual
namespace-profile-endev-macos-arm64runner viaworkflow_dispatchon this branch (with the release workflow temporarily trimmed to the macOS tarball path, since tarball jobs don't run on regular PRs):MISE_PGO=1 scripts/build-tarball.sh aarch64-apple-darwinincl. codesigning): run 29762962943 — ✅ 54.profrawcollected, 84.5 MB merged profile, optimized rebuild, signed tarballs producedNote: the
cargo-releaseregistry failure on the release branch is a separate issue (upstream re-publishedv1.1.0with incomplete assets, so/releases/latestresolves to a release with no Linux builds) and is not addressed here.🤖 Generated with Claude Code
Note
Low Risk
Small, Darwin-only change to release build flags; Linux PGO is untouched and the override is documented to win over inherited profile flags.
Overview
Fixes macOS PGO release builds that failed during training with an LLVM profile runtime/instrumentation version mismatch and zero
.profrawfiles.On Darwin,
scripts/pgo.bashnow exportsCFLAGS/CXXFLAGSwith-fno-profile-generateand-fno-profile-usebefore the instrumented build. That stops thecccrate from forwarding rustc’s PGO flags to Apple clang for vendored C (e.g. OpenSSL, Lua), so only Rust stays instrumented and profile writes succeed. Linux behavior is unchanged.Reviewed by Cursor Bugbot for commit 03bdfa3. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit