Skip to content

Let builds choose where gen-compile-cache runs - #8969

Merged
danlapid merged 1 commit into
mainfrom
dlapid/compile-cache-target-arch
Nov 28, 2026
Merged

danlapid merged 1 commit into
mainfrom
dlapid/compile-cache-target-arch

Conversation

@danlapid

@danlapid danlapid commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

gen-compile-cache is built for the target platform (cfg = "target"), since only the target's V8 accepts the caches it writes. In a cross-compiling build, the execution platform Bazel picks for it may not be able to run it, and the only way around that was to run it locally.

This gives the compile cache rule an optional toolchain of a new type, //build/config:compile_cache_executor_toolchain_type. None is registered by default, so nothing changes for existing builds. A build that has an execution platform able to run the tool can register a toolchain of this type, for example @bazel_tools//tools/test:empty_toolchain with exec_compatible_with and target_compatible_with set to the target's CPU. The compile cache actions then run on that platform, and everything else stays on the platform Bazel would have picked anyway.

A toolchain is the hook because exec_compatible_with can't be configured with select(), and a target's exec properties can only pick between executors of a platform it already runs on.

🤖 Generated with Claude Code

@danlapid
danlapid force-pushed the dlapid/compile-cache-target-arch branch from 52d7529 to de67e0f Compare November 28, 2026 06:13
gen-compile-cache is built for the target platform, since only the
target's V8 accepts the caches it writes. In a cross-compiling build
the execution platform Bazel picks for it may not be able to run it,
and the only way to change that was to run it locally.

The compile cache rule now takes an optional toolchain of a new type,
compile_cache_executor_toolchain_type. None is registered by default,
so nothing changes unless a build registers one, whose
exec_compatible_with then picks the execution platform the tool runs
on, such as one with the target's CPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@danlapid
danlapid force-pushed the dlapid/compile-cache-target-arch branch from de67e0f to 1f6d6e7 Compare November 28, 2026 06:27
@danlapid danlapid changed the title Run gen-compile-cache on arm64 executors in arm64 bazelflare builds Let builds choose where gen-compile-cache runs Nov 28, 2026
@danlapid
danlapid marked this pull request as ready for review November 28, 2026 06:29
@danlapid
danlapid requested review from a team as code owners November 28, 2026 06:29

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — This is a small, opt-in Bazel hook. Nothing changes for existing builds, and no issues were found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security concerns. The change touches only Bazel toolchain resolution for a build action.


📋 Code Quality: ✅ LGTM

The optional toolchain (mandatory = False) affects only how Bazel picks the execution platform for _gen_compile_cache. With no toolchain of this type registered, the choice is the same as before. cfg = "target" and run_shell are unchanged, so V8 is still built only once.


📝 Documentation: ✅ LGTM

The comment on the new toolchain_type explains why the hook exists, what happens by default, and how a build registers a toolchain for it, using @bazel_tools//tools/test:empty_toolchain constrained to the target's CPU as the example.


Reviewed commit: 1f6d6e78

@danlapid
danlapid merged commit 0006aba into main Nov 28, 2026
25 checks passed
@danlapid
danlapid deleted the dlapid/compile-cache-target-arch branch November 28, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant