build: align build script execution platforms

This commit is contained in:
Adam Perry
2026-06-20 01:27:43 +00:00
committed by Adam Perry @ OpenAI
parent 368f038865
commit 7bc12c413e

View File

@@ -1,11 +1,10 @@
# What: compile exec-side Rust binaries against the exec Windows triple instead
# of the lint target triple.
# What: compile exec-side Rust binaries against the exec Windows triple and
# keep build-script wrappers on the matching Rust execution platform.
# Why: Windows native argument-comment-lint keeps the repo target platform on
# `windows-gnullvm` to preserve cfg coverage, but exec-side helper binaries
# (build.rs, runners, bootstrap tools) must link as host tools. With
# `toolchain_linker_preference=rust`, rules_rust was still feeding those exec
# binaries the `windows-gnullvm` target/std path, which broke linking under the
# native Bazel lint lane.
# (build.rs, runners, bootstrap tools) must link as host tools. Without a Rust
# toolchain on the runfiles wrapper, its `cfg=exec` build-script dependency can
# drift onto Linux RBE even though the consuming action runs on Windows.
diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
--- a/rust/private/rustc.bzl
@@ -69,3 +68,16 @@ diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
- rustc_flags.add_all(toolchain.rust_std_paths, before_each = "-L", format_each = "%s")
+ rustc_flags.add_all(_effective_rust_std_paths(toolchain, use_exec_target), before_each = "-L", format_each = "%s")
rustc_flags.add_all(rust_flags, map_each = map_flag)
diff --git a/cargo/private/cargo_build_script.bzl b/cargo/private/cargo_build_script.bzl
--- a/cargo/private/cargo_build_script.bzl
+++ b/cargo/private/cargo_build_script.bzl
@@ -117,5 +117,8 @@ cargo_build_script_runfiles = rule(
default = Label("//cargo/private:copy_file"),
),
},
executable = True,
+ # Keep the cfg=exec build-script binary on the same Rust-capable execution
+ # platform as the wrapper action that consumes it.
+ toolchains = [str(Label("//rust:toolchain_type"))],
)