Upgrade to Bazel 7.7.0 and protobuf 29.5#88
Draft
rjhuijsman wants to merge 1 commit into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
protobuffrom 29.3to 29.5 and
glogfrom 0.5.0 to 0.7.1.Why things had to change
Bazel 7.7.0 (
.bazeliskrc)Bumped
USE_BAZEL_VERSIONfrom 6.5.0 to 7.7.0.bzlmod disabled (
.bazelrc)Bazel 7 enables bzlmod by default. Added
common --enable_bzlmod=falseto keep the existing WORKSPACE-based build working until the project
is ready to migrate to
MODULE.bazel.repo_mappingparameter removed (bazel/repos.bzl,bazel/deps.bzl, picojson/rapidjson)Bazel 7 removed the
repo_mappingparameter from repository rules(
http_archive,git_repository, etc.). All explicitrepo_mapping = {}arguments have been removed from all call sites.
native.existing_rules()deprecated;externalparameter removedBazel 7 deprecates
native.existing_rules(). The pattern of acceptingan
externalparameter to conditionally register the repo's owngit_repository(so downstream consumers could pull it in) is replacedthroughout with
maybe()from@bazel_tools//tools/build_defs/repo:utils.bzl,which already skips registration if the repo exists.
py_repositories()call added toWORKSPACE.bazelProtobuf 29.x loads
@rules_python//python/py_info.bzlinternally atanalysis time. This requires
py_repositories()to have been calledfirst to create the
@@rules_python_internalrepository. Without thiscall the build fails with a cycle in the WORKSPACE loading sequence.
rules_python 1.0.0 added to
bazel/repos.bzlProtobuf 29.x loads
rules_pythoninternally;rules_python1.0.0must be declared via
maybe()beforeprotobuf_deps()runs, orprotobuf_deps()will register an incompatible version.rules_python0.25.0 override removed frombazel/deps.bzlThe old
deps.bzlcalledprotobuf_deps()and then immediatelyoverrode
rules_pythonwith 0.25.0 to work around a compatibility bug.With
rules_python1.0.0 now declared viamaybe()inrepos.bzl(which runs first),
protobuf_deps()will see it already registeredand 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.
DynamicCastToGenerated→DynamicCastMessage(include/stout/flags/flags.h)Protobuf 29.x removed the
DynamicCastToGenerated<T>()function fromthe C++ runtime. Both call sites are updated to use
DynamicCastMessage<T>(),the direct replacement with identical semantics.
Test plan
bazel test //...in this repo passesbazel test //...in the monorepo passes (consumes this as a submodule)