Repository navigation
Conversation
Toolchain configs such as apple_support's set the `gcc` tool path to the path of a compiler wrapper built in the exec configuration, i.e. to `File.path`. rules_cc prefixed every relative tool path with the package of the cc_toolchain, which turned such paths into non-existent ones like external/apple_support++apple_cc_configure_extension+local_config_apple_cc/bazel-out/darwin_arm64-opt-exec-ST-<hash>/bin/external/apple_support+/crosstool/wrapped_clang and thus broke the `CC` Make variable for these toolchains. Tool paths that start with the output directory are now kept as they are.
fmeum
force-pushed
the
generated-tool-paths
branch
from
September 24, 2026 14:19
2a7cec9 to
f15e957
Compare
fmeum
commented
Sep 24, 2026
fmeum
commented
Sep 24, 2026
fmeum
marked this pull request as ready for review
September 24, 2026 14:52
fmeum
added a commit
to buildbuddy-io/bazel_env.bzl
that referenced
this pull request
Sep 24, 2026
With Bazel 10, apple_support's C++ toolchain is the default on macOS. Its `$(CC)` is a `wrapped_clang` built in the exec configuration, which needs the toolchain's action environment (`DEVELOPER_DIR`, `SDKROOT`) to run. #121 added support for this, but its title only mentions a dependency bump, so this PR's title stands in for it in the release notes. #121 also accidentally introduced a broad version of the rlocation heuristic that this PR narrows to the `external/<repo>/bazel-out/...` shape rules_cc currently produces and marks as a workaround for bazelbuild/rules_cc#901.
keith
approved these changes
Sep 24, 2026
trybka
approved these changes
Sep 24, 2026
This was referenced Oct 8, 2026
Open
Member
|
Is this one imported? The internal CL is gone |
Collaborator
|
It still exists internally, stuck on some tests that were misbehaving last week |
AleDema
pushed a commit
to AleDema/ic
that referenced
this pull request
Nov 18, 2026
Upgrades `rules_cc` from 0.2.22 to [0.2.28](https://github.com/bazelbuild/rules_cc/releases/tag/0.2.28), its latest release. Under Bazel 9, `rules_cc` implements the C/C++ rules and `cc_common`, and hermetic-llvm assembles its toolchains with rules_cc's rule-based toolchain API. So this bump touches how every C/C++ compile and every link (Rust links included) is configured. On Linux it changes no compile, link or rustc command line, and the unstamped release artifacts are byte-identical to master. On macOS, native targets move to apple_support's toolchain. I couldn't test that here; only this PR's darwin CI job covers it, and it passed (details below). The separate PR dfinity#12160 (llvm 0.8.27) makes the same one-line bump, because llvm 0.8.27 requires rules_cc >= 0.2.25. ## Changes - **`MODULE.bazel`**: version bump. BCR's `rules_cc/0.2.28` carries only its version patch. Two modules change in the resolved graph: `rules_cc` goes from 0.2.22 to 0.2.28, and `apple_support` from 2.5.2 to 2.9.1. rules_cc has depended on apple_support since 0.2.25 ([bazelbuild/rules_cc@679c0e4](bazelbuild/rules_cc@679c0e4)) and has required 2.9.1 since 0.2.26 ([bazelbuild/rules_cc#903](bazelbuild/rules_cc#903)). Before this, apple_support resolved to 2.5.2, the version Bazel 9.3.2's builtin `bazel_tools` module requests. protobuf, rules_apple, rules_rust and the other modules that depend on it ask for 1.x versions. Because apple_support now provides the macOS C++ toolchain (next section), a Bazel upgrade can change that toolchain too. No other module changes version, and `bazel mod graph` prints no version warnings for the root module's direct dependencies. - **`MODULE.bazel`**, comment at the macOS `register_toolchains` entries: names the toolchain that native macOS targets now get, which is apple_support's (next section). ## Upstream changes that touch our setup The release notes of 0.2.25 to 0.2.28 cover everything after 0.2.22 (0.2.23 and 0.2.24 were tagged but never released or published to the BCR). Where they were thin, I diffed the two release tarballs for the parts we use. - **The C++ toolchain type is unchanged.** `cc/use_cc_toolchain.bzl` is byte-identical in both versions, so `use_cc_toolchain()` still requests `@bazel_tools//tools/cpp:toolchain_type`, which every rules_cc rule also uses. That is the type the hermetic-llvm wrapper toolchains in `//bazel` register under. This matters because rules_rust requests that type with `mandatory = False`, so a mismatch would silently resolve no C++ toolchain. The compile and link command lines below are unchanged, which confirms that the hermetic toolchain still resolves. - **macOS: native targets now use apple_support's toolchain.** Under Bazel 9, rules_cc no longer autodetects a toolchain on macOS ([bazelbuild/rules_cc#755](bazelbuild/rules_cc#755), in 0.2.25). `@local_config_cc_toolchains` is empty there unless `BAZEL_USE_LEGACY_MACOS_TOOLCHAIN=1` is set. The arm64-darwin builds (pocket-ic, ic-admin, sns, and `//rs/...`/`//packages/...` in the darwin job) now resolve to the toolchain apple_support registers. The x86_64-darwin pocket-ic cross build (`--platforms=//:macos-intel`) already used that toolchain, because rules_cc's autodetected one only matched the host CPU. apple_support 2.9.0 made that its rules-based toolchain ([bazelbuild/apple_support#645](bazelbuild/apple_support#645); `APPLE_SUPPORT_RULES_BASED_TOOLCHAIN=0` opts out). Two checks: - rules_cc 0.2.27 has the fix that the generated compiler wrappers of apple_support >= 2.8.4 need for `$(CC)` ([bazelbuild/rules_cc#901](bazelbuild/rules_cc#901)). - The known archiver problem for Rust ([bazelbuild/apple_support#685](bazelbuild/apple_support#685), [bazelbuild/rules_rust#4336](bazelbuild/rules_rust#4336)) starts with apple_support 2.10, which renames the archiver to `apple-support-ar-wrapper`. In 2.9.1 it is still called `libtool`, so rules_rust's build-script runner still unsets `AR` and cc-rs uses the system `ar`. If the darwin job breaks, either `--repo_env` setting above, on a `common:macos` line in `bazel/conf/.bazelrc.build`, is a fallback. - **Module map names now carry `@@` for external targets** ([bazelbuild/rules_cc@3d6b6ac](bazelbuild/rules_cc@3d6b6ac)). For example, `lmdb.cppmap` now declares `module "@@+http_archive+lmdb//:lmdb"` instead of `module "+http_archive+lmdb//:lmdb"`; main-repository names are unchanged. hermetic-llvm enables `module_maps` but not `layering_check`, so no compile command line mentions these names. But each target's `.cppmap` is an input of its compile actions, so C/C++ compiles miss the cache once after this upgrade. That includes hermetic-llvm's from-source runtimes. - **`CcToolchainInfo`'s `compiler/ar/ld/strip/objcopy/gcov_executable` fall back to the toolchain's action-config tools** ([bazelbuild/rules_cc#739](bazelbuild/rules_cc#739)). hermetic-llvm has no `tool_paths`, so these used to be empty. Of these fields, rules_foreign_cc reads only `ld_executable`, which its `configure_make` and `make` rules export as `LD`. So all six of our builds that use those rules now also export `LD=<hermetic clang++>`, and that is the only change in their build scripts: - jemalloc, e2fsprogs, dosfstools and mtools are in the release graph, and what we ship doesn't change: the replica links jemalloc, and the IC-OS images are built with `mke2fs`, `fuse2fs`, `mkfs.fat` and `mcopy`, and both are byte-identical. - openssl and dnsmasq are not in the release graph. openssl is a `configure_make` that runs OpenSSL's own `config`, and the openssl-sys and libssh2-sys build scripts use it. dnsmasq is a `make` that local system tests use. Neither build uses `LD`: OpenSSL's `Configure` records it, but only its Windows makefile template reads it, and dnsmasq's Makefile links with `$(CC)`. - **The rule-based `cc_toolchain` defaults `target_libc` to `glibc` on Linux** (it was `""`; [bazelbuild/rules_cc#792](bazelbuild/rules_cc#792)). This changes `CcToolchainInfo.libc`, the `$(GLIBC_VERSION)` make variable and the new `@rules_cc//cc/libc` config settings. Nothing in this repo, rules_rust or rules_foreign_cc reads them. - **Solib symlinks are now created in Starlark** ([bazelbuild/rules_cc@ebe5632](bazelbuild/rules_cc@ebe5632)), with the same mangled paths. The toolchain's runtime-library symlinks only change mnemonic, from `SolibSymlink` to `Symlink`. `guest_vm_runner` links libvirt and devmapper through such symlinks; its RUNPATH entries are unchanged, and it is byte-identical in the HostOS image. - **The autodetected Linux toolchain** (only used with `--hermetic_cc=false`, i.e. `--config=afl`) now detects `target_libc` (`glibc` instead of `local`). For clang it also selects the linker with `--ld-path=` ([bazelbuild/rules_cc#935](bazelbuild/rules_cc#935)) and adds `-B` for the linker directory ([bazelbuild/rules_cc#943](bazelbuild/rules_cc#943)). In the dev container that toolchain detects `/usr/bin/gcc`, and its link flags are unchanged. - **New analysis errors:** absolute paths in `includes` (ours are relative), and disallowed `copts` (a list toolchains opt into; neither of ours does). `bazel build //... --nobuild` passes. ## Verification All in the dev container: - `bazel mod graph`: only `rules_cc` (0.2.28) and `apple_support` (2.9.1) change. The only warning is the pre-existing `rules_qemu` `use_repo` one. - `bazel mod explain apple_support --include_builtin --verbose` at both versions: on master, `bazel_tools` requests 2.5.2, and protobuf, re2, rules_apple, rules_swift, swift_argument_parser and rules_rust request 1.11.1 to 1.24.1. With this PR, rules_cc's 2.9.1 wins. - `bazel build //... --nobuild`: all 3387 targets analyze. - The Linter job's checks pass: shfmt, ruff, buf, DFINITY-capitalization, do-not-merge, buildifier, gazelle and buf-breaking. The buildifier, shfmt, ruff and gazelle autofixes leave the tree clean. - Action keys: I compared `bazel aquery` of the release artifacts' graph (the targets of the byte-identity check below; 29,297 actions) at 0.2.22 and 0.2.28. No `CppCompile`, `CppLink`, `CppArchive`, `Rustc`, `CargoBuildScriptRun` or `Genrule` key changes. The keys that do change: - 432 `CppModuleMap` writes (the `@@` names above). - 6 rules_foreign_cc build scripts (`LD`): jemalloc in three configurations, e2fsprogs, dosfstools and mtools. - 731 runfiles `_repo_mapping` writes. Only 4 of the 1,496 manifests differ in content: rules_cc no longer maps `rules_python`, which became a dev dependency upstream. - 21 toolchain runtime-library symlinks (mnemonic only, same paths). - These build: - `@lmdb//:liblmdb`, `@zstd//:zstd_cli` and `@pigz` (`cc_library`/`cc_binary`). - `//:mke2fs`, `//:fuse2fs`, `@dosfstools//:mkfs.fat` and `@mtools//:mcopy` (rules_foreign_cc configure_make and meson). - `//rs/ic_os/networking/nss_icos`, `//rs/ic_os/os_tools/guest_disk`, `//rs/ic_os/os_tools/guest_vm_runner` and `//rs/canister_sandbox`. - `//rs/pocket_ic_server:pocket-ic-server`. - The NNS governance and ICRC-1 ledger canisters (wasm32). - These tests pass: - `guest_vm_runner_test` (links libvirt and devmapper through `cc_import`, and runs `mkfs.fat` and `mcopy`). - `guest_disk_lib_test` (libcryptsetup). - `artifact_pool_test` (lmdb). - `canister_sandbox:backend_lib_test`. - The `ic_config` and `hmac` doc tests. - `nss_icos`, our only `rust_shared_library`, still links the static LLVM libunwind: its 18 `_Unwind_*` symbols are defined locally, and every undefined dynamic symbol is a versioned glibc one. - Outside the release graph, I compared the openssl and dnsmasq build scripts at 0.2.22 and 0.2.28 (`bazel aquery --include_file_write_contents`). The only change is the added `LD`, and the OpenSSL 3.4.0 and dnsmasq 2.92 sources don't use it on Linux (see above). `@openssl//:openssl`, `@dnsmasq//:dnsmasq` and `@crate_index//:ssh2` build, including the openssl-sys and libssh2-sys build scripts that use openssl. - `bazel build --config=afl` of `//rs/fuzzers/stable_structures:stable_structures_multiple_ops_persistent` succeeds. Its rustc actions have the same keys as with 0.2.22. - **Byte identity:** I built the unstamped release artifacts and compared them with a master build. That covers the IC-OS bundles `ci/container/build-ic.sh --icos` builds (GuestOS disk and update, HostOS update, SetupOS, GuestOS recovery update) plus `//publish/binaries:bundle` and `//publish/canisters:bundle`. All 133 output files are byte-identical. That build ran 1,252 actions locally: 1,225 in the Linux sandbox, among them C/C++ compiles and the four rules_foreign_cc builds, plus 27 IC-OS steps, which `--strategy_regexp=ic-os[:/].*=local` runs unsandboxed. Everything else was a cache hit or an internal action. - Not verified locally: macOS (the "Bazel Test arm64-darwin" job builds pocket-ic for arm64 and x86_64, `//rs/...` and `//packages/...` with apple_support's toolchain) and Linux arm64. CI covers those, plus the full build and test suite. This PR's CI run on 0eefd8b passed, including "Bazel Test arm64-darwin" and "Bazel Test arm64-linux". 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_compute_tool_pathsprefixes every relative tool path with the package of thecc_toolchain, which turns exec-cfg paths into non-existent ones. With apple_support 2.8.4, which Bazel@HEAD now bundles and thus selects by default on macOS,$(CC)expands to the nonsensicalinstead of
This PR keeps tool paths that start with the output directory as they are.