Skip to content

Upgrade to Bazel 7.7.0 and protobuf 29.5#88

Draft
rjhuijsman wants to merge 1 commit into
mainfrom
rjh.bazel7
Draft

Upgrade to Bazel 7.7.0 and protobuf 29.5#88
rjhuijsman wants to merge 1 commit into
mainfrom
rjh.bazel7

Conversation

@rjhuijsman

Copy link
Copy Markdown
Contributor

Summary

This PR upgrades the Bazel build to Bazel 7.7.0 as part of a coordinated
upgrade across the entire monorepo. It also upgrades protobuf from 29.3
to 29.5 and glog from 0.5.0 to 0.7.1.

Why things had to change

Bazel 7.7.0 (.bazeliskrc)

Bumped USE_BAZEL_VERSION from 6.5.0 to 7.7.0.

bzlmod disabled (.bazelrc)

Bazel 7 enables bzlmod by default. Added common --enable_bzlmod=false
to keep the existing WORKSPACE-based build working until the project
is ready to migrate to MODULE.bazel.

repo_mapping parameter removed (bazel/repos.bzl, bazel/deps.bzl, picojson/rapidjson)

Bazel 7 removed the repo_mapping parameter from repository rules
(http_archive, git_repository, etc.). All explicit repo_mapping = {}
arguments have been removed from all call sites.

native.existing_rules() deprecated; external parameter removed

Bazel 7 deprecates native.existing_rules(). The pattern of accepting
an external parameter to conditionally register the repo's own
git_repository (so downstream consumers could pull it in) is replaced
throughout with maybe() from @bazel_tools//tools/build_defs/repo:utils.bzl,
which already skips registration if the repo exists.

py_repositories() call added to WORKSPACE.bazel

Protobuf 29.x loads @rules_python//python/py_info.bzl internally at
analysis time. This requires py_repositories() to have been called
first to create the @@rules_python_internal repository. Without this
call the build fails with a cycle in the WORKSPACE loading sequence.

rules_python 1.0.0 added to bazel/repos.bzl

Protobuf 29.x loads rules_python internally; rules_python 1.0.0
must be declared via maybe() before protobuf_deps() runs, or
protobuf_deps() will register an incompatible version.

rules_python 0.25.0 override removed from bazel/deps.bzl

The old deps.bzl called protobuf_deps() and then immediately
overrode rules_python with 0.25.0 to work around a compatibility bug.
With rules_python 1.0.0 now declared via maybe() in repos.bzl
(which runs first), protobuf_deps() will see it already registered
and skip it, making the override unnecessary.

glog 0.5.0 → 0.7.1 (bazel/repos.bzl)

glog 0.5.0 does not compile against protobuf 29.x headers. glog 0.7.1
is the first release with the necessary compatibility fixes.

protobuf 29.3 → 29.5 (bazel/repos.bzl)

Minor bump to align with the rest of the monorepo. The 29.x API changes
required for this repo were already present since the previous 29.3
upgrade.

DynamicCastToGeneratedDynamicCastMessage (include/stout/flags/flags.h)

Protobuf 29.x removed the DynamicCastToGenerated<T>() function from
the C++ runtime. Both call sites are updated to use DynamicCastMessage<T>(),
the direct replacement with identical semantics.

Test plan

  • bazel test //... in this repo passes
  • bazel test //... in the monorepo passes (consumes this as a submodule)
  • PR for dependent repos (pyprotoc-plugin, public, mono) is also merged

Bazel 7 introduces several breaking changes that required updates:

- `.bazeliskrc`: Bump version from 6.5.0 to 7.7.0.

- `.bazelrc`: Add `common --enable_bzlmod=false`. Bazel 7 enables
  bzlmod by default; disabling it keeps the WORKSPACE-based build
  working until we are ready to migrate to MODULE.bazel.

- `WORKSPACE.bazel`: Remove the `external = False` argument from
  `repos()` (parameter no longer exists). Add a call to
  `py_repositories()` after `repos()`. Protobuf 29.x loads
  `@rules_python//python/py_info.bzl` at analysis time, which
  requires `py_repositories()` to have been called first to set up
  the `@@rules_python_internal` repository; omitting this call causes
  a cycle in the WORKSPACE loading sequence.

- `bazel/repos.bzl`: Bazel 7 removes the `repo_mapping` parameter
  from repository rules, so all `repo_mapping = {}` arguments are
  removed. The `external`/`repo_mapping` parameters are removed from
  `repos()` itself (callers no longer pass them). Add an explicit
  `maybe()` declaration for `rules_python` 1.0.0, required because
  protobuf 29.x loads it internally. Upgrade `glog` from 0.5.0 to
  0.7.1 for compatibility with protobuf 29.x. Bump `com_google_protobuf`
  from 29.3 to 29.5. Remove the `if external:` block that
  conditionally registered stout itself as a `git_repository`; the
  `maybe()` pattern used by consumers makes this unnecessary.

- `bazel/deps.bzl`: Remove `repo_mapping` parameters throughout.
  Remove the `rules_python` 0.25.0 override: this was a workaround
  for a bug in older rules_python where `protobuf_deps()` would bring
  in an incompatible version; with rules_python 1.0.0 declared via
  `maybe()` in repos.bzl (which runs before `protobuf_deps()`), the
  override is no longer needed.

- `3rdparty/bazel-rules-picojson/repos.bzl`,
  `3rdparty/bazel-rules-rapidjson/repos.bzl`: Replace the
  `if external and "..." not in native.existing_rules():` guard with
  `maybe()`. `native.existing_rules()` is deprecated in Bazel 7 and
  `maybe()` already provides idempotent registration. Remove the
  `external` and `repo_mapping` parameters from `repos()`.

- `include/stout/flags/flags.h`: Protobuf 29.x removed the
  `DynamicCastToGenerated<T>()` API. Replace both call sites with
  `DynamicCastMessage<T>()`, the direct replacement.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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