Skip to content

fix: Bazel 9 compatibility (bump to 0.22.0) and export toolchain_type#281

Draft
nicdumz wants to merge 1 commit into
bazel-contrib:masterfrom
nicdumz:fix/bazel9-compat-and-public-toolchain-type
Draft

fix: Bazel 9 compatibility (bump to 0.22.0) and export toolchain_type#281
nicdumz wants to merge 1 commit into
bazel-contrib:masterfrom
nicdumz:fix/bazel9-compat-and-public-toolchain-type

Conversation

@nicdumz

@nicdumz nicdumz commented Jul 13, 2026

Copy link
Copy Markdown

Fixes #278.

Bazel 9 compatibility (dep bump)

On Bazel 9 the source-built Jsonnet compilers fail to configure:

  • The jsonnet 0.21.0 C++ sources' BUILD files (@jsonnet//core, @jsonnet//cmd) use bare cc_library / cc_binary / cc_test, which Bazel 9 removed and no longer auto-provides:

    This rule has been removed from Bazel. Please add a load() statement for it.

  • jsonnet_go 0.21.0 pins rules_go 0.53.0, whose go/private/rules/cgo.bzl references the removed CcInfo symbol, so @go_toolchains//:all fails to load during toolchain resolution for any target (even when the cpp compiler is selected, because jsonnet_go is an unconditional dep).

Bumping jsonnet and jsonnet_go to 0.22.0 fixes both: the v0.22.0 C++ BUILD files already load("@rules_cc//cc:...", ...), and jsonnet_go 0.22.0 pulls rules_go 0.59.0, gazelle 0.47.0, and rules_cc — all Bazel-9 clean.

This is the same bump proposed in #272, #273, and #274, and validated green in #275 — thanks to those authors. This PR folds it together with the toolchain-type change below into one self-contained fix; happy to rebase and drop the bump hunk if one of those merges first.

Expose //jsonnet:toolchain_type

toolchain_type had no visibility, so it defaulted to private. A downstream module that wants to register its own Jsonnet toolchain (e.g. a prebuilt compiler binary, to avoid building the compiler from source) cannot reference @rules_jsonnet//jsonnet:toolchain_type without patching this repo. Making it public is consistent with the *_jsonnet_toolchain targets, which are already public.

Verification

On Bazel 9.1.0, examples/ builds and tests pass with both compilers, with no --incompatible_autoload_externally:

# cpp
bazel test //... --extra_toolchains=@rules_jsonnet//jsonnet:cpp_jsonnet_toolchain
#   -> 25 tests pass

# go (examples default compiler)
bazel test //...
#   -> 25 tests pass

Bump jsonnet and jsonnet_go 0.21.0 -> 0.22.0.

Under Bazel 9 the source-built compilers fail to configure (issue bazel-contrib#278):
the 0.21.0 C++ sources' BUILD files use bare cc_library/cc_binary/cc_test,
which Bazel 9 removed and no longer auto-provides, and jsonnet_go 0.21.0
pins rules_go 0.53.0 whose cgo.bzl references the removed CcInfo symbol,
so @go_toolchains fails to load for any target. The 0.22.0 releases
already load() the cc rules from @rules_cc and pull rules_go 0.59.0,
gazelle 0.47.0, and rules_cc, all Bazel-9 clean.

Also make //jsonnet:toolchain_type public so a downstream module can
register its own Jsonnet toolchain (e.g. a prebuilt compiler) without
patching rules_jsonnet.

Verified on Bazel 9.1.0: examples/ builds and tests pass with both the
cpp and go compilers (25/25 each), with no --incompatible_autoload_externally.
@nicdumz
nicdumz marked this pull request as draft July 13, 2026 09:09
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.

Bazel 9 compatibility

1 participant