build(bazel): upgrade rules_rs to 0.0.59

This commit is contained in:
Adam Perry
2026-06-12 07:59:58 +00:00
parent bf667c7003
commit a87e11e8b1
7 changed files with 59 additions and 54 deletions
+4 -4
View File
@@ -2,7 +2,7 @@ module(name = "codex")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "llvm", version = "0.7.1")
bazel_dep(name = "llvm", version = "0.7.3")
# The upstream LLVM archive contains a few unix-only symlink entries and is
# missing a couple of MinGW compatibility archives that windows-gnullvm needs
# during extraction and linking, so patch it until upstream grows native support.
@@ -78,7 +78,7 @@ use_repo(osx, "macos_sdk")
# Needed to disable xcode...
bazel_dep(name = "apple_support", version = "2.1.0")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "rules_cc", version = "0.2.18")
single_version_override(
module_name = "rules_cc",
patch_strip = 1,
@@ -87,7 +87,7 @@ single_version_override(
],
)
bazel_dep(name = "rules_platform", version = "0.1.0")
bazel_dep(name = "rules_rs", version = "0.0.58")
bazel_dep(name = "rules_rs", version = "0.0.59")
# `rules_rs` still does not model `windows-gnullvm` as a distinct Windows exec
# platform, so patch it until upstream grows that support for both x86_64 and
# aarch64.
@@ -99,7 +99,7 @@ single_version_override(
"//patches:rules_rs_windows_gnullvm_exec.patch",
"//patches:rules_rs_windows_exec_linker.patch",
],
version = "0.0.58",
version = "0.0.59",
)
rules_rust = use_extension("@rules_rs//rs/experimental:rules_rust.bzl", "rules_rust")
+15 -18
View File
@@ -45,6 +45,7 @@
"https://bcr.bazel.build/modules/bazel_features/1.34.0/MODULE.bazel": "e8475ad7c8965542e0c7aac8af68eb48c4af904be3d614b6aa6274c092c2ea1e",
"https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7",
"https://bcr.bazel.build/modules/bazel_features/1.42.0/MODULE.bazel": "e8ca15cb2639c5f12183db6dcb678735555d0cdd739b32a0418b6532b5e565f8",
"https://bcr.bazel.build/modules/bazel_features/1.43.0/MODULE.bazel": "defa2226f06ba20550d6548c3a2ea2a7929634437a52973869c20c225450eb91",
"https://bcr.bazel.build/modules/bazel_features/1.45.0/MODULE.bazel": "7daec6d87ab0703417486d4cb948af0b06f55d4d7c08cbb5978c80e79b538edf",
"https://bcr.bazel.build/modules/bazel_features/1.45.0/source.json": "635e4536e09ff125b8972e0fa239c135fde5f18701f7d5115680560651dfb41d",
"https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b",
@@ -63,6 +64,7 @@
"https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917",
"https://bcr.bazel.build/modules/bazel_skylib/1.7.0/MODULE.bazel": "0db596f4563de7938de764cc8deeabec291f55e8ec15299718b93c4423e9796d",
"https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b",
"https://bcr.bazel.build/modules/bazel_skylib/1.8.0/MODULE.bazel": "2fb3fb53675f6adfc1ca5bfbd5cfb655ae350fba4706d924a8ec7e3ba945671c",
"https://bcr.bazel.build/modules/bazel_skylib/1.8.1/MODULE.bazel": "88ade7293becda963e0e3ea33e7d54d3425127e0a326e0d17da085a5f1f03ff6",
"https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67",
"https://bcr.bazel.build/modules/bazel_skylib/1.9.0/MODULE.bazel": "72997b29dfd95c3fa0d0c48322d05590418edef451f8db8db5509c57875fb4b7",
@@ -86,9 +88,8 @@
"https://bcr.bazel.build/modules/libcap/2.27.bcr.1/MODULE.bazel": "7c034d7a4d92b2293294934377f5d1cbc88119710a11079fa8142120f6f08768",
"https://bcr.bazel.build/modules/libcap/2.27.bcr.1/source.json": "3b116cbdbd25a68ffb587b672205f6d353a4c19a35452e480d58fc89531e0a10",
"https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902",
"https://bcr.bazel.build/modules/llvm/0.7.0/MODULE.bazel": "3c07a4e5734b0ad41fe24dedaacbf3a35ce4377b7e1a21f24488a0c9ac4f1e6b",
"https://bcr.bazel.build/modules/llvm/0.7.1/MODULE.bazel": "74ac75efc6385b8a95d83bfa36ad399500f747c3d0f50287f9b6f9e854ec4814",
"https://bcr.bazel.build/modules/llvm/0.7.1/source.json": "0cac59d04dafa0ca1f70ea21cf1569e034ef8736c2c7510e834a9e8141d7e631",
"https://bcr.bazel.build/modules/llvm/0.7.3/MODULE.bazel": "b8ffe1ec9d18c0deb6d6dc1a6f78a64bcfcec8648c97b92ed6cd98a7fe49c64f",
"https://bcr.bazel.build/modules/llvm/0.7.3/source.json": "44d694e1559683ea4cf96052c56c5426d2604016636133798fcd57cc78542984",
"https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74",
"https://bcr.bazel.build/modules/openssl/3.5.4.bcr.0/MODULE.bazel": "0f6b8f20b192b9ff0781406256150bcd46f19e66d807dcb0c540548439d6fc35",
"https://bcr.bazel.build/modules/openssl/3.5.4.bcr.0/source.json": "543ed7627cc18e6460b9c1ae4a1b6b1debc5a5e0aca878b00f7531c7186b73da",
@@ -142,8 +143,8 @@
"https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c",
"https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37",
"https://bcr.bazel.build/modules/rules_cc/0.2.14/MODULE.bazel": "353c99ed148887ee89c54a17d4100ae7e7e436593d104b668476019023b58df8",
"https://bcr.bazel.build/modules/rules_cc/0.2.16/MODULE.bazel": "9242fa89f950c6ef7702801ab53922e99c69b02310c39fb6e62b2bd30df2a1d4",
"https://bcr.bazel.build/modules/rules_cc/0.2.16/source.json": "d03d5cde49376d87e14ec14b666c56075e5e3926930327fd5d0484a1ff2ac1cc",
"https://bcr.bazel.build/modules/rules_cc/0.2.18/MODULE.bazel": "4460ec36adc8f722a6a2a4ac9374cb91f2acebadaa93fc37966129afb3dece87",
"https://bcr.bazel.build/modules/rules_cc/0.2.18/source.json": "abad668ff2fd63ada1ac49bf386d37e27048b89a3465a6fd968bb832b00a09d3",
"https://bcr.bazel.build/modules/rules_cc/0.2.4/MODULE.bazel": "1ff1223dfd24f3ecf8f028446d4a27608aa43c3f41e346d22838a4223980b8cc",
"https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642",
"https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6",
@@ -201,8 +202,8 @@
"https://bcr.bazel.build/modules/rules_python/1.6.0/MODULE.bazel": "7e04ad8f8d5bea40451cf80b1bd8262552aa73f841415d20db96b7241bd027d8",
"https://bcr.bazel.build/modules/rules_python/1.7.0/MODULE.bazel": "d01f995ecd137abf30238ad9ce97f8fc3ac57289c8b24bd0bf53324d937a14f8",
"https://bcr.bazel.build/modules/rules_python/1.7.0/source.json": "028a084b65dcf8f4dc4f82f8778dbe65df133f234b316828a82e060d81bdce32",
"https://bcr.bazel.build/modules/rules_rs/0.0.58/MODULE.bazel": "72269bad768fbf5e00ea20d1fc5ad2193667d290c2c0ebefe80e787ef416d2a7",
"https://bcr.bazel.build/modules/rules_rs/0.0.58/source.json": "fdc6d257b388c4a0671563e259bea98b3401e86f2df884d16883922d91ffc668",
"https://bcr.bazel.build/modules/rules_rs/0.0.59/MODULE.bazel": "2356bae8fb790877f0d1b64199f7fc219738781c8ea324d1507a9473cf06dfea",
"https://bcr.bazel.build/modules/rules_rs/0.0.59/source.json": "0ee50d38cf9daec39106ba4110712f98fb8c8bc778717c4dc49f5fb629897a7b",
"https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c",
"https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b",
"https://bcr.bazel.build/modules/rules_shell/0.4.1/MODULE.bazel": "00e501db01bbf4e3e1dd1595959092c2fadf2087b2852d3f553b5370f5633592",
@@ -241,7 +242,7 @@
"@@aspect_tools_telemetry+//:extension.bzl%telemetry": {
"general": {
"bzlTransitiveDigest": "dnnhvKMf9MIXMulhbhHBblZdDAfAkiSVjApIXpUz9Y8=",
"usagesDigest": "7RqoFfyAk9gopozpmkZeHxhtuqELOLYzmqQ4uuF30BU=",
"usagesDigest": "Tane++tIVw9OVPCTBpnRoi7xPIBMTkmBZrGZNbwnyac=",
"recordedInputs": [
"REPO_MAPPING:aspect_tools_telemetry+,bazel_lib bazel_lib+",
"REPO_MAPPING:aspect_tools_telemetry+,bazel_skylib bazel_skylib+"
@@ -255,25 +256,23 @@
"alsa_lib": "1.2.9.bcr.4",
"apple_support": "2.1.0",
"aspect_tools_telemetry": "0.3.2",
"bazel_features": "1.42.0",
"bazel_features": "1.45.0",
"bazel_lib": "3.2.2",
"bazel_skylib": "1.8.2",
"bazel_skylib": "1.9.0",
"buildozer": "8.2.1",
"bzip2": "1.0.8.bcr.3",
"gawk": "5.3.2.bcr.3",
"googletest": "1.17.0",
"jsoncpp": "1.9.6",
"libcap": "2.27.bcr.1",
"llvm": "0.6.8",
"nlohmann_json": "3.6.1",
"llvm": "0.7.1",
"openssl": "3.5.4.bcr.0",
"package_metadata": "0.0.5",
"package_metadata": "0.0.7",
"platforms": "1.0.0",
"protobuf": "33.4",
"protobuf": "34.0.bcr.1",
"pybind11_bazel": "2.12.0",
"re2": "2024-07-02.bcr.1",
"rules_android": "0.1.1",
"rules_apple": "4.1.0",
"rules_cc": "0.2.16",
"rules_java": "9.0.3",
"rules_jvm_external": "6.7",
@@ -284,12 +283,10 @@
"rules_platform": "0.1.0",
"rules_proto": "7.1.0",
"rules_python": "1.7.0",
"rules_rs": "0.0.43",
"rules_rs": "0.0.58",
"rules_shell": "0.6.1",
"rules_swift": "3.1.2",
"sed": "4.9.bcr.3",
"stardoc": "0.7.2",
"swift_argument_parser": "1.3.1.2",
"tar.bzl": "0.9.0",
"with_cfg.bzl": "0.12.0",
"xz": "5.4.5.bcr.8",
+18 -16
View File
@@ -14,34 +14,33 @@ diff --git a/rs/experimental/toolchains/declare_rustc_toolchains.bzl b/rs/experi
rust_std = select(rust_std_select),
rustc = "{}rustc".format(rustc_repo_label),
cargo = "{}cargo".format(cargo_repo_label),
@@ -104,7 +106,20 @@ def declare_rustc_toolchains(
"@platforms//os:nixos": ["-ldl", "-lpthread"],
@@ -108,12 +110,18 @@ def declare_rustc_toolchains(
"@platforms//os:openbsd": ["-lpthread"],
"@platforms//os:ios": ["-lSystem", "-lobjc", "-Wl,-framework,Security", "-Wl,-framework,Foundation", "-lresolv"],
- # TODO: windows
"@rules_rs//rs/experimental/platforms/constraints:windows_gnu": ["-lws2_32", "-luserenv", "-lbcrypt", "-lntdll", "-lsynchronization"],
- "@rules_rs//rs/experimental/platforms/constraints:windows_gnullvm": ["-lws2_32", "-luserenv", "-lbcrypt", "-lntdll", "-lsynchronization"],
+ "@rules_rs//rs/experimental/platforms/constraints:windows_gnullvm": [
+ "advapi32.lib",
+ "ws2_32.lib",
+ "userenv.lib",
+ "Bcrypt.lib",
+ ],
+ "@rules_rs//rs/experimental/platforms/constraints:windows_msvc": [
+ "advapi32.lib",
+ "ws2_32.lib",
+ "userenv.lib",
+ "Bcrypt.lib",
"@rules_rs//rs/experimental/platforms/constraints:windows_msvc": [
"advapi32.lib",
"ws2_32.lib",
"userenv.lib",
"Bcrypt.lib",
+ "ucrt.lib",
+ ],
+ # TODO: other platforms
],
"//conditions:default": [],
}),
default_edition = edition,
diff --git a/rs/private/rustc_repository.bzl b/rs/private/rustc_repository.bzl
--- a/rs/private/rustc_repository.bzl
+++ b/rs/private/rustc_repository.bzl
@@ -7,10 +7,24 @@ load(
@@ -7,6 +7,14 @@ load(
)
load(":rust_repository_utils.bzl", "RUST_REPOSITORY_COMMON_ATTR", "download_and_extract")
-
+
+_WINDOWS_EXEC_LINKER_BUILD = """
+filegroup(
@@ -50,11 +49,14 @@ diff --git a/rs/private/rustc_repository.bzl b/rs/private/rustc_repository.bzl
+ visibility = ["//visibility:public"],
+)
+"""
def _rustc_repository_impl(rctx):
exec_triple = triple(rctx.attr.triple)
+
def _symlink_rust_objcopy_shared_libraries(rctx, exec_triple):
rust_objcopy = rctx.path("lib/rustlib/{}/bin/rust-objcopy".format(exec_triple.str))
if not rust_objcopy.exists:
@@ -29,6 +37,12 @@ def _rustc_repository_impl(rctx):
download_and_extract(rctx, "rustc", "rustc", exec_triple)
build_content = [BUILD_for_compiler(exec_triple)]
_symlink_rust_objcopy_shared_libraries(rctx, exec_triple)
build_content = [BUILD_for_compiler(exec_triple, include_objcopy = True)]
+ if exec_triple.system == "windows":
+ lld_link = rctx.which("lld-link.exe")
+ if lld_link == None:
@@ -102,16 +102,15 @@
let Args {
progname,
crate_links,
@@ -55,7 +135,8 @@ fn run_buildrs() -> Result<(), String> {
cargo_manifest_maker.create_runfiles_dir().unwrap()
}
@@ -54,6 +134,6 @@ fn run_buildrs() -> Result<(), String> {
cargo_manifest_maker.create_runfiles_dir().unwrap();
- let out_dir_abs = exec_root.join(out_dir);
+ let out_dir_abs = shorten_windows_path(&exec_root_join(&exec_root, &out_dir));
// For some reason Google's RBE does not create the output directory, force create it.
create_dir_all(&out_dir_abs)
.unwrap_or_else(|_| panic!("Failed to make output directory: {:?}", out_dir_abs));
@@ -89,11 +170,12 @@ fn run_buildrs() -> Result<(), String> {
@@ -87,11 +167,12 @@ fn run_buildrs() -> Result<(), String> {
let working_directory = resolve_rundir(&rundir, &exec_root, &manifest_dir)?;
@@ -126,7 +125,7 @@
.env("CARGO_MANIFEST_DIR", manifest_dir)
.env("RUSTC", rustc)
.env("RUST_BACKTRACE", "full");
@@ -123,7 +205,7 @@ fn run_buildrs() -> Result<(), String> {
@@ -121,7 +202,7 @@ fn run_buildrs() -> Result<(), String> {
for tool_env_var in &["CC", "CXX", "LD"] {
if let Some(tool_path) = env::var_os(tool_env_var) {
@@ -135,7 +134,7 @@
}
}
@@ -139,7 +221,7 @@ fn run_buildrs() -> Result<(), String> {
@@ -137,7 +218,7 @@ fn run_buildrs() -> Result<(), String> {
command.env_remove("AR");
command.env_remove("ARFLAGS");
} else {
@@ -144,7 +143,7 @@
}
}
@@ -257,7 +339,8 @@ fn resolve_rundir(rundir: &str, exec_root: &Path, manifest_dir: &Path) -> Result
@@ -319,7 +400,8 @@ fn resolve_rundir(rundir: &str, exec_root: &Path, manifest_dir: &Path) -> Result
if rundir.is_empty() {
return Ok(manifest_dir.to_owned());
}
@@ -157,7 +156,7 @@
diff --git a/cargo/private/cargo_build_script_runner/cargo_manifest_dir.rs b/cargo/private/cargo_build_script_runner/cargo_manifest_dir.rs
--- a/cargo/private/cargo_build_script_runner/cargo_manifest_dir.rs
+++ b/cargo/private/cargo_build_script_runner/cargo_manifest_dir.rs
@@ -282,7 +282,7 @@
@@ -316,7 +316,7 @@
/// been copied into the runfiles directory.
fn drain_runfiles_dir_windows(&self) -> Result<(), String> {
for dest in self.runfiles.values() {
@@ -10,7 +10,7 @@
diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -129,6 +129,20 @@
@@ -130,7 +130,21 @@ is_proc_macro_dep_enabled = rule(
build_setting = config.bool(flag = True),
)
@@ -32,7 +32,9 @@ diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
+def _get_rustc_env(attr, toolchain, crate_name, use_exec_target = False):
"""Gathers rustc environment variables
@@ -147,6 +161,6 @@
Args:
@@ -149,8 +163,8 @@ def _get_rustc_env(attr, toolchain, crate_name):
pre = ""
result = {
- "CARGO_CFG_TARGET_ARCH": "" if toolchain.target_arch == None else toolchain.target_arch,
@@ -41,7 +43,8 @@ diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
+ "CARGO_CFG_TARGET_OS": "" if _effective_target_os(toolchain, use_exec_target) == None else _effective_target_os(toolchain, use_exec_target),
"CARGO_CRATE_NAME": crate_name,
"CARGO_PKG_AUTHORS": "",
@@ -997,9 +1011,11 @@
"CARGO_PKG_DESCRIPTION": "",
@@ -1020,10 +1034,12 @@ def construct_arguments(
if build_metadata and not use_json_output:
fail("build_metadata requires parse_json_output")
@@ -54,18 +57,22 @@ diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
+ env = _get_rustc_env(attr, toolchain, crate_info.name, use_exec_target)
# Wrapper args first
@@ -1138,5 +1154,5 @@
process_wrapper_flags = ctx.actions.args()
@@ -1164,14 +1180,14 @@ def construct_arguments(
if error_format != "json":
# Color is not compatible with json output.
rustc_flags.add("--color=always")
- rustc_flags.add(toolchain.target_flag_value, format = "--target=%s")
+ rustc_flags.add(_effective_target_flag_value(toolchain, use_exec_target), format = "--target=%s")
if hasattr(attr, "crate_features"):
@@ -1144,6 +1160,6 @@
rustc_flags.add_all(getattr(attr, "crate_features"), before_each = "--cfg", format_each = 'feature="%s"')
if linker_script:
rustc_flags.add(linker_script, format = "--codegen=link-arg=-T%s")
# Tell Rustc where to find the standard library (or libcore)
- 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)
-
+
rustc_flags.add_all(
_extract_allowed_unstable_features_from_flags(rust_flags, all_allowed_unstable_features),
+1 -1
View File
@@ -14,7 +14,7 @@ diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl
+ exec_rust_std = None,
rust_std = None,
rustfmt = None,
linker = None):
linker = None,
@@ -315,6 +316,14 @@
# Made available to support $(location) expansion in stdlib_linkflags and extra_rustc_flags.
transitive_file_sets.append(depset(ctx.files.rust_std))
@@ -1,6 +1,6 @@
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -501,11 +501,41 @@
@@ -501,11 +501,25 @@
filtered_args.append(version)
# Keep library search path flags