Skip to content

Migrate to Bazel 8#427

Open
lolski wants to merge 28 commits intomasterfrom
bazel-8-upgrade
Open

Migrate to Bazel 8#427
lolski wants to merge 28 commits intomasterfrom
bazel-8-upgrade

Conversation

@lolski
Copy link
Copy Markdown
Member

@lolski lolski commented Feb 23, 2026

Motivation

Update Bazel version from 6.2 to 8.5.1.

The upgrade is done in a backwards-compatible way, such that "upstream" repositories that are yet to be upgraded may depend on this repository. This is done by preserving a few Bazel 6 configs (WORKSPACE, etc) alongside the new Bazel 8 ones. Once every repositories have been upgraded to Bazel 8, these files will be removed.

Implementation

Create MODULE.bazel

The new module declaration is organized into these sections:

  1. Module ID and version
  2. Common/util declarations needed by subsequent declarations
  3. Build dependencies
  4. Languages and toolchains: where we declare our Rust, Kotlin, Python, and other languages we use
  5. Platform definitions for doing architecture and OS selections
  6. Package managers: pip, maven
  7. Assembly and deployments
  8. Docs

We've also done syntactic changes to fix broken rules during the upgrade, here's a few examples:

  • The deprecated cfg = "host" updated to cfg = "exec"
  • output_to_genfiles = True removed in various places.
  • struct.to_json() to json.encode()

The following files are kept for backwards compatibility, and will be removed when all repos have been

  • WORKSPACE: Deprecated with notice; updated dep versions to match MODULE.bazel; added rules_cc() call

@lolski lolski requested a review from alexjpwalker as a code owner February 23, 2026 13:55
@lolski lolski changed the title Upgrade to Bazel 8 Migrate Bazel to version 8 Feb 24, 2026
@lolski lolski changed the title Migrate Bazel to version 8 Migrate to Bazel 8 Feb 24, 2026
- Add .bazelrc with enable_workspace=true (required for Bazel 8)
- Update .bazelversion to 8.0.0
- Replace cfg = "host" with cfg = "exec" (deprecated in Bazel 8)
- Remove output_to_genfiles attribute (removed in Bazel 8)
- Update rules_python to 1.0.0 (PyInfo provider moved)
- Update rules_rust to 0.56.0
- Add rules_cc 0.0.17 dependency
- Update rules_jvm_external to 6.6

Note: Build is blocked on Java toolchain compatibility issues.
See dependencies/bazel-8-upgrade-plan.md for details.
Switch from WORKSPACE to MODULE.bazel as the primary build configuration.
This enables rules_java 8.x which is required for Bazel 8 (rules_java 7.x
creates dependency cycles in WORKSPACE mode).

- Add MODULE.bazel with BCR dependencies and extension configurations
- Remove --enable_workspace=true from .bazelrc (Bzlmod now default)
- Add deprecation notices to WORKSPACE and legacy .bzl files
- WORKSPACE kept functional for backward compatibility
The doc_hub.bzl loads rules from //docs/doxygen:rules.bzl and
//docs/python:rules.bzl which requires these directories to be
Bazel packages. Add BUILD files with bzl_library targets and
move the sphinx_runner target to the python subpackage.
Note: LLVM toolchain configuration moved to typedb_dependencies repo,
which is the root module when building downstream repos.
Configure toolchains_llvm for standalone builds only using dev_dependency.
This allows bazel-distribution to build independently while avoiding
conflicts when used as a dependency (where the root module must configure
its own LLVM toolchain).
Documents current Bzlmod migration state:
- 52/53 targets build successfully
- Only //:docs targets fail (stardoc/bzl_library issue)
The struct.to_json() method was removed in Bazel 8. Use json.encode()
which is the new standard way to encode objects to JSON.
Set TZ=UTC in the sphinx runner environment to fix babel/zoneinfo
error in sandboxed Bazel builds where TZ may be set to /UTC.
Bazel 8 requires directory outputs to be declared with
declare_directory() rather than attr.output(). Changed to use
attr.string + declare_directory, matching the doxygen_docs rule.
Reorganize the flat MODULE.bazel structure into clearly delineated
sections so that related bazel_dep, extension, toolchain, and use_repo
calls are co-located. No functional changes.
type: foreground
command: |
bazel build //...
bazel build //... --extra_toolchains=@llvm_toolchain//:all -- -//:docs -//:docs.extract
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excluded docs since I can't yet get it to work

Copy link
Copy Markdown
Member

@dmitrii-ubskii dmitrii-ubskii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly questions.

The following files are kept for backwards compatibility [...]
.bazelrc: Created with Bzlmod migration comment

No it wasn't 🤔
But even so, is .bazelrc even deprecated? I see no indication of that in the docs (https://bazel.build/versions/8.5.0/run/bazelrc)

@dmitrii-ubskii dmitrii-ubskii self-requested a review February 27, 2026 12:06
maven/deps.bzl Outdated
Comment on lines +20 to +24
"com.eclipsesource.minimal-json:minimal-json",
"com.eclipsesource.minimal-json:minimal-jsonz",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo?

lolski and others added 3 commits February 27, 2026 18:29
Use Label() instead of a plain string for the uploader dep in all
deploy macros (artifact, maven, pip, apt, helm). Plain string labels
in macros are resolved relative to the calling repo, causing
'no such package common/uploader' errors when macros are invoked
from external repos. Label() resolves relative to the .bzl file's
own repo at load time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lolski and others added 2 commits March 26, 2026 16:55
The label `//docs:doxygen/doxyfile.template` references a file across
a package boundary. Since `docs/doxygen/` has its own BUILD file,
the correct label is `//docs/doxygen:doxyfile.template`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

3 participants