Skip to content

fix(bazel): un-scope crate_universe extension so @crates resolves downstream - #75

Merged
jayakasadev merged 1 commit into
mainfrom
ci-konfig-crate-universe-non-dev
Jun 16, 2026
Merged

jayakasadev merged 1 commit into
mainfrom
ci-konfig-crate-universe-non-dev

Conversation

@jayakasadev

Copy link
Copy Markdown
Owner

What

  • Removes dev_dependency = True from the @rules_rust//crate_universe:extension.bzl extension declaration in MODULE.bazel.

Why

snmalloc-rs/BUILD.bazel's :snmalloc_rs_profiling target references @crates//:flate2 unconditionally. Bazel skips dev_dependency declarations of non-root modules, so any downstream Bazel consumer that depends on :snmalloc_rs_profiling fails analysis with:

No repository visible as '@crates' from repository '@@snmalloc+'

The flate2-free :snmalloc_rs_profile_compat target (added in #74) stays available for consumers that do not need write_pprof_gz; this fix only matters for the full-profiling path.

Cost

  • flate2 (transitively) materialised in the consumer's resolved module graph whenever the snmalloc fork is pulled. The crate is feature-gated to :snmalloc_rs_profiling only, so consumers depending solely on :snmalloc_rs or :snmalloc_rs_profile_compat see no link-time impact.

Evidence

  • Companion change in capitalintent/konfig (CU-86aj23u16) was originally shipped against a locally-patched fork pin via git_override(patches=...) flipping this same flag, with bazel build //rust/konfig:konfig_bin_heapprof + bazel test //rust/konfig:test_heapprof PASS locally. With this fix landed the patch is removed.

…nstream

`snmalloc-rs/BUILD.bazel`'s `:snmalloc_rs_profiling` target depends on
`@crates//:flate2` unconditionally. The crate_universe extension that
materialises that repo was declared `dev_dependency = True`, but Bazel
skips dev_dependencies of non-root modules, so consumers of the fork
analyze-fail with:

  No repository visible as '@crates' from repository '@@snmalloc+'

Drop the dev scoping so `@crates` is visible to any module that pulls
the fork. The flate2-free `:snmalloc_rs_profile_compat` target stays in
place for downstream consumers that do not need `write_pprof_gz`; this
fix only matters for the `:snmalloc_rs_profiling` path.

Companion to capitalintent/konfig CU-86aj23u16 (heap-profile.pprof
endpoint shipped against a locally-patched fork pin via
`git_override(patches=...)`); after this lands, konfig drops the
patch and bumps the pin.
@jayakasadev
jayakasadev merged commit 78fd405 into main Jun 16, 2026
@jayakasadev
jayakasadev deleted the ci-konfig-crate-universe-non-dev branch June 16, 2026 16:34
jayakasadev added a commit that referenced this pull request Jun 16, 2026
…76)

PR #75 dropped `dev_dependency = True` so downstream consumers could
resolve `@crates//:flate2` referenced by `:snmalloc_rs_profiling`. That
fixed the visibility problem but introduced a worse one: any consumer
that also calls `use_extension("@rules_rust//crate_universe:extension.bzl",
"crate")` under the default repo name `crates` collides with this module
and bzlmod refuses to evaluate:

    Defined two crate universes with the same name in different
    MODULE.bazel files (`crates`).

Switch the materialised repo name to `snmalloc_crates` via
`crate.from_specs(name = ...)` and alias it back to `@crates` inside
this module's namespace via `use_repo(crate, crates = "snmalloc_crates")`.
Result:

  * `snmalloc-rs/BUILD.bazel`'s `@crates//:flate2` ref still resolves
    (alias is module-local).
  * Downstream modules' own `@crates` repo is untouched — they only see
    `@snmalloc_crates` if they explicitly use_repo it.

The `isolate = True` alternative was attempted first but is still gated
behind `--experimental_isolated_extension_usages`; renaming is the
stable path on Bazel 9.x.
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.

2 participants