mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58:46 +00:00
273 lines
13 KiB
Diff
273 lines
13 KiB
Diff
# What: teach `rules_rs` that `windows-gnullvm` is a distinct Windows exec ABI.
|
|
# Scope: platform/toolchain naming, constraints, and host-tool selection; no
|
|
# Cargo target changes.
|
|
|
|
diff --git a/rs/experimental/miri/private/declare_toolchains.bzl b/rs/experimental/miri/private/declare_toolchains.bzl
|
|
index e0c4f8b..cec29ec 100644
|
|
--- a/rs/experimental/miri/private/declare_toolchains.bzl
|
|
+++ b/rs/experimental/miri/private/declare_toolchains.bzl
|
|
@@ -2,7 +2,7 @@ load("@rules_rust//rust/platform:triple.bzl", _parse_triple = "triple")
|
|
load("//rs/experimental/miri/private:sysroot.bzl", "miri_sysroot")
|
|
load("//rs/experimental/miri/private:toolchain.bzl", "miri_sysroot_toolchain", "miri_toolchain")
|
|
load("//rs/platforms:triples.bzl", "ALL_TARGET_TRIPLES", "SUPPORTED_EXEC_TRIPLES", "triple_to_rust_constraint_set")
|
|
-load("//rs/toolchains:toolchain_utils.bzl", "sanitize_triple", "sanitize_version")
|
|
+load("//rs/toolchains:toolchain_utils.bzl", "exec_triple_suffix", "sanitize_triple", "sanitize_version")
|
|
|
|
def declare_miri_toolchains(
|
|
*,
|
|
@@ -24,11 +24,8 @@ def declare_miri_toolchains(
|
|
|
|
for triple in execs:
|
|
exec_triple = _parse_triple(triple)
|
|
- triple_suffix = exec_triple.system + "_" + exec_triple.arch
|
|
- exec_compatible_with = [
|
|
- "@platforms//os:" + exec_triple.system,
|
|
- "@platforms//cpu:" + exec_triple.arch,
|
|
- ]
|
|
+ triple_suffix = exec_triple_suffix(exec_triple)
|
|
+ exec_compatible_with = triple_to_rust_constraint_set(triple)
|
|
|
|
miri_repo_label = "@miri_%s_%s//:" % (triple_suffix, version_key)
|
|
toolchain_kwargs = dict(
|
|
diff --git a/rs/platforms/triples.bzl b/rs/platforms/triples.bzl
|
|
index b299f6f..c960d54 100644
|
|
--- a/rs/platforms/triples.bzl
|
|
+++ b/rs/platforms/triples.bzl
|
|
@@ -45,7 +45,9 @@ SUPPORTED_EXEC_TRIPLES = [
|
|
"x86_64-unknown-linux-gnu",
|
|
"aarch64-unknown-linux-gnu",
|
|
"x86_64-pc-windows-msvc",
|
|
+ "x86_64-pc-windows-gnullvm",
|
|
"aarch64-pc-windows-msvc",
|
|
+ "aarch64-pc-windows-gnullvm",
|
|
"x86_64-apple-darwin",
|
|
"aarch64-apple-darwin",
|
|
]
|
|
diff --git a/rs/toolchains/declare_rust_analyzer_toolchains.bzl b/rs/toolchains/declare_rust_analyzer_toolchains.bzl
|
|
index e8a729a..f61f9e0 100644
|
|
--- a/rs/toolchains/declare_rust_analyzer_toolchains.bzl
|
|
+++ b/rs/toolchains/declare_rust_analyzer_toolchains.bzl
|
|
@@ -4,8 +4,8 @@ load(
|
|
"@rules_rust//rust/private:repository_utils.bzl",
|
|
"includes_rust_analyzer_proc_macro_srv",
|
|
)
|
|
-load("//rs/platforms:triples.bzl", "SUPPORTED_EXEC_TRIPLES")
|
|
-load("//rs/toolchains:toolchain_utils.bzl", "sanitize_version")
|
|
+load("//rs/platforms:triples.bzl", "SUPPORTED_EXEC_TRIPLES", "triple_to_rust_constraint_set")
|
|
+load("//rs/toolchains:toolchain_utils.bzl", "exec_triple_suffix", "sanitize_version")
|
|
|
|
def _channel(version):
|
|
if version.startswith("nightly"):
|
|
@@ -31,15 +31,14 @@ def declare_rust_analyzer_toolchains(
|
|
|
|
for triple in execs:
|
|
exec_triple = _parse_triple(triple)
|
|
- triple_suffix = exec_triple.system + "_" + exec_triple.arch
|
|
+ triple_suffix = exec_triple_suffix(exec_triple)
|
|
|
|
rustc_repo_label = "@rustc_{}_{}//:".format(triple_suffix, rust_analyzer_version_key)
|
|
rust_analyzer_repo_label = "@rust_analyzer_{}_{}//:".format(triple_suffix, rust_analyzer_version_key)
|
|
rust_src_repo_label = "@rust_src_{}//lib/rustlib/src:rustc_srcs".format(rust_analyzer_version_key)
|
|
|
|
- rust_analyzer_toolchain_name = "{}_{}_{}_rust_analyzer_toolchain".format(
|
|
- exec_triple.system,
|
|
- exec_triple.arch,
|
|
+ rust_analyzer_toolchain_name = "{}_{}_rust_analyzer_toolchain".format(
|
|
+ triple_suffix,
|
|
version_key,
|
|
)
|
|
|
|
@@ -57,11 +56,8 @@ def declare_rust_analyzer_toolchains(
|
|
rust_analyzer_toolchain(**rust_analyzer_toolchain_kwargs)
|
|
|
|
native.toolchain(
|
|
- name = "{}_{}_rust_analyzer_{}".format(exec_triple.system, exec_triple.arch, version_key),
|
|
- exec_compatible_with = [
|
|
- "@platforms//os:" + exec_triple.system,
|
|
- "@platforms//cpu:" + exec_triple.arch,
|
|
- ],
|
|
+ name = "{}_rust_analyzer_{}".format(triple_suffix, version_key),
|
|
+ exec_compatible_with = triple_to_rust_constraint_set(triple),
|
|
target_compatible_with = [],
|
|
target_settings = [
|
|
"@rules_rust//rust/toolchain/channel:" + channel,
|
|
diff --git a/rs/toolchains/declare_rustc_toolchains.bzl b/rs/toolchains/declare_rustc_toolchains.bzl
|
|
index afe84b3..bbf383c 100644
|
|
--- a/rs/toolchains/declare_rustc_toolchains.bzl
|
|
+++ b/rs/toolchains/declare_rustc_toolchains.bzl
|
|
@@ -2,7 +2,7 @@ load("@rules_rust//rust:toolchain.bzl", "rust_toolchain")
|
|
load("@rules_rust//rust/platform:triple.bzl", _parse_triple = "triple")
|
|
load("//rs/platforms:triples.bzl", "ALL_TARGET_TRIPLES", "SUPPORTED_EXEC_TRIPLES", "SUPPORTED_TIER_3_TRIPLES", "triple_to_rust_constraint_set")
|
|
load("//rs/private:bpf_linker_repository.bzl", "bpf_linker_repository_name")
|
|
-load("//rs/toolchains:toolchain_utils.bzl", "sanitize_triple", "sanitize_version")
|
|
+load("//rs/toolchains:toolchain_utils.bzl", "exec_triple_suffix", "sanitize_triple", "sanitize_version")
|
|
|
|
_BPF_TARGET_TRIPLES = [
|
|
"bpfeb-unknown-none",
|
|
@@ -53,15 +53,14 @@ def declare_rustc_toolchains(
|
|
|
|
for triple in execs:
|
|
exec_triple = _parse_triple(triple)
|
|
- triple_suffix = exec_triple.system + "_" + exec_triple.arch
|
|
+ triple_suffix = exec_triple_suffix(exec_triple)
|
|
|
|
rustc_repo_label = "@rustc_{}_{}//:".format(triple_suffix, version_key)
|
|
cargo_repo_label = "@cargo_{}_{}//:".format(triple_suffix, version_key)
|
|
clippy_repo_label = "@clippy_{}_{}//:".format(triple_suffix, version_key)
|
|
|
|
- rust_toolchain_name = "{}_{}_{}_rust_toolchain".format(
|
|
- exec_triple.system,
|
|
- exec_triple.arch,
|
|
+ rust_toolchain_name = "{}_{}_rust_toolchain".format(
|
|
+ triple_suffix,
|
|
version_key,
|
|
)
|
|
rust_std = rust_toolchain_name + "_rust_std"
|
|
@@ -202,11 +201,8 @@ def declare_rustc_toolchains(
|
|
target_key = sanitize_triple(target_triple)
|
|
|
|
native.toolchain(
|
|
- name = "{}_{}_to_{}_{}".format(exec_triple.system, exec_triple.arch, target_key, version_key),
|
|
- exec_compatible_with = [
|
|
- "@platforms//os:" + exec_triple.system,
|
|
- "@platforms//cpu:" + exec_triple.arch,
|
|
- ],
|
|
+ name = "{}_to_{}_{}".format(triple_suffix, target_key, version_key),
|
|
+ exec_compatible_with = triple_to_rust_constraint_set(triple),
|
|
target_compatible_with = triple_to_rust_constraint_set(target_triple),
|
|
target_settings = [
|
|
"@rules_rust//rust/private:bootstrapped",
|
|
@@ -221,11 +217,8 @@ def declare_rustc_toolchains(
|
|
continue
|
|
|
|
native.toolchain(
|
|
- name = "{}_{}_to_{}_{}_bootstrap".format(exec_triple.system, exec_triple.arch, target_key, version_key),
|
|
- exec_compatible_with = [
|
|
- "@platforms//os:" + exec_triple.system,
|
|
- "@platforms//cpu:" + exec_triple.arch,
|
|
- ],
|
|
+ name = "{}_to_{}_{}_bootstrap".format(triple_suffix, target_key, version_key),
|
|
+ exec_compatible_with = triple_to_rust_constraint_set(triple),
|
|
target_compatible_with = triple_to_rust_constraint_set(target_triple),
|
|
target_settings = [
|
|
"@rules_rust//rust/private:bootstrapping",
|
|
diff --git a/rs/toolchains/declare_rustfmt_toolchains.bzl b/rs/toolchains/declare_rustfmt_toolchains.bzl
|
|
index 6c28641..d1b084c 100644
|
|
--- a/rs/toolchains/declare_rustfmt_toolchains.bzl
|
|
+++ b/rs/toolchains/declare_rustfmt_toolchains.bzl
|
|
@@ -1,7 +1,7 @@
|
|
load("@rules_rust//rust:toolchain.bzl", "rustfmt_toolchain")
|
|
load("@rules_rust//rust/platform:triple.bzl", _parse_triple = "triple")
|
|
-load("//rs/platforms:triples.bzl", "SUPPORTED_EXEC_TRIPLES")
|
|
-load("//rs/toolchains:toolchain_utils.bzl", "sanitize_version")
|
|
+load("//rs/platforms:triples.bzl", "SUPPORTED_EXEC_TRIPLES", "triple_to_rust_constraint_set")
|
|
+load("//rs/toolchains:toolchain_utils.bzl", "exec_triple_suffix", "sanitize_version")
|
|
|
|
def _channel(version):
|
|
if version.startswith("nightly"):
|
|
@@ -22,14 +22,13 @@ def declare_rustfmt_toolchains(
|
|
|
|
for triple in execs:
|
|
exec_triple = _parse_triple(triple)
|
|
- triple_suffix = exec_triple.system + "_" + exec_triple.arch
|
|
+ triple_suffix = exec_triple_suffix(exec_triple)
|
|
|
|
rustc_repo_label = "@rustc_{}_{}//:".format(triple_suffix, version_key)
|
|
rustfmt_repo_label = "@rustfmt_{}_{}//:".format(triple_suffix, rustfmt_version_key)
|
|
|
|
- rustfmt_toolchain_name = "{}_{}_{}_rustfmt_toolchain".format(
|
|
- exec_triple.system,
|
|
- exec_triple.arch,
|
|
+ rustfmt_toolchain_name = "{}_{}_rustfmt_toolchain".format(
|
|
+ triple_suffix,
|
|
version_key,
|
|
)
|
|
|
|
@@ -43,11 +42,8 @@ def declare_rustfmt_toolchains(
|
|
)
|
|
|
|
native.toolchain(
|
|
- name = "{}_{}_rustfmt_{}".format(exec_triple.system, exec_triple.arch, version_key),
|
|
- exec_compatible_with = [
|
|
- "@platforms//os:" + exec_triple.system,
|
|
- "@platforms//cpu:" + exec_triple.arch,
|
|
- ],
|
|
+ name = "{}_rustfmt_{}".format(triple_suffix, version_key),
|
|
+ exec_compatible_with = triple_to_rust_constraint_set(triple),
|
|
target_compatible_with = [],
|
|
target_settings = [
|
|
"@rules_rust//rust/toolchain/channel:" + channel,
|
|
diff --git a/rs/toolchains/module_extension.bzl b/rs/toolchains/module_extension.bzl
|
|
index 554dd26..f79b73f 100644
|
|
--- a/rs/toolchains/module_extension.bzl
|
|
+++ b/rs/toolchains/module_extension.bzl
|
|
@@ -20,7 +20,7 @@ load("//rs/private:rustc_src_repository.bzl", "rustc_src_repository")
|
|
load("//rs/private:rustfmt_repository.bzl", "rustfmt_repository")
|
|
load("//rs/private:stdlib_repository.bzl", "stdlib_repository")
|
|
load("//rs/private:toolchains_repository.bzl", "toolchains_repository")
|
|
-load("//rs/toolchains:toolchain_utils.bzl", "sanitize_triple", "sanitize_version")
|
|
+load("//rs/toolchains:toolchain_utils.bzl", "exec_triple_suffix", "sanitize_triple", "sanitize_version")
|
|
|
|
_DEFAULT_RUSTC_VERSION = "1.92.0"
|
|
_DEFAULT_EDITION = "2021"
|
|
@@ -302,20 +302,25 @@ def _toolchains_impl(mctx):
|
|
for triple in SUPPORTED_EXEC_TRIPLES:
|
|
exec_triple = _parse_triple(triple)
|
|
|
|
- triple_suffix = exec_triple.system + "_" + exec_triple.arch
|
|
+ triple_suffix = exec_triple_suffix(exec_triple)
|
|
rustc_name = "rustc_{}_{}".format(triple_suffix, version_key)
|
|
|
|
rustc_repository(
|
|
name = rustc_name,
|
|
triple = triple,
|
|
version = base_version,
|
|
iso_date = iso_date,
|
|
sha256 = _sha_for("rustc", base_version, iso_date, exec_triple),
|
|
)
|
|
|
|
if version in rust_versions:
|
|
cargo_name = "cargo_{}_{}".format(triple_suffix, version_key)
|
|
- if exec_triple.arch == host_arch and exec_triple.system == host_os:
|
|
+ # Keep extension-time host tools on the native Windows ABI.
|
|
+ if (
|
|
+ exec_triple.arch == host_arch and
|
|
+ exec_triple.system == host_os and
|
|
+ (exec_triple.system != "windows" or exec_triple.abi == "msvc")
|
|
+ ):
|
|
host_cargo_repos[version] = cargo_name
|
|
host_rustc_repos[version] = rustc_name
|
|
|
|
@@ -363,7 +363,7 @@ def _toolchains_impl(mctx):
|
|
|
|
for triple in SUPPORTED_EXEC_TRIPLES:
|
|
exec_triple = _parse_triple(triple)
|
|
- triple_suffix = exec_triple.system + "_" + exec_triple.arch
|
|
+ triple_suffix = exec_triple_suffix(exec_triple)
|
|
|
|
rustfmt_repository(
|
|
name = "rustfmt_{}_{}".format(triple_suffix, version_key),
|
|
@@ -387,7 +387,7 @@ def _toolchains_impl(mctx):
|
|
|
|
for triple in SUPPORTED_EXEC_TRIPLES:
|
|
exec_triple = _parse_triple(triple)
|
|
- triple_suffix = exec_triple.system + "_" + exec_triple.arch
|
|
+ triple_suffix = exec_triple_suffix(exec_triple)
|
|
|
|
rust_analyzer_repository(
|
|
name = "rust_analyzer_{}_{}".format(triple_suffix, version_key),
|
|
diff --git a/rs/toolchains/toolchain_utils.bzl b/rs/toolchains/toolchain_utils.bzl
|
|
index 1f64d62..cbd9411 100644
|
|
--- a/rs/toolchains/toolchain_utils.bzl
|
|
+++ b/rs/toolchains/toolchain_utils.bzl
|
|
@@ -1,4 +1,9 @@
|
|
"""Shared helpers for toolchain generation."""
|
|
|
|
+def exec_triple_suffix(exec_triple):
|
|
+ if exec_triple.system == "windows":
|
|
+ return "{}_{}_{}".format(exec_triple.system, exec_triple.arch, exec_triple.abi)
|
|
+ return "{}_{}".format(exec_triple.system, exec_triple.arch)
|
|
+
|
|
def sanitize_triple(triple_str):
|
|
return triple_str.replace("-", "_").replace(".", "_")
|