Skip to content

Commit 68c9337

Browse files
[bazel] Pin Windows target platform to gnullvm to fix proc-macro E0463
Windows CI pinned only --host_platform=//:local_windows_gnullvm, leaving the target platform as Bazel's auto-detected x64_windows. That platform lacks the @llvm//constraints/windows/abi:gnullvm and crt:msvcrt constraints, so the Rust toolchain resolved for the target config was a different variant than the one resolved for the exec (host) config. The visible symptom: compiling crates like `scroll` (target config x64_windows-fastbuild) referenced their proc-macro DLLs in the exec config (local_windows_gnullvm-opt-exec). Because the two configs resolved mismatched toolchains, the gnullvm proc-macro DLL (scroll_derive, time_macros) could not be loaded by the target rustc and failed with E0463: can't find crate. Pinning --platforms to //:local_windows_gnullvm as well puts the whole build on a single gnullvm toolchain, exactly as the RBE config already pins both --host_platform and --platforms. The extra abi/crt constraints only add to the host-inherited platform, so non-Rust toolchains (Java, .NET, Python) resolve unchanged. Also removes the unused local_windows_msvc platform: the hermetic LLVM Windows linker is hardwired to gnu-mode clang++ (-target x86_64-w64-windows-gnu) regardless of the abi constraint, so an msvc host can never link rustc's MSVC-style output. gnullvm is the only viable host, making that platform dead.
1 parent f290959 commit 68c9337

3 files changed

Lines changed: 15 additions & 24 deletions

File tree

.bazelrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,16 @@ common:linux --host_platform=//:local_linux_gnu
9494
# The LLVM toolchain doesn't ship libgcc_s; this stub satisfies Rust's
9595
# glibc stdlib link dependency when LLVM is the host C++ toolchain.
9696
common:linux --@llvm//config:experimental_stub_libgcc_s=True
97-
common:windows --host_platform=//:local_windows_msvc
97+
# Pin both the host (exec) and target platform to the gnullvm Windows
98+
# platform. Pinning only --host_platform leaves the target platform as
99+
# Bazel's auto-detected `x64_windows`, which lacks the gnullvm ABI / msvcrt
100+
# constraints. That makes the target-resolved Rust toolchain a different
101+
# variant than the exec-resolved one, so gnullvm proc-macro DLLs (e.g.
102+
# scroll_derive, time_macros) built in the exec config can't be loaded by
103+
# the target rustc and fail with `E0463: can't find crate`. Pinning both
104+
# (as the RBE config already does) keeps the whole build on one toolchain.
105+
common:windows --host_platform=//:local_windows_gnullvm
106+
common:windows --platforms=//:local_windows_gnullvm
98107
build:linux --workspace_status_command=scripts/build-info.sh
99108
build:macos --workspace_status_command=scripts/build-info.sh
100109
build:windows --workspace_status_command="powershell.exe scripts/build-info.ps1"

BUILD.bazel

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,6 @@ platform(
141141
parents = ["@platforms//host"],
142142
)
143143

144-
# Native Windows host platform. Used as `--host_platform` on Windows
145-
# runners so native rust builds go through `x86_64-pc-windows-msvc` (which
146-
# the Windows runners have installed as part of Visual Studio) rather
147-
# than `x86_64-pc-windows-gnullvm`. The gnullvm path drags in LLVM's
148-
# bootstrap-process-wrapper Starlark transition, which puts
149-
# `process_wrapper` in a different exec config than proc-macro deps and
150-
# trips rustc with `can't find crate for time_macros / scroll_derive`
151-
# style errors. Cross-compile targets in //rust still transition to the
152-
# gnullvm rules_rs platforms so non-Windows hosts can produce PE binaries
153-
# without a Windows SDK.
154-
platform(
155-
name = "local_windows_msvc",
156-
constraint_values = [
157-
"@llvm//constraints/windows/abi:msvc",
158-
"@llvm//constraints/windows/crt:msvcrt",
159-
],
160-
parents = ["@platforms//host"],
161-
)
162-
163144
buildifier(
164145
name = "buildifier",
165146
lint_mode = "fix",

rust/BUILD.bazel

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ alias(
6565
"//common:linux_x86_64": ":selenium-manager-linux-x86_64",
6666
"//common:macos_aarch64": ":selenium-manager-macos-aarch64",
6767
"//common:macos_x86_64": ":selenium-manager-macos-x86_64",
68-
# On Windows hosts platform_transition_binary hits a process_wrapper /
69-
# proc-macro exec-config hash divergence that prevents proc-macro DLLs
70-
# from being found. Fall back to the native rust_binary directly; on
71-
# a gnullvm host this already produces the correct gnullvm PE binary.
68+
# A Windows host is pinned to the gnullvm target platform (see the
69+
# --platforms setting in .bazelrc), so the native rust_binary already
70+
# builds the correct gnullvm PE binary. Using it directly avoids an
71+
# unnecessary platform_transition_binary (and its -ST- exec config)
72+
# on the host's own architecture.
7273
"//common:windows_aarch64": ":_selenium-manager-bin",
7374
"//common:windows_x86_64": ":_selenium-manager-bin",
7475
}),

0 commit comments

Comments
 (0)