Fix Bazel 9 compatibility: add explicit load() for cc_* rules#243
Merged
robrussell merged 4 commits intomasterfrom Jan 29, 2026
Merged
Fix Bazel 9 compatibility: add explicit load() for cc_* rules#243robrussell merged 4 commits intomasterfrom
robrussell merged 4 commits intomasterfrom
Conversation
Bazel 9 removed native cc_library, cc_test, and cc_binary rules from
the global scope. They now require explicit load() statements from
@rules_cc.
- Add load("@rules_cc//cc:cc_library.bzl", "cc_library") to BUILD files
- Add load("@rules_cc//cc:cc_test.bzl", "cc_test") to BUILD files
- Update build_defs.bzl macros to use loaded cc_test instead of
native.cc_test
- Add bazel_dep for rules_cc to MODULE.bazel so @rules_cc is available - Add py_test load to compiler/back_end/cpp/BUILD
- Update MODULE.bazel dependency versions: - abseil-cpp: 20230125.1 -> 20240722.0 - googletest: 1.14.0.bcr.1 -> 1.17.0.bcr.2 (Bazel 9 compatible) - rules_python: 0.31.0 -> 1.0.0 - rules_cc: 0.0.17 -> 0.1.0 - Update build_defs.bzl for Bazel 9 API changes: - Load cc_common from @rules_cc//cc/common:cc_common.bzl - Use find_cc_toolchain from @rules_cc//cc:find_cc_toolchain.bzl - Update _cc_toolchain attribute to use @rules_cc//cc:current_cc_toolchain - Use use_cc_toolchain() for toolchain resolution - Update .bazelrc to use C++17 (required by googletest 1.17+)
robrussell
approved these changes
Jan 29, 2026
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
Bazel 9 removed native
cc_library,cc_test, andcc_binaryrules from the global scope. They now require explicitload()statements from@rules_cc.This PR adds the necessary load statements to fix the CI failures.
Changes
load("@rules_cc//cc:cc_library.bzl", "cc_library")to BUILD files using cc_libraryload("@rules_cc//cc:cc_test.bzl", "cc_test")to BUILD files using cc_testbuild_defs.bzlmacros to use loadedcc_testinstead ofnative.cc_testFiles Modified
integration/googletest/BUILDruntime/cpp/BUILDruntime/cpp/test/BUILDruntime/cpp/test/build_defs.bzlcompiler/back_end/cpp/build_defs.bzl