Skip to content

chore(bazel): upgrade buildifier_prebuilt from 8.2.0.2 to 10.2.0 - #12154

Merged
basvandijk merged 2 commits into
masterfrom
bas/buildifier-prebuilt-10.2.0
Nov 18, 2026
Merged

basvandijk merged 2 commits into
masterfrom
bas/buildifier-prebuilt-10.2.0

Conversation

@basvandijk

@basvandijk basvandijk commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Upgrades buildifier_prebuilt from 8.2.0.2 to 10.2.0, its latest release. This moves buildifier itself from 8.2.0 to 10.2.0; buildtools has no 9.x release. Buildifier 10.2.0 formats our files exactly like 8.2.0, so no file is reformatted. It does add a default lint warning that would fail the CI Linter job. This PR turns that warning off in a new .buildifier.json at the repository root. Every buildifier run inside the checkout reads that file, so CI, the pre-commit targets and the VS Code integration all lint with the same warnings.

Changes

  • MODULE.bazel: version bump. BCR's buildifier_prebuilt/10.2.0 has no patches. Its new bazel_features 1.45.0 requirement is already met by the 1.50.0 we resolve. Its other requirements (bazel_skylib 1.3.0, platforms 0.0.11, rules_shell 0.6.1) are at or below what we already use. In bazel mod graph, only buildifier_prebuilt itself changes.

  • .buildifier.json (new): {"warnings": "-make-location"} removes make-location from buildifier's default warnings (see below). Buildifier loads this file by itself. It looks in its working directory and the directories above it, and command-line flags override what the file sets. So the file applies to:

    • //bazel:buildifier (aliased as //:buildifier and //pre-commit:buildifier-fix) and //bazel:buildifier.check (aliased as //pre-commit:buildifier-check). Their runner changes to the workspace root before it runs buildifier.
    • The VS Code integration. .vscode/settings.json points bazel.buildifier.executable at @buildifier_prebuilt//:buildifier. The recommended bazelbuild.vscode-bazel extension lints open BUILD and .bzl files with bazel run @buildifier_prebuilt//:buildifier -- --format=json --mode=check --path=<file> --lint=warn. It runs that from the VS Code workspace folder and passes no --warnings. In 10.2.0 that target runs buildifier from the directory bazel run was started in (see below), so buildifier finds the file. A lint_warnings attribute on our two targets wouldn't reach this integration.
    • Any other buildifier run from inside the checkout.

    It uses the warnings key, not warningsList. A --warnings flag replaces warnings, but buildifier appends warningsList to the flag's value. That fails when the flag lists categories without a + or - prefix, as --warnings=all does.

  • bazel/BUILD.bazel: a comment next to the two buildifier targets. It says where their lint warnings are set, why there and not with lint_warnings, and why make-location is off, since JSON can't hold that comment.

