Declare a "scalac" exec_group so per-action cpu sizing can be set#1842
Open
gergelyfabian wants to merge 1 commit into
Open
Declare a "scalac" exec_group so per-action cpu sizing can be set#1842gergelyfabian wants to merge 1 commit into
gergelyfabian wants to merge 1 commit into
Conversation
Adds an empty `exec_group("scalac")` to every scala rule that compiles
Scala sources (scala_library, scala_library_for_plugin_bootstrapping,
scala_macro_library, scala_binary, scala_test, scala_junit_test,
scala_repl) and wires the Scalac action to it via
`exec_group = "scalac"` in `compile_scala`. Also declares the same
exec_group on the two aspects that call `compile_scala`
(scrooge_scala_aspect, scala_proto_aspect) — aspects do not inherit
exec_groups from the rule they attach to, so they need their own
declaration.
The group is intentionally empty (no toolchains / no
exec_compatible_with) — its sole purpose is to be a target for the
`<group>.<key>` syntax on `exec_properties`. This lets a user set
`exec_properties = {"scalac.<key>": "<value>"}` on a target to
configure the compile action independently of the target's other
actions (test execution, jar packaging, etc.). Without a declared
exec_group, Bazel rejects the prefixed key at analysis time.
The action's toolchain resolution and exec platform selection are
unchanged: no toolchains or constraints are attached to the group,
so the rule's default toolchains still apply to the Scalac action.
`scala_proto_library` and `scrooge_scala_library` intentionally do not
declare the exec_group on the top-level rule: Bazel does not propagate
target-level `exec_properties` to actions created by attached aspects,
so declaring it there would silently drop the user's config. The
analysis-time error surfaces the limitation; users needing per-action
config for these rules should set exec_properties at the platform
level.
Regression coverage:
- //test:ScalacExecGroup* targets set a scalac.* exec_property on each
of the seven rules that support the feature. Removing the rule's
exec_group declaration fails analysis on these targets under `bazel
build test/...`.
- test/shell/test_scalac_exec_group.sh uses `bazel aquery` to verify
the property reaches the Scalac action's ExecutionInfo on every
regression target, catching removal of `exec_group = "scalac"` from
`ctx.actions.run` in compile_scala (which would silently reroute the
property to the default exec group without failing analysis).
- //test_expect_failure/scalac_exec_group_on_aspect_rule/... exercises
the intentional gap on scala_proto_library and scrooge_scala_library;
the same shell test asserts both fail analysis with the expected
"non-existent exec groups: scalac" message, so the docs' claim stays
honest if Bazel changes behavior or someone adds the exec_group to
those rules.
Documents the feature and the aspect-propagation limitation under
docs/scalac_exec_group.md.
gergelyfabian
requested review from
WojciechMazur,
mbland and
simuons
as code owners
July 1, 2026 05:58
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.
Adds an empty
exec_group("scalac")to every scala rule that compiles Scala sources (scala_library, scala_library_for_plugin_bootstrapping, scala_macro_library, scala_binary, scala_test, scala_junit_test, scala_repl) and wires the Scalac action to it viaexec_group = "scalac"incompile_scala. Also declares the same exec_group on the two aspects that callcompile_scala(scrooge_scala_aspect, scala_proto_aspect) — aspects do not inherit exec_groups from the rule they attach to, so they need their own declaration.The group is intentionally empty (no toolchains / no exec_compatible_with) — its sole purpose is to be a target for the
<group>.<key>syntax onexec_properties. This lets a user setexec_properties = {"scalac.<key>": "<value>"}on a target to configure the compile action independently of the target's other actions (test execution, jar packaging, etc.). Without a declared exec_group, Bazel rejects the prefixed key at analysis time.The action's toolchain resolution and exec platform selection are unchanged: no toolchains or constraints are attached to the group, so the rule's default toolchains still apply to the Scalac action.
scala_proto_libraryandscrooge_scala_libraryintentionally do not declare the exec_group on the top-level rule: Bazel does not propagate target-levelexec_propertiesto actions created by attached aspects, so declaring it there would silently drop the user's config. The analysis-time error surfaces the limitation; users needing per-action config for these rules should set exec_properties at the platform level.Regression coverage:
bazel build test/....bazel aqueryto verify the property reaches the Scalac action's ExecutionInfo on every regression target, catching removal ofexec_group = "scalac"fromctx.actions.runin compile_scala (which would silently reroute the property to the default exec group without failing analysis).Documents the feature and the aspect-propagation limitation under docs/scalac_exec_group.md.