From 7bc12c413e9784b666fbe19153ac8f90bb8f5cd5 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 20 Jun 2026 01:27:43 +0000 Subject: [PATCH] build: align build script execution platforms --- .../rules_rust_windows_exec_bin_target.patch | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/patches/rules_rust_windows_exec_bin_target.patch b/patches/rules_rust_windows_exec_bin_target.patch index e4cf306dff..b582383192 100644 --- a/patches/rules_rust_windows_exec_bin_target.patch +++ b/patches/rules_rust_windows_exec_bin_target.patch @@ -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"))], + )