Skip to content

fix: add skip_per_crate_rustc_flags to rust_crate.bzl#73

Open
rejuvenile wants to merge 1 commit intohermeticbuild:mainfrom
rejuvenile:add-skip-per-crate-rustc-flags
Open

fix: add skip_per_crate_rustc_flags to rust_crate.bzl#73
rejuvenile wants to merge 1 commit intohermeticbuild:mainfrom
rejuvenile:add-skip-per-crate-rustc-flags

Conversation

@rejuvenile
Copy link
Copy Markdown
Contributor

Summary

Set skip_per_crate_rustc_flags = True on generated third-party crate targets in rust_crate.bzl, enabling configuration trimming for better cache hit rates.

Problem

When experimental_per_crate_rustc_flag is 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 = True to the rust_library / rust_proc_macro call in rust_crate(). This leverages the corresponding rules_rust attribute (added in [bazelbuild/rules_rust#XXXX]) to trim the experimental_per_crate_rustc_flag setting 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_flags attribute 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: Add skip_per_crate_rustc_flags = True to the kwargs dict passed to rust_library/rust_proc_macro

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.
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