Skip to content

incompatible_override_toolchain_transition: Migrate rules to use the toolchain transition #11584

@katre

Description

@katre

This flag unconditionally makes all rule uses the new toolchain transition. This means that any rule that uses toolchain resolution to fetch tools will need to migrate so that tools are in the correct configuration.

Flag: --incompatible_override_toolchain_transition

Migration:

First, wait for the new feature to be released (presumably in the release after 3.3.0).

See toolchain transition migration for details, but the process is fairly simple:

  1. For rules that create toolchains (i.e., cc_toolchain, go_toolchain, java_toolchain), add the proper cfg attribute.
    1. If the attribute is a tool used in builds (a compiler, a linker, anything that is executed), add cfg = 'exec' so that it will be built for the correct execution platform.
    2. If the attribute is intended to be part of the final target (a library, included source, anything else), add cfg = 'target', so that it will be built in the correct target configuration.
    3. At this point, there will be no change, because toolchains still use the host transition, and that overrides anything set on the toolchain rule itself.
  2. For each rule that uses a toolchain (i.e., cc_library, go_binary, java_test), add the incompatible_use_toolchain_transition = True parameter to the rule definition in Starlark.
    1. This enables the toolchain transition, instead of the host transition, when this rule type depends on a toolchain.
    2. Every toolchain type this rule uses should have been migrated in step 1 above.
  3. Once every rule has been migrated, wait for Bazel to flip the value of the --incompatible_override_toolchain_transition flag. This will take several releases for all rules to finish steps 1. and 2.
  4. Once the flag has flipped, remove the incompatible_use_toolchain_transition parameter from the rule declaration.
  5. Bazel will eventually deprecate the flag and rule parameter and remove them.

Metadata

Metadata

Assignees

Labels

P2We'll consider working on this in future. (Assignee optional)incompatible-changeIncompatible/breaking changeteam-Configurabilityplatforms, toolchains, cquery, select(), config transitionstype: feature request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions