Skip to content

chore: upgrade rules_rust to 0.71.3 - #10632

Merged
basvandijk merged 8 commits into
masterfrom
upgrade-rules-rust-0.71.3
Jul 2, 2026
Merged

chore: upgrade rules_rust to 0.71.3#10632
basvandijk merged 8 commits into
masterfrom
upgrade-rules-rust-0.71.3

Conversation

@basvandijk

@basvandijk basvandijk commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

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).
  • 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).
  • 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 (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.

- Drop bazel/rules_rust_package_alias.patch: the package_alias attribute
  is upstreamed in rules_rust 0.71.3.
- Regenerate 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.
- Repin Cargo Bazel lockfile (checksum only).
@basvandijk basvandijk added the CI_ALL_BAZEL_TARGETS Runs all bazel targets label Jul 2, 2026
@github-actions github-actions Bot added the chore label Jul 2, 2026
@basvandijk
basvandijk marked this pull request as ready for review July 2, 2026 10:29
@basvandijk
basvandijk requested a review from a team as a code owner July 2, 2026 10:29
@github-actions github-actions Bot added the @idx label Jul 2, 2026
Two regressions surfaced by the rules_rust 0.69.0 -> 0.71.3 upgrade:

1. Cross-crate DEP_* env vars broke: 0.71.x redacts the producing build
   script'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, so the token never resolves (libssh2-sys could not
   find zlib.h from libz-sys's DEP_Z_INCLUDE). New
   bazel/rules_rust_dep_env.patch restores exec-root-only redaction for
   dep env files.

2. rustdoc doc tests failed to link with 'running strip: FileNotFound':
   0.71.3 no longer leaks the compile action env (incl. PATH) into
   CrateInfo.rustc_env (bazelbuild/rules_rust#3989), so the generated
   doctest runner script clears the environment without exporting PATH,
   and our zig-wrapper strip hook (hermetic_cc_toolchain_strip.patch)
   could no longer resolve the bare 'strip' name. The wrapper now
   resolves strip to an absolute path with a PATH-based fallback.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the Bazel rules_rust dependency to v0.71.3 and updates the repo’s patch set and Cargo Bazel lockfile to match, aiming to keep existing behavior (notably around strip levels) while adopting the upstreamed package_alias support.

Changes:

  • Bump rules_rust from 0.69.0 to 0.71.3 and update the archive integrity/URL.
  • Remove the now-upstreamed rules_rust_package_alias.patch, regenerate/update rules_rust_strip_level.patch, and add a new rules_rust_dep_env.patch.
  • Repin Cargo.Bazel.json.lock (checksum-only change).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Cargo.Bazel.json.lock Updates the pinned lock checksum after repinning.
bazel/rust.MODULE.bazel Bumps rules_rust version/integrity and updates the applied patch list.
bazel/rules_rust_strip_level.patch Updates the rules_rust patch that overrides strip level handling.
bazel/rules_rust_package_alias.patch Removes the no-longer-needed patch (upstreamed).
bazel/rules_rust_dep_env.patch Introduces a patch intended to fix cross-crate DEP_* env var handling in rules_rust 0.71.x.
bazel/hermetic_cc_toolchain_strip.patch Adjusts hermetic toolchain stripping behavior (notably strip resolution).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bazel/rules_rust_dep_env.patch Outdated
Comment thread bazel/rules_rust_dep_env.patch
Comment thread bazel/rules_rust_strip_level.patch
Comment thread bazel/hermetic_cc_toolchain_strip.patch Outdated
Comment thread bazel/rust.MODULE.bazel
- Add standard 'diff --git' header to rules_rust_dep_env.patch for
  easier auditing and patch-applicator compatibility.
- zig-wrapper: fail with a clear error when no strip binary is found
  instead of falling back to a bare "strip" that cannot resolve
  without PATH.
- Document the purpose of each rules_rust patch inline in
  rust.MODULE.bazel.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Comment thread bazel/rules_rust_strip_level.patch
@basvandijk
basvandijk enabled auto-merge July 2, 2026 13:53
@basvandijk
basvandijk disabled auto-merge July 2, 2026 14:28
rules_rust 0.71.x (bazelbuild/rules_rust#4088) started prefixing every
path expanded from the plural $(locations ...) / $(execpaths ...)
forms with the ${pwd} substitution token, like it already did for the
singular forms. That token is only substituted by the process wrapper
during build actions; nothing substitutes it in a test's runtime
environment (RunEnvironmentInfo), so tests saw literal
'${pwd}/rs/...' paths and failed to open them.

Use $(rootpaths ...) which rules_rust deliberately leaves unmodified
for runtime use and which expands to the same runfiles-relative paths
as $(locations ...) did before 0.71.x for these source files.

Fixes:
//rs/dogecoin/ckdoge/minter:unit_tests
//rs/nns/governance:governance_integration_test
//rs/nns/governance:merge_neurons_test
//rs/nns/integration_tests:integration_tests_src/governance_neurons
//rs/tla_instrumentation:args_test
//rs/tla_instrumentation:multiple_calls_test
//rs/tla_instrumentation:structs_test

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):

  1. Update unreleased_changelog.md (if there are behavior changes, even if they are
    non-breaking).

  2. Are there BREAKING changes?

  3. Is a data migration needed?

  4. Security review?

How to Satisfy This Automatic Review

  1. Go to the bottom of the pull request page.

  2. Look for where it says this bot is requesting changes.

  3. Click the three dots to the right.

  4. Select "Dismiss review".

  5. In the text entry box, respond to each of the numbered items in the previous
    section, declare one of the following:

  • Done.

  • $REASON_WHY_NO_NEED. E.g. for unreleased_changelog.md, "No
    canister behavior changes.", or for item 2, "Existing APIs
    behave as before.".

Brief Guide to "Externally Visible" Changes

"Externally visible behavior change" is very often due to some NEW canister API.

Changes to EXISTING APIs are more likely to be "breaking".

If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.

If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.

Reference(s)

For a more comprehensive checklist, see here.

GOVERNANCE_CHECKLIST_REMINDER_DEDUP

@zeropath-ai

zeropath-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 082d8ae.

Security Overview
Detected Code Changes
Change Type Relevant files
Bug Fix ► Cargo.Bazel.json.lock
Indirectly updates checksum value in lockfile
Enhancement ► bazel/hermetic_cc_toolchain_strip.patch
Modify spawnWindows function signature and adjust strip command building
Enhancement ► bazel/rules_rust_dep_env.patch
Add patch to fix cross-crate DEP_* env vars handling
Enhancement ► cargo/private/cargo_build_script_runner/lib.rs
Change parameter name from out_dir to _out_dir and adjust related logic
Enhancement ► bazel/rules_rust_strip_level.patch
Add per-compilation-mode strip level override and comments
Enhancement ► bazel/rust.MODULE.bazel
Update rules_rust version to 0.71.3 and adjust patch integrations

@zeropath-ai

zeropath-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 082d8ae.

Security Overview
Detected Code Changes
Change Type Relevant files
Bug Fix ► Cargo.Bazel.json.lock
Indirectly updates checksum value in lockfile
Enhancement ► bazel/hermetic_cc_toolchain_strip.patch
Modify spawnWindows function signature and adjust strip command building
Enhancement ► bazel/rules_rust_dep_env.patch
Add patch to fix cross-crate DEP_* env vars handling
Enhancement ► cargo/private/cargo_build_script_runner/lib.rs
Change parameter name from out_dir to _out_dir and adjust related logic
Enhancement ► bazel/rules_rust_strip_level.patch
Add per-compilation-mode strip level override and comments
Enhancement ► bazel/rust.MODULE.bazel
Update rules_rust version to 0.71.3 and adjust patch integrations

@basvandijk
basvandijk enabled auto-merge July 2, 2026 14:49
@basvandijk
basvandijk dismissed github-actions[bot]’s stale review July 2, 2026 14:52

No canister changes.

@basvandijk
basvandijk added this pull request to the merge queue Jul 2, 2026
Merged via the queue into master with commit cc1287f Jul 2, 2026
43 of 45 checks passed
@basvandijk
basvandijk deleted the upgrade-rules-rust-0.71.3 branch July 2, 2026 18:07
github-merge-queue Bot pushed a commit to bazelbuild/rules_rust that referenced this pull request Jul 5, 2026
### The bug

Since the `OUT_DIR` sanitization work (#4050 / #4011, first released in
0.71.x), `outputs_to_dep_env` redacts the producer's `out_dir` to the
generic `${out_dir}` substitution token, the same way `outputs_to_env`
does.

That redaction is only correct for `_bs.env` files, which are consumed
by the target that directly owns the build script (where
`process_wrapper`'s `--out-dir` resolves the token to the right
directory). Dep env (`DEP_*`) files, however, are consumed by
*downstream* crates' build scripts: their runner only substitutes
`${pwd}`, and their own `out_dir` points to a different directory. The
token is therefore left unresolved, or would resolve to the wrong
directory.

Real-world failure: `libssh2-sys`'s build script fails to find `zlib.h`
because `libz-sys`'s `DEP_Z_INCLUDE` contains a literal `${out_dir}`
path component. Found while upgrading `rules_rust` to 0.71.3 in
dfinity/ic (see dfinity/ic#10632, where this fix is currently carried as
a patch).

### The fix

Only substitute the exec root in dep env files and keep the real
`out_dir` path. That path is valid for consumers: the producer's
`out_dir` is a declared input of downstream build script actions.

### Tests

* Unit test
`out_dir_in_dep_env_value_is_not_redacted_to_substitution_token` in
`cargo/private/cargo_build_script_runner/lib.rs`.
* End-to-end regression test `//cargo/tests/dep_env:build_read_out_dir`
mirroring the libz-sys → libssh2-sys scenario: a producer build script
advertises `cargo:include=$OUT_DIR/include` and the consumer build
script asserts `DEP_Z_INCLUDE` points at an existing directory. Fails
without the fix, passes with it.

---

Assisted-by: GitHub Copilot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants