Skip to content

Conversation

@brentleyjones
Copy link
Collaborator

This updates the following APIs:

  • swift_common.get_toolchain now takes an exec_group argument, which is will look up the toolchain under ctx.exec_groups[NAME] instead of ctx.
  • swift_common.{compile,compile_module_interface,precompile_clang_module} now take an exec_group argument, which is passed down to the underlying ctx.actions.run call for actions using the toolchain.

In all cases the default value of the argument is None, so omitting it retains the current behavior.

Most importantly, this lets us declare the Swift toolchain somewhere other than the rule/aspect's ctx, which ensures that in a multiple toolchain scenario, the Swift toolchain doesn't fully decide the execution platform for all actions (even non-Swift actions).

Since execution groups are somewhat in flux right now, this may not be the final form—it would be nice to have the coupling between the execution group and the toolchain automated. I considered just having each action be its own execution group (like C++ link actions use cpp_link), but that seems worse; Swift actions should almost never be split across different toolchains/platforms, and it would force the user to have to declare multiple exec groups if they wanted to use the feature with multiple actions. This lets them share something like a single "swift" execution group across multiple actions, with the only caveat being that they have to pass that name explicitly.

PiperOrigin-RevId: 502638394
(cherry picked from commit aeee2bb)

brentleyjones referenced this pull request Sep 30, 2024
…d pass an optional execution group name down to actions that use it.

This updates the following APIs:

-   `swift_common.get_toolchain` now takes an `exec_group` argument, which is will look up the toolchain under `ctx.exec_groups[NAME]` instead of `ctx`.
-   `swift_common.{compile,compile_module_interface,precompile_clang_module}` now take an `exec_group` argument, which is passed down to the underlying `ctx.actions.run` call for actions using the toolchain.

In all cases the default value of the argument is `None`, so omitting it retains the current behavior.

Most importantly, this lets us declare the Swift toolchain somewhere other than the rule/aspect's `ctx`, which ensures that in a multiple toolchain scenario, the Swift toolchain doesn't fully decide the execution platform for all actions (even non-Swift actions).

Since execution groups are somewhat in flux right now, this may not be the final form—it would be nice to have the coupling between the execution group and the toolchain automated. I considered just having each action be its own execution group (like C++ link actions use `cpp_link`), but that seems worse; Swift actions should almost never be split across different toolchains/platforms, and it would force the user to have to declare multiple exec groups if they wanted to use the feature with multiple actions. This lets them share something like a single "swift" execution group across multiple actions, with the only caveat being that they have to pass that name explicitly.

PiperOrigin-RevId: 502638394
…d pass an optional execution group name down to actions that use it

This updates the following APIs:

-   `swift_common.get_toolchain` now takes an `exec_group` argument, which is will look up the toolchain under `ctx.exec_groups[NAME]` instead of `ctx`.
-   `swift_common.{compile,compile_module_interface,precompile_clang_module}` now take an `exec_group` argument, which is passed down to the underlying `ctx.actions.run` call for actions using the toolchain.

In all cases the default value of the argument is `None`, so omitting it retains the current behavior.

Most importantly, this lets us declare the Swift toolchain somewhere other than the rule/aspect's `ctx`, which ensures that in a multiple toolchain scenario, the Swift toolchain doesn't fully decide the execution platform for all actions (even non-Swift actions).

Since execution groups are somewhat in flux right now, this may not be the final form—it would be nice to have the coupling between the execution group and the toolchain automated. I considered just having each action be its own execution group (like C++ link actions use `cpp_link`), but that seems worse; Swift actions should almost never be split across different toolchains/platforms, and it would force the user to have to declare multiple exec groups if they wanted to use the feature with multiple actions. This lets them share something like a single "swift" execution group across multiple actions, with the only caveat being that they have to pass that name explicitly.

PiperOrigin-RevId: 502638394
(cherry picked from commit aeee2bb)
Signed-off-by: Brentley Jones <github@brentleyjones.com>
@brentleyjones brentleyjones force-pushed the bj/allow-the-swift-toolchain-to-be-associated-with-an-execution-group-and-pass-an-optional-execution-group-name-down-to-actions-that-use-it branch from edf2b45 to 1f12af9 Compare October 1, 2024 16:27
@brentleyjones brentleyjones enabled auto-merge (rebase) October 1, 2024 16:27
@brentleyjones brentleyjones merged commit 3f445ce into master Oct 1, 2024
@brentleyjones brentleyjones deleted the bj/allow-the-swift-toolchain-to-be-associated-with-an-execution-group-and-pass-an-optional-execution-group-name-down-to-actions-that-use-it branch October 1, 2024 17:29
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.

4 participants