Skip to content

Commit cc1287f

Browse files
basvandijkIDX GitHub Automation
andauthored
chore: upgrade rules_rust to 0.71.3 (#10632)
Upgrades `rules_rust` from 0.69.0 to 0.71.3. - Drops `bazel/rules_rust_package_alias.patch`: the `package_alias` attribute is upstreamed in 0.71.3 ([rules_rust#3742](bazelbuild/rules_rust#3742)). - Regenerates `bazel/rules_rust_strip_level.patch` for 0.71.3: still needed because the native `rust.toolchain` `strip_level` tag attribute is a flat `string_dict` that cannot express the per-compilation-mode config (and is looked up by target triple downstream) ([rules_rust#3730](bazelbuild/rules_rust#3730)). - Adds `bazel/rules_rust_dep_env.patch`: rules_rust 0.71.x redacts the producer's out_dir to a generic `${out_dir}` token in dep env files, but those files are consumed by *downstream* crates' build scripts whose `--out-dir` differs, leaving the token unresolved (e.g. `libssh2-sys` failing to find `zlib.h` from `libz-sys`'s `DEP_Z_INCLUDE`). - Updates `bazel/hermetic_cc_toolchain_strip.patch`: the zig-wrapper now invokes `strip` via an absolute path (`/usr/bin/strip` or `/bin/strip`, failing with a clear error if neither exists), because rules_rust 0.71.x runs the wrapper at rustdoc doc-test time with a cleared environment (no `PATH`), where a bare `strip` fails to resolve. - Repins the Cargo Bazel lockfile (checksum-only change). - Switches test `env` attributes from `$(locations ...)` to `$(rootpaths ...)`: since [rules_rust#4088](bazelbuild/rules_rust#4088) (0.71.x) the plural `$(locations ...)`/`$(execpaths ...)` forms are `${pwd}`-prefixed like the singular forms; that token is only substituted during build actions, so test runtime envs saw literal `${pwd}/...` paths. `$(rootpaths ...)` is deliberately left unmodified for runtime use. --------- Co-authored-by: IDX GitHub Automation <infra+github-automation@dfinity.org>
1 parent 47b51fb commit cc1287f

10 files changed

Lines changed: 72 additions & 47 deletions

File tree

Cargo.Bazel.json.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"checksum": "c19078f9cd882fc228f7bb8d94437446b00320b3fe2bf5dd342d438fcf79b8f3",
2+
"checksum": "f78d53f7469ce9942ae6b5291f59924ee6a7937f946111f9b53c1cbbb9e83e25",
33
"crates": {
44
"abnf 0.12.0": {
55
"name": "abnf",

bazel/hermetic_cc_toolchain_strip.patch

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ index 5584f44..42f84d5 100644
5959
},
6060
}
6161
}
62-
@@ -152,13 +152,53 @@ fn spawnWindows(arena: mem.Allocator, params: ExecParams) u8 {
62+
@@ -152,13 +152,59 @@ fn spawnWindows(arena: mem.Allocator, params: ExecParams) u8 {
6363
}
6464
}
6565

@@ -71,10 +71,16 @@ index 5584f44..42f84d5 100644
7171
- );
7272
- return 1;
7373
+fn spawnAndStripUnix(arena: mem.Allocator, params: ExecParams) u8 {
74-
+ // Build a strip command
74+
+ // Build a strip command. Use an absolute path: this wrapper also runs at
75+
+ // rustdoc doc-test time where the environment is cleared (no PATH), so a
76+
+ // bare "strip" would fail to resolve with error.FileNotFound.
77+
+ const strip_bin = for ([_][]const u8{ "/usr/bin/strip", "/bin/strip" }) |p| {
78+
+ std.fs.accessAbsolute(p, .{}) catch continue;
79+
+ break p;
80+
+ } else return fatal("strip binary not found (checked /usr/bin/strip and /bin/strip)\n", .{});
7581
+ const strip_cmd = blk: {
7682
+ var list = ArrayListUnmanaged([]const u8){};
77-
+ list.appendSlice(arena, &[_][]const u8{ "strip", "-S" }) catch |err| {
83+
+ list.appendSlice(arena, &[_][]const u8{ strip_bin, "-S" }) catch |err| {
7884
+ return fatal("error building strip cmd: {s}\n", .{@errorName(err)});
7985
+ };
8086
+

bazel/rules_rust_dep_env.patch

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Fix cross-crate DEP_* env vars: rules_rust 0.71.x redacts the producer's out_dir
2+
# to a generic ${out_dir} token in dep env files, but those files are consumed by
3+
# downstream crates' build scripts whose --out-dir differs, leaving the token
4+
# unresolved (e.g. libssh2-sys failing to find zlib.h from libz-sys's DEP_Z_INCLUDE).
5+
# Upstream issue: the 'env files are only consumed by the direct owner' assumption
6+
# in redact_paths() does not hold for outputs_to_dep_env().
7+
# Fixed upstream by https://github.com/bazelbuild/rules_rust/pull/4124:
8+
# drop this patch when upgrading to a release that includes it.
9+
diff --git a/cargo/private/cargo_build_script_runner/lib.rs b/cargo/private/cargo_build_script_runner/lib.rs
10+
--- a/cargo/private/cargo_build_script_runner/lib.rs
11+
+++ b/cargo/private/cargo_build_script_runner/lib.rs
12+
@@ -181,7 +181,7 @@
13+
outputs: &[BuildScriptOutput],
14+
crate_links: &str,
15+
exec_root: &str,
16+
- out_dir: &str,
17+
+ _out_dir: &str,
18+
) -> String {
19+
let prefix = format!("DEP_{}_", crate_links.replace('-', "_").to_uppercase());
20+
outputs
21+
@@ -191,7 +191,12 @@
22+
Some(format!(
23+
"{}{}",
24+
prefix,
25+
- Self::escape_for_serializing(Self::redact_paths(env, exec_root, out_dir))
26+
+ // Do NOT redact the producer's out_dir to the generic `${out_dir}`
27+
+ // token here: DEP_* env vars are consumed by *downstream* crates'
28+
+ // build scripts, whose process_wrapper `--out-dir` points to a
29+
+ // different directory, so the token would resolve incorrectly
30+
+ // (or not at all). Only the exec root is safe to substitute.
31+
+ Self::escape_for_serializing(Self::redact_exec_root(env, exec_root))
32+
))
33+
} else {
34+
None

bazel/rules_rust_package_alias.patch

Lines changed: 0 additions & 24 deletions
This file was deleted.

bazel/rules_rust_strip_level.patch

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# support for per-platform strip levels: https://github.com/bazelbuild/rules_rust/issues/3730
2+
# rules_rust 0.71.3 added a `strip_level` attribute to the `rust.toolchain` tag, but it is a flat
3+
# `attr.string_dict` that cannot express the per-compilation-mode config, and it is passed
4+
# unwrapped to `rust_register_toolchains` which looks it up by target triple. Override it here.
25
diff --git a/rust/extensions.bzl b/rust/extensions.bzl
3-
index 99868b0df..5932b0760 100644
6+
index da2830f08..b7665652e 100644
47
--- a/rust/extensions.bzl
58
+++ b/rust/extensions.bzl
6-
@@ -122,6 +122,11 @@ def _rust_impl(module_ctx):
7-
toolchain_triples = toolchain_triples,
8-
target_settings = [str(v) for v in toolchain.target_settings],
9-
extra_toolchain_infos = extra_toolchain_infos,
9+
@@ -140,7 +140,11 @@ def _rust_impl(module_ctx):
10+
sha256s = toolchain.sha256s,
11+
extra_target_triples = toolchain.extra_target_triples,
12+
opt_level = toolchain.opt_level if toolchain.opt_level else None,
13+
- strip_level = toolchain.strip_level if toolchain.strip_level else None,
1014
+ strip_level = {"x86_64-unknown-linux-gnu": {
1115
+ "dbg": "none",
1216
+ "fastbuild": "none",
1317
+ "opt": "none",
1418
+ }},
15-
)
16-
metadata_kwargs = {}
17-
if bazel_features.external_deps.extension_metadata_has_reproducible:
19+
urls = toolchain.urls,
20+
versions = toolchain.versions,
21+
compact_windows_names = True,

bazel/rust.MODULE.bazel

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
# Run `./bin/bazel-pin.sh` from the top-level directory of the working tree after changing this file
33
# to regenerate Cargo Bazel lockfiles.
44

5-
bazel_dep(name = "rules_rust", version = "0.69.0")
5+
bazel_dep(name = "rules_rust", version = "0.71.3")
66
archive_override(
77
module_name = "rules_rust",
8-
integrity = "sha256-u8dkwlLQYSgbI1knek1GSA4tz69yr8HObgCtpYzL/Uw=",
8+
integrity = "sha256-h8txtdi9xcNfgjdTBYX+R9CEsxKDucJx+OPvezmkTQM=",
99
patch_strip = 1,
1010
patches = [
11+
# Configure per-compilation-mode strip levels, which the native
12+
# `rust.toolchain` tag's flat `strip_level` string_dict cannot express
13+
# (https://github.com/bazelbuild/rules_rust/issues/3730).
1114
"//bazel:rules_rust_strip_level.patch",
12-
"//bazel:rules_rust_package_alias.patch",
15+
# Fix cross-crate DEP_* env vars being redacted to an `${out_dir}` token
16+
# that downstream crates' build scripts cannot resolve (see patch header).
17+
"//bazel:rules_rust_dep_env.patch",
1318
],
14-
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.69.0/rules_rust-0.69.0.tar.gz"],
19+
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.71.3/rules_rust-0.71.3.tar.gz"],
1520
)
1621

1722
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")

rs/dogecoin/ckdoge/minter/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ rust_test(
4848
crate = ":ckdoge_minter_lib",
4949
data = [":test_vectors"],
5050
env = {
51-
"TEST_VECTORS": "$(locations :test_vectors)",
51+
"TEST_VECTORS": "$(rootpaths :test_vectors)",
5252
},
5353
proc_macro_deps = [
5454
# Keep sorted.

rs/nns/governance/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ rust_ic_test(
458458
env = {
459459
"NEURON_CSV_PATH": "$(rootpath :tests/neurons.csv)",
460460
"TLA_APALACHE_BIN": "$(rootpath @tla_apalache//:bin/apalache-mc)",
461-
"TLA_MODULES": "$(locations :tla_models)",
461+
"TLA_MODULES": "$(rootpaths :tla_models)",
462462
},
463463
proc_macro_deps = MACRO_DEPENDENCIES + ["//rs/tla_instrumentation:proc_macros"],
464464
tags = ["long_test"],
@@ -487,7 +487,7 @@ rust_ic_test(
487487
env = {
488488
"NEURON_CSV_PATH": "$(rootpath :tests/neurons.csv)",
489489
"TLA_APALACHE_BIN": "$(rootpath @tla_apalache//:bin/apalache-mc)",
490-
"TLA_MODULES": "$(locations :tla_models)",
490+
"TLA_MODULES": "$(rootpaths :tla_models)",
491491
},
492492
proc_macro_deps = MACRO_DEPENDENCIES + ["//rs/tla_instrumentation:proc_macros"],
493493
tags = ["long_test"],

rs/nns/integration_tests/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ rust_ic_test_suite_with_extra_srcs(
267267
],
268268
env = DEV_ENV | {
269269
"TLA_APALACHE_BIN": "$(rootpath @tla_apalache//:bin/apalache-mc)",
270-
"TLA_MODULES": "$(locations //rs/nns/governance:tla_models)",
270+
"TLA_MODULES": "$(rootpaths //rs/nns/governance:tla_models)",
271271
"JAVABASE": "$(JAVABASE)",
272272
},
273273
extra_srcs = ["src/lib.rs"],

rs/tla_instrumentation/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ rust_test(
3636
],
3737
env = {
3838
"TLA_APALACHE_BIN": "$(rootpath @tla_apalache//:bin/apalache-mc)",
39-
"TLA_MODULES": "$(locations :tla_models)",
39+
"TLA_MODULES": "$(rootpaths :tla_models)",
4040
},
4141
proc_macro_deps = [
4242
":proc_macros",
@@ -71,7 +71,7 @@ rust_test(
7171
env = {
7272
"JAVABASE": "$(JAVABASE)",
7373
"TLA_APALACHE_BIN": "$(rootpath @tla_apalache//:bin/apalache-mc)",
74-
"TLA_MODULES": "$(locations :tla_models)",
74+
"TLA_MODULES": "$(rootpaths :tla_models)",
7575
},
7676
proc_macro_deps = [
7777
":proc_macros",
@@ -99,7 +99,7 @@ rust_test(
9999
],
100100
env = {
101101
"TLA_APALACHE_BIN": "$(rootpath @tla_apalache//:bin/apalache-mc)",
102-
"TLA_MODULES": "$(locations :tla_models)",
102+
"TLA_MODULES": "$(rootpaths :tla_models)",
103103
},
104104
proc_macro_deps = [
105105
":proc_macros",

0 commit comments

Comments
 (0)