fix: add skip_per_crate_rustc_flags to rust_crate.bzl#73
Open
rejuvenile wants to merge 1 commit intohermeticbuild:mainfrom
Open
fix: add skip_per_crate_rustc_flags to rust_crate.bzl#73rejuvenile wants to merge 1 commit intohermeticbuild:mainfrom
rejuvenile wants to merge 1 commit intohermeticbuild:mainfrom
Conversation
Set skip_per_crate_rustc_flags = True on generated third-party crate targets. This enables configuration trimming so that per_crate_rustc_flag settings (which filter by crate name prefix and typically target first-party code) don't cause unnecessary rebuilds of third-party crates. Requires the corresponding rules_rust change that adds the skip_per_crate_rustc_flags attribute and transition.
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.
Summary
Set
skip_per_crate_rustc_flags = Trueon generated third-party crate targets inrust_crate.bzl, enabling configuration trimming for better cache hit rates.Problem
When
experimental_per_crate_rustc_flagis set in rules_rust (e.g., to pass extra flags to first-party crates matching a//prefix), all third-party crates are placed into a different Bazel configuration even though the per-crate flags never match them. This causes unnecessary rebuilds of every third-party crate whenever the flag value changes.Fix
Pass
skip_per_crate_rustc_flags = Trueto therust_library/rust_proc_macrocall inrust_crate(). This leverages the corresponding rules_rust attribute (added in [bazelbuild/rules_rust#XXXX]) to trim theexperimental_per_crate_rustc_flagsetting from the configuration of third-party crates, returning them to a canonical configuration.Dependency
This change requires rules_rust to have the
skip_per_crate_rustc_flagsattribute defined. Without it, Bazel will error on the unknown attribute. The rules_rust PR adding this attribute is being submitted in parallel.Changes
rs/rust_crate.bzl: Addskip_per_crate_rustc_flags = Trueto the kwargs dict passed torust_library/rust_proc_macro