Upstream changes that touch our setup

  • New default lint warning make-location. It was added for BUILD files in v10.0.1 (bazel-contrib/buildtools#1484) and extended to .bzl files in v10.2.0 (#1526). It flags every string that contains $(location or $(locations, and buildifier can't fix it automatically. With only the version bump, //pre-commit:buildifier-check reports 114 of these in 28 files, and nothing else.

    • Why I excluded it instead of rewriting the uses: the rewrite isn't mechanical. Bazel documents $(location) as a synonym for either $(execpath) or $(rootpath), depending on the attribute being expanded. Our uses are in genrule commands, rules_rust rustc_env/build_script_env, test env, binary args, and strings that macros pass on to other rules. Each one needs its own check. A wrong choice still analyzes fine and only fails when the action or test runs.
    • Scope: the 28 files belong to five different code-owner teams (table below).
    • Follow-up: migrate the uses, then remove the setting from .buildifier.json. Until then, the exclusion also hides new uses.
    The 28 files, with their number of findings and their code owners
    File Findings Code owners
    bazel/canbench.bzl 2 infra
    bazel/canisters.bzl 8 infra
    bazel/defs.bzl 1 infra
    bazel/download.bzl 2 infra
    bazel/fuzz_testing.bzl 2 infra, core-protocol
    bazel/inject_version_into_wasm_tests/BUILD.bazel 3 infra
    bazel/mainnet-icos-images.bzl 1 infra
    bazel/prost.bzl 2 infra
    ic-os/bootloader/BUILD.bazel 1 node
    ic-os/components/conformance_tests/defs.bzl 2 node
    ic-os/defs.bzl 17 node
    ic-os/dev-tools/bare_metal_deployment/tools.bzl 10 node
    ic-os/setupos/defs.bzl 1 node
    rs/bitcoin/ckbtc/minter/BUILD.bazel 2 defi
    rs/ethereum/cketh/minter/BUILD.bazel 2 defi
    rs/ledger_suite/icp/index/BUILD.bazel 1 defi
    rs/ledger_suite/icrc1/index-ng/BUILD.bazel 1 defi
    rs/nervous_system/patch_canister_did/defs.bzl 2 governance-team
    rs/nervous_system/tools/sync-with-released-nervous-system-wasms/BUILD.bazel 1 governance-team
    rs/nns/handlers/lifeline/impl/BUILD.bazel 4 governance-team
    rs/nns/test_utils/golden_nns_state/BUILD.bazel 1 governance-team
    rs/pocket_ic_server/BUILD.bazel 38 core-protocol
    rs/registry/admin/BUILD.bazel 2 governance-team
    rs/tests/system_tests.bzl 1 infra
    rs/universal_canister/impl/BUILD.bazel 3 core-protocol
    third_party/BUILD.miracl-core.bazel 2 infra
    third_party/BUILD.pebble-challtestsrv.bazel 1 infra
    third_party/BUILD.pebble.bazel 1 infra
  • allowed-symbol-load-locations, the other new default warning (bazel-contrib/buildtools#1318, v8.5.1). It only checks symbols listed in a custom tables file. We don't pass add_tables, so it never fires.

  • positional-args was rewritten (bazel-contrib/buildtools#1393, v8.5.1). It now follows load()s to decide whether a called function is a rule or macro, and also checks nested calls. It finds nothing in our BUILD files.

  • Formatter changes don't change any of our files: bazel run //:buildifier with 10.2.0 leaves the tree unchanged. They cover:

    • type annotations
    • comment placement
    • sorting of visibility() arguments in .bzl files (#1452); we have no visibility() calls
    • BUILD formatting for *.BUILD.bazel files (#1433), plus REPO.bazel and VENDOR.bazel; we have none of these files
  • The runner script that bazel run executes for our two buildifier targets changed in two ways. Neither changes the set of files buildifier checks.

    • The .git exclusion is now a find -prune instead of a ! -path filter (keith/buildifier-prebuilt#127, #174).
    • find now hands the files to buildifier with -exec ... {} + instead of piping them to xargs, and also collects *.star files (#168). We have no *.star files, and a failing check still makes the target exit non-zero (see the probe below).
  • The @buildifier_prebuilt//:buildifier binary target, which the VS Code integration runs, is now a bash script (keith/buildifier-prebuilt#162, 8.5.1.3).

    • It used to be a symlink to the buildifier binary, so bazel run started buildifier in the target's runfiles tree.
    • The script changes to $BUILD_WORKING_DIRECTORY, the directory bazel run was started in, and then execs buildifier with the same arguments.
    • vscode-bazel sends the file's content on stdin, together with --path set to the file's path relative to the workspace. So the working directory doesn't change which file gets checked. It does decide which .buildifier.json buildifier finds.
  • The exec platform of the buildifier rule and of the binary target (keith/buildifier-prebuilt#124, 8.2.1; #146, 8.5.1.3).

    • In 8.2.0.2 the rule pinned the exec platform with exec_compatible_with = HOST_CONSTRAINTS, and the binary target didn't constrain it.
    • On Bazel 9, both now request @bazel_tools//tools/test:default_test_toolchain_type instead, which ties the exec platform to the target platform.
    • Our --host_platform and --platforms are both //:linux-glibc-2.31, so it still picks the host's binary (buildifier_linux_amd64 in the dev container).

Verification

All in the dev container:

  • bazel mod graph: only buildifier_prebuilt changes (8.2.0.2 to 10.2.0). bazel_features stays at 1.50.0. The only warning is the existing rules_qemu use_repo one.
  • bazel run //pre-commit:buildifier-check:
    • passes on master
    • with only the version bump, fails with exactly 114 make-location findings in 28 files and no formatting diff
    • with this PR, passes
    • with this PR but .buildifier.json removed, fails again with the same 114 findings, so the file is what turns the warning off
  • bazel run //:buildifier with 10.2.0 changes no files.
  • Generated runners: neither passes --warnings (ARGS=('-mode=fix' '-v=false' '-lint=fix') and ARGS=('-mode=diff' '-v=false' '-lint=warn')). Both contain \( -path './.git/*' \) -prune -o.
  • Editor integration: I ran the command that vscode-bazel runs for lint diagnostics (bazel run @buildifier_prebuilt//:buildifier -- --format=json --mode=check --path=<file> --lint=warn < <file>) on rs/pocket_ic_server/BUILD.bazel and ic-os/defs.bzl:
    • from the workspace root: no warnings
    • from the workspace root with .buildifier.json removed: 38 and 17 make-location warnings
    • from rs/: no warnings, so buildifier also finds the file from a subdirectory
    • with an explicit --warnings=all: 38 make-location and 25 unsorted-dict-items warnings, so a --warnings flag still overrides the file
  • Probe, in a temporary package (deleted afterwards) with a badly formatted genrule, an unused load() and a $(location) in cmd:
    • buildifier-check failed with a diff and a load warning, and no make-location warning.
    • buildifier-fix fixed both problems.
    • buildifier-check then passed.
  • CI Linter steps (from ci-pr-only.yml):
    • These all pass: shfmt-check, ruff-check, buf-check, DFINITY-capitalization-check, do-not-merge-check, buildifier-check, gazelle-check and buf-breaking-check.
    • After that, the autofixes (buildifier-fix, shfmt-fix, ruff-fix, :rustfmt and :gazelle) leave the working tree unchanged.
  • bazel build //... --nobuild: all 3387 targets analyze.
  • Release artifacts: I didn't run the byte-identity build, because nothing they're built from changes:
    • buildifier_prebuilt is a dev dependency.
    • bazel cquery 'deps(//ic-os/guestos/envs/prod:bundle-update + //publish/binaries:bundle)' returns 107,118 configured targets, and none of them comes from it. That output includes resolved toolchains, such as the Rust and Python ones.
    • No other module's resolved version changes, and no Bazel target uses .buildifier.json.
  • Not verified on macOS. The exec-platform change also applies there, and CI doesn't cover it either. The only macOS job, the darwin leg of bazel-test-arm64 in ci-main.yml, builds three //publish/binaries targets, //rs/... and //packages/..., and none of them uses the buildifier targets. On Linux, CI covers the full build and tests.

🤖 Generated with Claude Code

This moves buildifier from 8.2.0 to 10.2.0. It formats the repo exactly
as before, but its new default make-location lint flags all 114
"$(location ...)"/"$(locations ...)" uses in 28 BUILD and .bzl files and
has no automatic fix. Exclude it from both buildifier targets: replacing
those uses means choosing $(execpath ...) or $(rootpath ...) for each one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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.

🟢 Approval recommended

No active review issues were identified for the buildifier upgrade.

No open issues 🎉

What changed in this PR

Upgrades the repository’s Bazel formatter and linter while preserving existing $(location) usage and keeping check and autofix targets aligned.

Changes:

  • Bumps buildifier_prebuilt from 8.2.0.2 to 10.2.0.
  • Disables the new make-location warning through a shared warning configuration, deferring location-expression migration until each use can be checked.
File Description
MODULE.bazel Upgrades the development-only buildifier_prebuilt dependency.
bazel/​BUILD.bazel Applies the shared make-location exclusion to both buildifier targets and documents its rationale.

Review effort: Balanced

The vscode-bazel extension that .vscode/extensions.json recommends lints
open BUILD and .bzl files by running @buildifier_prebuilt//:buildifier
(set in .vscode/settings.json) with buildifier's default warnings. The
lint_warnings attribute of //bazel:buildifier and
//bazel:buildifier.check didn't reach it, so editors would flag the 114
make-location findings that CI ignores.

Buildifier loads a .buildifier.json from its working directory or a
directory above it, and command-line flags override it. Both rule
targets run buildifier from the workspace root, and with this upgrade
the binary target runs it from the directory that `bazel run` was
started in. So a .buildifier.json at the repository root configures
every buildifier run inside the checkout. Set the exclusion there and
drop lint_warnings from the two targets.

Use the "warnings" key rather than "warningsList". A --warnings flag
replaces "warnings", but buildifier appends "warningsList" to the flag's
value, which fails when the flag names categories without a +/- prefix,
such as --warnings=all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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.

🟢 Approval recommended

No active review issues are reported for the Buildifier tooling update.

No open issues 🎉

Review effort: Balanced

@basvandijk
basvandijk marked this pull request as ready for review November 18, 2026 08:11
@basvandijk
basvandijk requested review from a team as code owners November 18, 2026 08:11
@basvandijk
basvandijk added this pull request to the merge queue Nov 18, 2026
Merged via the queue into master with commit 4b3e8e8 Nov 18, 2026
46 of 47 checks passed
@basvandijk
basvandijk deleted the bas/buildifier-prebuilt-10.2.0 branch November 18, 2026 12:08
basvandijk added a commit that referenced this pull request Nov 18, 2026
master changed the lines around this PR's aspect_bazel_lib bump: bazel_skylib
1.9.2 (#12150), rules_shell 0.10.0 (#12152) and buildifier_prebuilt 10.2.0
(#12154). The resolution takes those three versions from master and keeps this
PR's aspect_bazel_lib 2.22.5 with its comment and single_version_override.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
AleDema pushed a commit to AleDema/ic that referenced this pull request Nov 18, 2026
…#12155)

Upgrades `aspect_bazel_lib` from 2.19.3 to
[2.22.5](https://github.com/bazel-contrib/bazel-lib/releases/tag/v2.22.5),
its latest release. 2.x is the last `aspect_bazel_lib` line: from 3.0 on
the module is published as `bazel_lib`, which is already in our graph at
3.2.2 (through `llvm`, `rules_qemu`, `rules_distroless`,
`rules_foreign_cc`, `tar.bzl` and `yq.bzl`).

The bump comes with a small patch to `aspect_bazel_lib`'s
`MODULE.bazel`. Without it, `aspect_bazel_lib`'s own toolchains would
take over the toolchain types that it now aliases from `bazel_lib` and
`tar.bzl` (since 2.21.1 and 2.22.0). Then hermetic-llvm would assemble
its toolchain with `aspect_bazel_lib`'s tools instead of `bazel_lib`'s,
and every C/C++/Rust build would break as soon as `bazel_lib` >= 3.8.0
enters the graph (details below). With the patch, the build graph of the
release artifacts resolves the same toolchains as on master, and the
release artifacts are byte-identical.

## Changes

- **`MODULE.bazel`**: version bump, plus a `single_version_override`
that applies the patch below and pins 2.22.5. The pin is needed because
Bazel applies a patch to a module's `MODULE.bazel` to every version of
the module that it visits during resolution, and `rules_oci` 2.0.0 asks
for 2.7.2, where the patch doesn't apply.
- The pin also holds `aspect_bazel_lib` at 2.22.5 when another module
asks for a newer version, and Bazel doesn't warn about that. The comment
above the override says so and points to `bazel mod explain
aspect_bazel_lib --verbose`, which marks the requests that the pin
overrides, e.g. `[email protected] # (was 2.7.2, cause
single_version_override)` under `rules_oci` 2.0.0. Nothing asks for more
than 2.22.5 today. In our graph, `rules_oci` 2.0.0 asks for 2.7.2 and
`jq.bzl` 0.1.0 for 2.8.1. Among the latest releases of our direct
dependencies, the highest request is 2.21.1 (`rules_oci` 2.3.5).
- BCR's `aspect_bazel_lib/2.22.5` carries only its usual release patches
(version stamp, Go dev dependencies).
- 2.22.5 adds a dependency on `bazel_lib` 3.0.0 and asks for `tar.bzl`
0.5.1, `bazel_skylib` 1.8.1 and `stardoc` 0.7.1. We already resolve
`bazel_lib` 3.2.2, `tar.bzl` 0.10.4, `bazel_skylib` 1.9.0 and `stardoc`
0.7.2, so no other module's resolved version changes.
- **`bazel/aspect_bazel_lib_aliased_toolchains.patch`** (new): removes 5
of the 9 `register_toolchains` entries from `aspect_bazel_lib`'s
`MODULE.bazel`, those of the five toolchain types that 2.21.1 and 2.22.0
turned into aliases (`copy_directory`, `copy_to_directory`, `coreutils`,
`expand_template` and `tar`). jq, yq, zstd and bats are still
`aspect_bazel_lib`'s own toolchain types and keep their registrations.
The patch applies to the BCR source with no offset or fuzz.

## Why the patch


[bazel-contrib/bazel-lib#1153](bazel-contrib/bazel-lib#1153)
(2.21.1) turned the `tar` toolchain type into an alias of `tar.bzl`'s.
[bazel-contrib/bazel-lib#1216](bazel-contrib/bazel-lib#1216)
(2.22.0) turned the `copy_directory`, `copy_to_directory`, `coreutils`
and `expand_template` toolchain types into aliases of `bazel_lib`'s, so
that rules from both modules create identical actions. But
`aspect_bazel_lib` still registers its own toolchains for all five. It
is a direct dependency of the root module, while `bazel_lib` and
`tar.bzl` are transitive ones, so its registrations come first and win
for every rule that requests one of the shared types. With only the
version bump, `bazel cquery` shows two switches:

- **Release artifacts:** hermetic-llvm assembles its resource directory,
crt objects and the libc++/libc++abi/libunwind/glibc search directories
with `bazel_lib`'s `copy_file` and `copy_to_directory`. These 22
`CopyFile` and 86 `CopyToDirectory` actions (across configurations) are
the only users of these toolchains in the build graph of the release
artifacts. They would switch from `bazel_lib` 3.2.2's tools to
`aspect_bazel_lib`'s, e.g. from uutils coreutils 0.5.0 to 0.1.0.
- **Test and Rosetta images:** the `tar.bzl` and `rules_distroless`
targets would switch from `tar.bzl`'s bsdtar
(hermeticbuild/bsdtar-prebuilt v3.8.1-3) to `aspect_bazel_lib`'s
(aspect-build/bsdtar-prebuilt v3.8.1). These are
`//rs/tests:{sh,awk,ca_certificates,dpkg_status,passwd,ubuntu_packages_tar}`
and the `passwd` layers in `//rs/rosetta-api/{icp,icrc1}` and
`//rs/tests/httpbin-rs`. For `sh`, `awk` and the `passwd` targets,
`tar.bzl`'s `tar` writes the `mtree` with `bazel_lib`'s
`expand_template`, and those actions would switch to
`aspect_bazel_lib`'s `expand_template` binary as well.

That alone would be harmless today. But `bazel_lib` 3.8.0
([bazel-contrib/bazel-lib#1310](bazel-contrib/bazel-lib#1310))
passes `copy_to_directory`'s arguments in a params file, which
`aspect_bazel_lib`'s binary doesn't accept. So once any module brings in
`bazel_lib` >= 3.8.0, every one of those `CopyToDirectory` actions
fails, and with them every C/C++/Rust build. This is
[bazel-contrib/bazel-lib#1312](bazel-contrib/bazel-lib#1312).
The latest releases of our direct dependencies ask for at most
`bazel_lib` 3.2.2, so this would only bite later.

Upstream fixed dfinity#1312 on its 2.x branch with
[bazel-contrib/bazel-lib#1313](bazel-contrib/bazel-lib#1313),
merged on 2026-11-14. No release has it yet: 2.22.5 is still the latest
2.x release. dfinity#1313 removes only the `copy_directory`,
`copy_to_directory` and `coreutils` registrations, which covers the
switch in the release artifacts but not the one in the images. This
patch also removes the `expand_template` and `bsd_tar` registrations.
That keeps the image targets above on the toolchains they use on master,
and all five aliased types resolve the same way.

With the patch, each aliased type resolves to the toolchains of the
module that defines it:

- The build graph of the release artifacts resolves exactly the
toolchains it does on master.
- The `tar.bzl` and `rules_distroless` targets above keep `tar.bzl`'s
bsdtar and `bazel_lib`'s `expand_template`, as on master.
- `rules_oci` 2.0.0's `oci_image` and `oci_load`, and our
`expand_template`, ask for `aspect_bazel_lib`'s alias types. So they now
get `tar.bzl`'s bsdtar and `bazel_lib`'s coreutils (0.5.0) and
`expand_template`. On master they get `aspect_bazel_lib`'s bsdtar 3.7.9
and coreutils 0.0.27.
- Both sets of toolchains provide the same fields (`tarinfo.binary`,
`coreutils_info.bin`, `expand_template_info.bin`,
`copy_to_directory_info.bin`). The `expand_template`, `copy_directory`
and `copy_to_directory` Go tools of `aspect_bazel_lib` 2.22.5 and
`bazel_lib` 3.2.2 are built from the same `main.go` files. Only their
shared helper package differs: `bazel_lib`'s also tries reflink copies
on Linux. The outputs are byte-identical (see Verification).

## Upstream changes that touch our setup

- Toolchain aliases: `tar`
([dfinity#1153](bazel-contrib/bazel-lib#1153), 2.21.1),
and `copy_directory`, `copy_to_directory`, `coreutils` and
`expand_template`
([dfinity#1216](bazel-contrib/bazel-lib#1216), 2.22.0).
See above.
- `aspect_bazel_lib`'s own bsdtar moves from 3.7.9 to 3.8.1
([dfinity#1126](bazel-contrib/bazel-lib#1126), 2.20.0),
and its coreutils from 0.0.27 to 0.1.0
([dfinity#1136](bazel-contrib/bazel-lib#1136), 2.21.0).
With the patch, nothing in our build uses these two any more.
- `expand_template` now adds the runfiles of its `data` to its own
([dfinity#1171](bazel-contrib/bazel-lib#1171), 2.21.2).
Our two `expand_template` targets,
`//rs/rosetta-api/{icp,icrc1}:stamped`, have no `data`.
- `copy_directory`, `copy_to_directory`, `copy_file` and `copy_to_bin`
now forward to `bazel_lib`'s implementations
([dfinity#1229](bazel-contrib/bazel-lib#1229),
[dfinity#1233](bazel-contrib/bazel-lib#1233), 2.22.4
and 2.22.5). We don't use them directly, only through `rules_oci`.
- Not relevant for us: jq stays 1.7, and zstd stays 1.5.6 (the same
binaries from a new URL). yq moves to 4.45.2, but nothing in our build
uses `aspect_bazel_lib`'s yq toolchain.

## Verification

All in the dev container:

- `bazel mod graph`: compared with master, only `aspect_bazel_lib`
changes (2.19.3 → 2.22.5). There are no new warnings; the existing
`rules_qemu` `use_repo` warning is unchanged.
- **After merging master**: dfinity#12150, dfinity#12152 and dfinity#12154 changed the
`bazel_skylib`, `rules_shell` and `buildifier_prebuilt` lines around
this PR's `aspect_bazel_lib` bump. The merge keeps master's versions of
those three and this PR's `aspect_bazel_lib` 2.22.5 with its comment and
override. Against master, `bazel mod graph` still changes only
`aspect_bazel_lib`. `bazel mod explain aspect_bazel_lib --verbose` lists
only the root module and `rules_oci` 2.0.0 (asking for 2.7.2), so no
module asks for a newer version that the pin would override. `bazel
build //... --nobuild` analyzes all 3389 targets, and `bazel run
//:buildifier` changes nothing.
- `bazel build //... --nobuild`: all 3387 targets analyze.
- Linter job:
`//pre-commit:{shfmt-check,ruff-check,buf-check,DFINITY-capitalization-check,do-not-merge-check,buildifier-check,gazelle-check,buf-breaking-check}`
pass. `buildifier-fix`, `shfmt-fix`, `ruff-fix` and `//:gazelle` leave
the tree clean.
- Toolchain resolution: for the release targets below, `bazel cquery
'deps(...)'` returns the same 110,935 configured targets as on master,
with the same toolchain targets. `aspect_bazel_lib` isn't among them.
Without the patch, the `coreutils` and `copy_to_directory` toolchains
switch to `aspect_bazel_lib`'s, as described above.
- **Release artifacts are byte-identical.** I built
`//publish/binaries:bundle`, `//publish/canisters:bundle` and the
unstamped IC-OS bundles that `ci/container/build-ic.sh --icos` builds
(GuestOS prod disk and update, GuestOS recovery update, HostOS prod
update, SetupOS prod). All 133 output files have the same SHA-256 as a
build of master at c712eb2. No sandboxed action ran: apart from 26
actions that run unsandboxed (`local`), every action was a cache hit.
- **The targets that use `aspect_bazel_lib`, or its toolchains through
`rules_oci`, produce byte-identical outputs.** I built these 21 targets,
which cover every kind of use, with 2.19.3 and with this PR in the same
output base. Both builds produce the same 77 files, and the 4 OCI layout
directories have the same structure and file modes:
  - `//rs/tests:{sh,awk}` (`tar`)
- `//rs/tests:{ca_certificates,dpkg_status,passwd,ubuntu_packages_tar}`
(`rules_distroless`)
- the OCI images and `oci_load` tarballs
`//rs/tests:{ubuntu_test_runtime_image_src,ubuntu_test_runtime.tar,static-file-server.tar,minica.tar}`,
`//rs/tests/httpbin-rs:{httpbin_image_src,httpbin.tar}`,
`//rs/rosetta-api/icp:{rosetta_image,rosetta_image.tar}` and
`//rs/rosetta-api/icrc1:{ic_icrc_rosetta_image,icrc_rosetta_image.tar}`
- `//rs/tests:colocate_uvm_config_image`, which packs the test-runtime
image tarball
- the Rosetta push scripts `//rs/rosetta-api/icp:push_rosetta_image` and
`//rs/rosetta-api/icrc1:push_ic_icrc_rosetta_image`
- their `:stamped` tag files, built both unstamped and with `--stamp
--embed_label=...` (which `rosetta-release.yml` passes); with stamping,
`expand_template` runs its toolchain's binary, now `bazel_lib`'s
- I also diffed the `bazel aquery` action keys of everything these
targets depend on, master against this PR. 58 of the 8,363 actions
change, all of them `rules_oci` actions whose tools are now
`bazel_lib`'s and `tar.bzl`'s: the 10 `OCIDescriptor` (`oci_image`) and
6 `OCITarball` (`oci_load`) actions, the 3 `CopyToDirectory` actions
that lay out pulled base images, and the template and runfiles actions
of their scripts. The images, tarballs and scripts they produce are
among the identical files above.
- Not built locally: the other `oci_load` tarballs of pulled images and
the other UVM config images under `//rs/tests` (e.g. `bitcoind.tar`,
`jaeger.tar`, `vector-with-log-fetcher.tar`, `ckbtc_uvm_config_image`).
They use the same rules as `static-file-server.tar`, `minica.tar` and
`colocate_uvm_config_image`.
- Not run locally: the 476 tests that depend on these targets are all
system tests under `//rs/tests`. CI runs them, along with the full build
and test suite.

The second commit changes only comments: the patch header and the
`MODULE.bazel` comment above the override. After it, I re-ran:

- The new patch applies with `patch -F0` (no offset or fuzz) to the
`MODULE.bazel` that the BCR serves for 2.22.5. The result has the same
SHA-256 as with the first commit's patch, and so does the
`aspect_bazel_lib` `MODULE.bazel` that Bazel fetched.
- `bazel mod graph` (depth 1 and full): the same output as before the
commit, with no new warnings. `bazel mod explain aspect_bazel_lib
--verbose` shows `[email protected] # (was 2.7.2, cause
single_version_override)` under `rules_oci` 2.0.0.
- I checked the pin's effect on newer requests in a scratch workspace
whose root module asks for `aspect_bazel_lib` 2.7.2 and depends on
`jq.bzl` 0.1.0, which asks for 2.8.1. With
`single_version_override(version = "2.7.2")`, Bazel resolves 2.7.2
without a warning, and `mod explain --verbose` shows `(was 2.8.1, cause
single_version_override)`. Without the override, it resolves 2.8.1 and
warns that the root module asks for 2.7.2.
- `bazel build //... --nobuild`: all 3387 targets analyze. The
Linter-job checks pass, and the autofixes plus `//:buildifier` leave the
tree clean.
- `bazel cquery 'deps(...)'` returns the same 110,935 configured targets
for the release targets, and the same 53,045 for the targets that use
the module, as before the commit. `bazel aquery`: all 8,363 action keys
in the deps of the 21 targets above are unchanged. So I didn't rebuild
the release artifacts for this commit.

## Follow-ups

- dfinity#12157 (`rules_oci` 2.3.5, which needs `aspect_bazel_lib` >= 2.21.1)
is stacked on this PR, so it lands after it.
- Once an `aspect_bazel_lib` 2.x release includes
bazel-contrib/bazel-lib#1313, this patch no longer applies (its hunk
fails against the 2.x branch). Then reduce it to the `expand_template`
and `bsd_tar` registrations, as the TODO in the patch says, and keep the
version pin. Dropping the patch instead would make the `tar` and
`expand_template` types resolve to `aspect_bazel_lib`'s bsdtar and
`expand_template`, including for the `tar.bzl` and `rules_distroless`
targets above.
- Possibly move our three direct uses of `aspect_bazel_lib`
(`expand_template` in the two Rosetta packages, `tar` in `//rs/tests`)
to `bazel_lib` and `tar.bzl`, its 3.x successors. `rules_oci` 2.x still
depends on `aspect_bazel_lib`, though.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

4 participants