Skip to content

Allow opting out of cc toolchain for cargo_build_script - #3679

Closed
dzbarsky wants to merge 1 commit into
bazelbuild:mainfrom
hermeticbuild:zbarsky/cc-build-script
Closed

Allow opting out of cc toolchain for cargo_build_script#3679
dzbarsky wants to merge 1 commit into
bazelbuild:mainfrom
hermeticbuild:zbarsky/cc-build-script

Conversation

@dzbarsky

Copy link
Copy Markdown
Contributor

With a hermetic cc toolchain + sysroot, the cc_toolchain.all_files can be quite a lot of a files to add to the spawn inputs. Our monorepo shows around 15% of global analysis time spent on ctx.actions.run of cargo_build_script due to these inputs. This PR gives us a switch to remove the toolchain from build scripts that don't intend to use it, while keeping backwards-compatibility.

@dzbarsky
dzbarsky force-pushed the zbarsky/cc-build-script branch from 3956a95 to 0d6c5b8 Compare October 19, 2025 17:39
@dzbarsky
dzbarsky force-pushed the zbarsky/cc-build-script branch from 0d6c5b8 to ce56648 Compare October 19, 2025 17:41
codelinaro-mirror-sync Bot pushed a commit to CodeLinaro-mirror/la_platform_external_bazelbuild-rules_rust that referenced this pull request Jul 25, 2026
This change introduces `use_cc_toolchain` to `cargo_build_script` which
can be used to control whether or not a `cc_toolchain` is explicitly
withheld from `CargoBuildScript` actions. Additionally a global flag
`--@rules_rust//cargo/settings:use_cc_toolchain` can be used to control
the default of any build script that has not either explicitly set
`use_cc_toolchain = 1` (always include cc toolchains) or
`use_cc_toolchain = 0` (always exclude cc toolchains).

closes bazelbuild/rules_rust#3680
closes bazelbuild/rules_rust#3679

Co-authored-by: Krasimir Georgiev <krasimir@google.com>
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