Skip to content

Add Bazel 9 support for //third_party#41757

Merged
markdroth merged 3 commits into
grpc:masterfrom
smolkaj:bazel9-support
Jun 16, 2026
Merged

Add Bazel 9 support for //third_party#41757
markdroth merged 3 commits into
grpc:masterfrom
smolkaj:bazel9-support

Conversation

@smolkaj

@smolkaj smolkaj commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Why

Bazel 9 is out and gRPC's BCR entry currently doesn't build under it
(tracked in #41697). This PR fixes the last remaining blocker.

bazel/cython_library.bzl was already fixed in this repo. The only
remaining issue is third_party/address_sorting/address_sorting.bzl,
which calls native.cc_library without a load() — a hard error in
Bazel 9, which removed the autoload of native C++ rules.

Changes

  • third_party/address_sorting/address_sorting.bzl: load cc_library
    explicitly (consistent with e.g. bazel/cc_grpc_library.bzl) instead
    of using native.cc_library

For maintainers

Please add the release notes: no label (Mergeable requirement) and
approve the check_bzl_deps workflow run.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Mar 1, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

- Replace native.cc_library with a loaded cc_library in
  third_party/address_sorting/address_sorting.bzl. In Bazel 9,
  native C++ rules are no longer autoloaded into the global namespace.
- Bump .bazelversion to 9.0.0.

Signed-off-by: Steffen Smolka <steffen.smolka@gmail.com>
@smolkaj smolkaj marked this pull request as ready for review March 1, 2026 04:22
@markdroth markdroth assigned yuanweiz and unassigned murgatroid99 Mar 3, 2026
@smolkaj

smolkaj commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

Gentle reminder, could I get a review/merge?

@smolkaj

smolkaj commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

@yuanweiz

@yuanweiz

yuanweiz commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

@yuanweiz

Can you revert the .bazelversion change? We don't fully support bazel 9 yet (with some native bits hanging around and bzlmod support unfinished). The address_sorting change looks fine.

@yuanweiz

yuanweiz commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

If the goal is to fix bcr we can add a separate patch file under .bcr, since our BCR presubmit only builds a small subset of targets.

Comment thread .bazelversion Outdated
@smolkaj

smolkaj commented Mar 10, 2026

Copy link
Copy Markdown
Contributor Author

@yuanweiz

Can you revert the .bazelversion change? We don't fully support bazel 9 yet (with some native bits hanging around and bzlmod support unfinished). The address_sorting change looks fine.

Done.

FWIW, this builds fine on my machine with Bazel 9.

@smolkaj

smolkaj commented Mar 10, 2026

Copy link
Copy Markdown
Contributor Author

If the goal is to fix bcr we can add a separate patch file under .bcr, since our BCR presubmit only builds a small subset of targets.

Done: bazelbuild/bazel-central-registry#7749

@yuanweiz yuanweiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this change!

@yuanweiz yuanweiz added the release notes: no Indicates if PR should not be in release notes label Mar 10, 2026
@smolkaj

smolkaj commented Mar 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

anything else I need to do for this to get merged, or will this be handled by you/others?

@yuanweiz

Copy link
Copy Markdown
Contributor

I'm triggering the CI, once it's passed I'll have a repo admin merge it.

@yuanweiz yuanweiz requested a review from markdroth March 11, 2026 16:41
@yuanweiz

yuanweiz commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

@markdroth this looks good. Could you merge it when you have time? I'm checking our copybara setup to confirm whether this change affects google3 counterpart

@yuanweiz

Copy link
Copy Markdown
Contributor

I saw this error message that doesn't match what I see on github UI.

0311 09:41:57.486 VERBOSE: PROFILE:   4010 //copybara/8b8f06cc-5064-4a46-95ef-4aa73771837e_4ab894a4-2877-4d6b-ad88-2153e07c43e6/run/github_pr_to_piper/origin.resolve_source_ref
0311 09:41:57.487 VERBOSE: PROFILE:   4012 //copybara/8b8f06cc-5064-4a46-95ef-4aa73771837e_4ab894a4-2877-4d6b-ad88-2153e07c43e6/run/github_pr_to_piper
0311 09:41:57.487 WARNING: Cannot migrate http://github.com/grpc/grpc/pull/41843 because the following ci labels have not been passed: [Bazel RBE ASAN C/C++, Clang Tidy (internal CI), Bazel RBE Build Tests, Sanity Checks (internal CI), Bazel RBE Debug C/C++, Bazel RBE Opt C/C++, Windows clang-cl with strict warnings [Build Only], Bazel Basic Tests for Python (Local), Bazel RBE TSAN C/C++]
0311 09:41:57.493 VERBOSE: PROFILE:  10734 //copybara/8b8f06cc-5064-4a46-95ef-4aa73771837e_4ab894a4-2877-4d6b-ad88-2153e07c43e6

@markdroth

Copy link
Copy Markdown
Member

I think this PR should go through the normal copybara workflow.

@yuanweiz

yuanweiz commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

I think this PR should go through the normal copybara workflow.

Yeah at first I thought the changed file is github-only, but after checking I realized it's just the folder location that's slightly different.

The copybara error message looks a bit odd though (it seems to suggest various CIs are failing but only 1 of them is). I'm re-triggering Bazel RBE Build Tests only to see if that makes copybara happy.

@zifeitong

Copy link
Copy Markdown

There is one more missing cc_library import: https://github.com/grpc/grpc/blob/master/third_party/xxhash/BUILD

Bazel 9 requires explicit load statements for cc_library instead of
relying on the implicit native rule.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@smolkaj

smolkaj commented Mar 14, 2026

Copy link
Copy Markdown
Contributor Author

There is one more missing cc_library import: https://github.com/grpc/grpc/blob/master/third_party/xxhash/BUILD

Thanks, fixed

@pawbhard

Copy link
Copy Markdown
Contributor

@yuanweiz Either with this PR or follow up make sure we add bazel compatibility check test in portability test (building with oldest and latest supported version)

@yuanweiz

Copy link
Copy Markdown
Contributor

@yuanweiz Either with this PR or follow up make sure we add bazel compatibility check test in portability test (building with oldest and latest supported version)

Agreed. I approved this because it's harmless so we shouldn't leave it hanging for too long. But realistically I don't think it will fix all the issues with bazel 9.

To @smolkaj, could you finish some pending items:

  • Change the title to reflect which components (bazel targets) is now buildable with bazel 9
  • explain how you tested it, what's the bazel version used, etc (could be manual testing)

@yuanweiz yuanweiz changed the title Add Bazel 9 support Add Bazel 9 support for //third_party Jun 16, 2026
@markdroth markdroth merged commit 0f2fc63 into grpc:master Jun 16, 2026
63 checks passed
grohman-hub pushed a commit to grohman-hub/grpc that referenced this pull request Jun 16, 2026
## Why

Bazel 9 is out and gRPC's BCR entry currently doesn't build under it
(tracked in grpc#41697). This PR fixes the last remaining blocker.

`bazel/cython_library.bzl` was already fixed in this repo. The only
remaining issue is `third_party/address_sorting/address_sorting.bzl`,
which calls `native.cc_library` without a `load()` — a hard error in
Bazel 9, which removed the autoload of native C++ rules.

## Changes

- `third_party/address_sorting/address_sorting.bzl`: load `cc_library`
  explicitly (consistent with e.g. `bazel/cc_grpc_library.bzl`) instead
  of using `native.cc_library`

## For maintainers

Please add the `release notes: no` label (Mergeable requirement) and
approve the `check_bzl_deps` workflow run.

---------

Signed-off-by: Steffen Smolka <steffen.smolka@gmail.com>
Co-authored-by: Claude Opus 4.6 <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.

7 participants