build: select the gnullvm nightly toolchain

This commit is contained in:
Adam Perry
2026-06-20 00:45:51 +00:00
committed by Adam Perry @ OpenAI
parent d93ad01950
commit c459a81bbf
4 changed files with 31 additions and 5 deletions

View File

@@ -112,6 +112,7 @@ rules_rust = use_extension("@rules_rs//rs/experimental:rules_rust.bzl", "rules_r
# `libssp_nonshared`, so strip the forwarded stack-protector flags there.
rules_rust.patch(
patches = [
"//patches:rules_rust_repository_set_replacement.patch",
"//patches:rules_rust_windows_gnullvm_build_script.patch",
"//patches:rules_rust_windows_exec_msvc_build_script_env.patch",
"//patches:rules_rust_windows_bootstrap_process_wrapper_linker.patch",
@@ -140,7 +141,7 @@ nightly_rust.toolchain(
# ABI so proc macros, build scripts, and the lint driver share one hermetic
# LLVM/MinGW toolchain.
nightly_rust.repository_set(
name = "rust_windows_x86_64_gnullvm",
name = "rust_windows_x86_64",
dev_components = True,
edition = "2024",
exec_compatible_with = [

View File

@@ -15,6 +15,7 @@ exports_files([
"rules_rust_windows_msvc_direct_link_args.patch",
"rules_rust_windows_gnullvm_build_script.patch",
"rules_cc_rusty_v8_custom_libcxx.patch",
"rules_rust_repository_set_replacement.patch",
"rules_rs_build_script_deps_annotation.patch",
"rules_rs_windows_gnullvm_exec.patch",
"rules_rs_windows_exec_linker.patch",

View File

@@ -21,10 +21,10 @@ diff --git a/rs/experimental/toolchains/declare_rustc_toolchains.bzl b/rs/experi
"@platforms//os:ios": ["-lSystem", "-lobjc", "-Wl,-framework,Security", "-Wl,-framework,Foundation", "-lresolv"],
- # TODO: windows
+ "@rules_rs//rs/experimental/platforms/constraints:windows_gnullvm": [
+ "advapi32.lib",
+ "ws2_32.lib",
+ "userenv.lib",
+ "Bcrypt.lib",
+ "-ladvapi32",
+ "-lws2_32",
+ "-luserenv",
+ "-lbcrypt",
+ ],
+ "@rules_rs//rs/experimental/platforms/constraints:windows_msvc": [
+ "advapi32.lib",

View File

@@ -0,0 +1,24 @@
# What: replace a default repository set by its documented repository name.
# Why: changing the exec triple (for example, MSVC to gnullvm) also changes the
# lookup key, so matching by both the old triple and name leaves the default
# toolchain registered and lets it win toolchain resolution.
diff --git a/rust/extensions.bzl b/rust/extensions.bzl
--- a/rust/extensions.bzl
+++ b/rust/extensions.bzl
@@ -100,8 +100,13 @@ def _rust_impl(module_ctx):
**repository_set
)
extra_toolchain_infos.update(**toolchain_infos)
- if toolchain_triples.get(repository_set["exec_triple"]) == repository_set["name"]:
- toolchain_triples.pop(repository_set["exec_triple"], None)
+ replaced_exec_triples = [
+ exec_triple
+ for exec_triple, name in toolchain_triples.items()
+ if name == repository_set["name"]
+ ]
+ for exec_triple in replaced_exec_triples:
+ toolchain_triples.pop(exec_triple)
toolchains = root.tags.toolchain
if not toolchains and rules_rust: