diff --git a/crate_universe/private/crate.bzl b/crate_universe/private/crate.bzl index c804d5f02c..70abcbd1f1 100644 --- a/crate_universe/private/crate.bzl +++ b/crate_universe/private/crate.bzl @@ -79,6 +79,7 @@ def _annotation( data_glob = None, deps = None, gen_binaries = [], + disable_pipelining = False, gen_build_script = None, patch_args = None, patch_tool = None, @@ -118,6 +119,7 @@ def _annotation( deps (list, optional): A list of labels to add to a crate's `rust_library::deps` attribute. gen_binaries (list or bool, optional): As a list, the subset of the crate's bins that should get `rust_binary` targets produced. Or `True` to generate all, `False` to generate none. + disable_pipelining (bool, optional): If True, disables pipelining for library targets for this crate. gen_build_script (bool, optional): An authorative flag to determine whether or not to produce `cargo_build_script` targets for the current crate. patch_args (list, optional): The `patch_args` attribute of a Bazel repository rule. See @@ -164,6 +166,7 @@ def _annotation( data_glob = data_glob, deps = deps, gen_binaries = gen_binaries, + disable_pipelining = disable_pipelining, gen_build_script = gen_build_script, patch_args = patch_args, patch_tool = patch_tool, diff --git a/crate_universe/src/config.rs b/crate_universe/src/config.rs index 1d2adc96ea..c8813245ea 100644 --- a/crate_universe/src/config.rs +++ b/crate_universe/src/config.rs @@ -178,6 +178,9 @@ pub struct CrateAnnotations { /// [compile_data](https://bazelbuild.github.io/rules_rust/defs.html#rust_library-compile_data) attribute. pub compile_data_glob: Option>, + /// If true, disables pipelining for library targets generated for this crate. + pub disable_pipelining: bool, + /// Additional data to pass to the target's /// [rustc_env](https://bazelbuild.github.io/rules_rust/defs.html#rust_library-rustc_env) attribute. pub rustc_env: Option>, @@ -278,6 +281,7 @@ impl Add for CrateAnnotations { crate_features: joined_extra_member!(self.crate_features, rhs.crate_features, BTreeSet::new, BTreeSet::extend), data: joined_extra_member!(self.data, rhs.data, BTreeSet::new, BTreeSet::extend), data_glob: joined_extra_member!(self.data_glob, rhs.data_glob, BTreeSet::new, BTreeSet::extend), + disable_pipelining: self.disable_pipelining || rhs.disable_pipelining, compile_data: joined_extra_member!(self.compile_data, rhs.compile_data, BTreeSet::new, BTreeSet::extend), compile_data_glob: joined_extra_member!(self.compile_data_glob, rhs.compile_data_glob, BTreeSet::new, BTreeSet::extend), rustc_env: joined_extra_member!(self.rustc_env, rhs.rustc_env, BTreeMap::new, BTreeMap::extend), diff --git a/crate_universe/src/context/crate_context.rs b/crate_universe/src/context/crate_context.rs index df33c54ec3..ed35afb237 100644 --- a/crate_universe/src/context/crate_context.rs +++ b/crate_universe/src/context/crate_context.rs @@ -247,6 +247,10 @@ pub struct CrateContext { /// Additional text to add to the generated BUILD file. #[serde(skip_serializing_if = "Option::is_none")] pub additive_build_file_content: Option, + + /// If true, disables pipelining for library targets generated for this crate + #[serde(skip_serializing_if = "std::ops::Not::not")] + pub disable_pipelining: bool, } impl CrateContext { @@ -394,6 +398,7 @@ impl CrateContext { build_script_attrs, license, additive_build_file_content: None, + disable_pipelining: false, } .with_overrides(extras) } @@ -446,6 +451,11 @@ impl CrateContext { self.common_attrs.data_glob.extend(extra.clone()); } + // Disable pipelining + if crate_extra.disable_pipelining { + self.disable_pipelining = true; + } + // Rustc flags if let Some(extra) = &crate_extra.rustc_flags { self.common_attrs.rustc_flags.append(&mut extra.clone()); diff --git a/crate_universe/src/rendering.rs b/crate_universe/src/rendering.rs index 6a452dcfea..17c6743316 100644 --- a/crate_universe/src/rendering.rs +++ b/crate_universe/src/rendering.rs @@ -435,6 +435,7 @@ impl Renderer { .make_aliases(krate, false, false) .remap_configurations(platforms), common: self.make_common_attrs(platforms, krate, target)?, + disable_pipelining: krate.disable_pipelining, }) } diff --git a/crate_universe/src/utils/starlark.rs b/crate_universe/src/utils/starlark.rs index 474b8264f5..ff0781effc 100644 --- a/crate_universe/src/utils/starlark.rs +++ b/crate_universe/src/utils/starlark.rs @@ -175,6 +175,8 @@ pub struct RustLibrary { pub aliases: SelectDict>, #[serde(flatten)] pub common: CommonAttrs, + #[serde(skip_serializing_if = "std::ops::Not::not")] + pub disable_pipelining: bool, } #[derive(Serialize)]