Skip to content

Fix Bazel 9 compatibility: add explicit load() for cc_* rules#243

Merged
robrussell merged 4 commits intomasterfrom
fix-bazel-9-compatibility
Jan 29, 2026
Merged

Fix Bazel 9 compatibility: add explicit load() for cc_* rules#243
robrussell merged 4 commits intomasterfrom
fix-bazel-9-compatibility

Conversation

@AaronWebster
Copy link
Collaborator

Summary

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.

This PR adds the necessary load statements to fix the CI failures.

Changes

  • Add load("@rules_cc//cc:cc_library.bzl", "cc_library") to BUILD files using cc_library
  • Add load("@rules_cc//cc:cc_test.bzl", "cc_test") to BUILD files using cc_test
  • Update build_defs.bzl macros to use loaded cc_test instead of native.cc_test

Files Modified

  • integration/googletest/BUILD
  • runtime/cpp/BUILD
  • runtime/cpp/test/BUILD
  • runtime/cpp/test/build_defs.bzl
  • compiler/back_end/cpp/build_defs.bzl

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+)
@AaronWebster AaronWebster self-assigned this Jan 29, 2026
@AaronWebster AaronWebster added the bug Something isn't working label Jan 29, 2026
@robrussell robrussell merged commit e24ea8c into master Jan 29, 2026
11 checks passed
@AaronWebster AaronWebster deleted the fix-bazel-9-compatibility branch January 29, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants