You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Guard and document the macOS/Linux native-linker override and ThinLTO - #418
Adds //python:ci_macos_native_linker_test, a regression guard for the extra_link_flags/extra_link_libs/supports_start_end_lib mechanism that routes native Darwin/Linux links through the host linker (deb44608, 20d97b4d, 85770509) — this had no test coverage, unlike the apple_support ASAN patches (ci_macos_asan_test).
Verifies and documents that swapping macOS's link driver from ld64.lld to Apple's native /usr/bin/ld does not silently break the -flto=thin ThinLTO invariant: built and linked a real target on Xcode 27.0 / macOS 26.6.2 with -v, confirmed Apple's linker (ld-27037.1) reports built-in LTO support for LLVM 21 bitcode without needing the classic -lto_library plugin flag. Added one new test assertion plus a doc paragraph (docs/BUILD_SYSTEM.md) so a future regression here doesn't go unnoticed.
Brings specs/build-system.md's "Toolchains are hermetic" invariant up to date: it already documented the Linux linker exception but not the macOS one, and didn't mention the two apple_support patches under "Key entry points".
Why this is separate from the v3.1.1 release PR
This is pure test/doc polish discovered while backporting the macOS 27 fix to a release/v3.1.1 branch for main (see #417) — it doesn't change any build behavior, so it goes straight to develop rather than through the release branch.
Test plan
bazelisk test //library/... //python/... — 87/87 pass
New test (ci_macos_native_linker_test) passes against develop's existing MODULE.bazel/.bazelrc/CPPVARIABLES.bzl as-is (pure regression guard, nothing to fix)
Adds a regression test for the extra_link_flags/extra_link_libs/
supports_start_end_lib mechanism (no prior guard existed for it, unlike
the apple_support ASAN patches), verifies and documents that Apple's
current linker still performs ThinLTO without an explicit -lto_library
plugin flag, and brings specs/build-system.md's hermeticity invariant
up to date with the macOS/Linux linker exceptions already shipped.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Narrow the new ThinLTO test's name/docstring: it only guards that
-flto=thin stays requested, not that cross-TU optimization actually
happens — a future linker could keep accepting the flag while silently
dropping the optimization, and this test can't catch that.
- Fix the LTO verification command in docs/BUILD_SYSTEM.md: plain
`bazel build -s`/`-v` never reach the linker's own stderr banner;
`--linkopt=-Wl,-v` is needed to forward -v through clang to the linker.
- Scope the macOS hermeticity bullet in specs/build-system.md to the
default toolchain and call out that --config=asan switches compilation
itself (not just the link) to the installed Xcode toolchain.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Renamed/clarified test_macos_keeps_thin_lto_at_compile_and_link → test_macos_requests_thin_lto_flags_at_compile_and_link; docstring now states explicitly it only guards that -flto=thin stays requested, not that cross-TU optimization actually occurs.
docs/BUILD_SYSTEM.md: fixed the verification command to bazel build --linkopt=-Wl,-v //path:target, since plain -s/-v never reach the linker's own banner.
specs/build-system.md: scoped the hermeticity bullet to the default toolchain and called out that --config=asan switches macOS compilation itself (not just the link) to the installed Xcode toolchain.
Didn't add a full cross-TU LTO integration fixture — building a fixture that reliably detects whether the linker actually performed cross-TU inlining (vs. just accepted the flag) is a meaningfully bigger, more fragile piece of infrastructure than this polish PR's scope, and the doc already documents the manual verification procedure (now corrected) as the mitigation for that gap.
This still overstates hermeticity: the compiler binary comes from toolchains_llvm, but it compiles against the installed Xcode SDK, whose .tbd inputs are the reason this override is needed (docs/BUILD_SYSTEM.md:56-76). Describe both the SDK and linker as host inputs so the reproducibility invariant is accurate.
Remove hard-coded dependency version
specs/build-system.md:114
This hard-codes an exact dependency version immediately after the spec says exact versions live only in MODULE.bazel and drift (lines 71-72). Remove the version here so this entry does not become stale on the next apple_support bump.
- Use bazelisk (not bare bazel) in the LTO verification commands, matching
the rest of docs/BUILD_SYSTEM.md.
- specs/build-system.md: the macOS hermeticity bullet now names the
installed SDK, not just the linker, as a host input — compilation reads
the host SDK's headers/.tbd stubs even on the default toolchain.
- specs/build-system.md: drop the hard-coded apple_support 1.24.2 version
from Key entry points; exact versions live only in MODULE.bazel per this
spec's own dependency-graph bullet.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Switched the LTO verification commands to `bazelisk` (was bare `bazel`), matching the rest of the doc.
`specs/build-system.md`: the hermeticity bullet now calls out the installed macOS SDK itself as a host input (compilation reads its headers/`.tbd` stubs), not just the linker.
`specs/build-system.md`: removed the hard-coded `apple_support 1.24.2` version from Key entry points — versions live only in `MODULE.bazel` per this spec's own rule.
24/24 `//python/...` tests pass (doc/spec-only change, no behavior touched).
"macOS keeps requesting ThinLTO" read as an assertion of fact rather than
a description of what the test checks. Spell out that this only guards
flag presence in CPPVARIABLES.bzl, not that the linker actually performs
cross-TU optimization — matching the test method's own docstring.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
Clean Copilot reviewCopilot reviewed and had neither new comments nor new suppressed comments.
3 participants
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.
Summary
//python:ci_macos_native_linker_test, a regression guard for theextra_link_flags/extra_link_libs/supports_start_end_libmechanism that routes native Darwin/Linux links through the host linker (deb44608,20d97b4d,85770509) — this had no test coverage, unlike theapple_supportASAN patches (ci_macos_asan_test).ld64.lldto Apple's native/usr/bin/lddoes not silently break the-flto=thinThinLTO invariant: built and linked a real target on Xcode 27.0 / macOS 26.6.2 with-v, confirmed Apple's linker (ld-27037.1) reports built-in LTO support for LLVM 21 bitcode without needing the classic-lto_libraryplugin flag. Added one new test assertion plus a doc paragraph (docs/BUILD_SYSTEM.md) so a future regression here doesn't go unnoticed.specs/build-system.md's "Toolchains are hermetic" invariant up to date: it already documented the Linux linker exception but not the macOS one, and didn't mention the twoapple_supportpatches under "Key entry points".Why this is separate from the v3.1.1 release PR
This is pure test/doc polish discovered while backporting the macOS 27 fix to a
release/v3.1.1branch formain(see #417) — it doesn't change any build behavior, so it goes straight todeveloprather than through the release branch.Test plan
bazelisk test //library/... //python/...— 87/87 passci_macos_native_linker_test) passes against develop's existingMODULE.bazel/.bazelrc/CPPVARIABLES.bzlas-is (pure regression guard, nothing to fix)🤖 Generated with Claude Code