Skip to content

fix(hub-repo): register per-platform toolchain() rules instead of aliases#21

Merged
avrabe merged 1 commit intomainfrom
fix/hub-repo-toolchain-registration
Apr 20, 2026
Merged

fix(hub-repo): register per-platform toolchain() rules instead of aliases#21
avrabe merged 1 commit intomainfrom
fix/hub-repo-toolchain-registration

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 20, 2026

Problem

Downstream projects using rules_verus via:

```starlark
register_toolchains("@verus_toolchains//:all")
```

hit Bazel's ambiguity rule — `:all` is both a wildcard and the name of an existing alias rule in the hub repo. Bazel picks the alias interpretation, which points to only the first platform's underlying target (not even a `toolchain()` rule), so no toolchains are registered:

```
WARNING: The target pattern '@verus_toolchains//:all' is ambiguous:
':all' is both a wildcard, and the name of an existing alias rule;
using the latter interpretation
ERROR: While resolving toolchains for target //:rivet_specs_verify:
No matching toolchains found for types
```

This is blocking Verus CI on rivet (https://github.com/pulseengine/rivet/actions/runs/24649838100/job/72070649411).

Fix

Change the hub repo's generated BUILD.bazel from an alias-based layout to one proper `toolchain()` wrapper per supported platform:

  • Each wrapper references the underlying `verus_toolchain_info` provider.
  • Each wrapper has matching `exec_compatible_with` / `target_compatible_with` constraints.
  • The conflicting alias named `all` is removed.

With no alias shadowing `:all`, Bazel's wildcard-package interpretation takes over and registers all per-platform `toolchain()` rules at once. Native toolchain resolution then selects the correct one based on the exec platform.

Scope

  • 1 file changed (`verus/extensions.bzl`)
  • 44 insertions, 55 deletions
  • No changes to the per-platform repo emitted by `verus/private/repo.bzl` — the `verus_toolchain_info` provider it already exports works as-is.
  • Backwards-compatible for any consumer using `register_toolchains("@verus_toolchains//:all")`.

Test plan

  • `cd rivet/verus && bazel test //:rivet_specs_verify` passes toolchain resolution on Linux CI
  • Local smoke tests still need to be run (no bazel on my machine)

🤖 Generated with Claude Code

…ases

The hub repo's generated BUILD.bazel previously emitted only aliases —
one per platform, plus an alias literally named `all` pointing at just
the first platform's toolchain. Downstream projects doing:

    register_toolchains("@verus_toolchains//:all")

hit Bazel's ambiguity rule (":all" is both a wildcard and an alias
target) and resolved to the alias, which pointed at a non-toolchain()
target. Result: "No matching toolchains found" on any toolchain
resolution attempt.

Fix: drop the alias-based layout and emit one proper `toolchain()`
wrapper per supported platform, each referencing the underlying
`verus_toolchain_info` provider with the matching
exec_compatible_with / target_compatible_with constraints. Remove the
conflicting alias named `all` so Bazel's package-wildcard
interpretation of `:all` takes over and registers every platform's
toolchain, letting native resolution pick the correct one.

Reproduction (before fix):

    cd rivet/verus && bazel test //:rivet_specs_verify
    ERROR: While resolving toolchains for target //:rivet_specs_verify:
    No matching toolchains found for types

With this change, toolchain resolution succeeds on Linux CI runners
and host Darwin runners without further changes to consumer
MODULE.bazel files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant