Skip to content

fix: add missing load() statements for Bazel 9 compatibility#1155

Open
00fish0 wants to merge 2 commits intoalibaba:mainfrom
00fish0:fix/bazel9-add-missing-load-statements
Open

fix: add missing load() statements for Bazel 9 compatibility#1155
00fish0 wants to merge 2 commits intoalibaba:mainfrom
00fish0:fix/bazel9-add-missing-load-statements

Conversation

@00fish0
Copy link

@00fish0 00fish0 commented Feb 28, 2026

Problem

Bazel 9.0.0 removed the built-in cc_binary, cc_test, and cc_library rules. They must now be explicitly loaded from @rules_cc//cc:defs.bzl via a load() statement. This causes the CI build to fail with:

Error in fail:
         This rule has been removed from Bazel. Please add a \`load()\` statement for it.

Warnings:

In file included from include/ylt/coro_rpc/impl/coro_connection.hpp:40,
                 from include/ylt/coro_rpc/impl/coro_rpc_server.hpp:44,
                 from include/ylt/coro_rpc/coro_rpc_server.hpp:17,
                 from src/coro_rpc/examples/file_transfer/file_server.cpp:2:
include/ylt/coro_rpc/impl/errno.h: In member function ‘uint16_t& coro_rpc::rpc_error::val()’:
include/ylt/coro_rpc/impl/errno.h:114:29: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  114 |   uint16_t& val() { return *(uint16_t*)&(code.ec); }
      |                             ^~~~~~~~~~~~~~~~~~~~~
include/ylt/coro_rpc/impl/errno.h: In member function ‘const uint16_t& coro_rpc::rpc_error::val() const’:
include/ylt/coro_rpc/impl/errno.h:115:41: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  115 |   const uint16_t& val() const { return *(uint16_t*)&(code.ec); }
      |                                         ^~~~~~~~~~~~~~~~~~~~~
In file included from include/ylt/coro_rpc/coro_rpc_server.hpp:17,
                 from src/coro_rpc/examples/file_transfer/file_server.cpp:2:
include/ylt/coro_rpc/impl/coro_rpc_server.hpp: In instantiation of ‘async_simple::Future<coro_rpc::err_code> coro_rpc::coro_rpc_server_base<server_config>::async_start() [with server_config = coro_rpc::config_t]’:
include/ylt/coro_rpc/impl/coro_rpc_server.hpp:177:12:   required from ‘coro_rpc::err_code coro_rpc::coro_rpc_server_base<server_config>::start() [with server_config = coro_rpc::config_t]’
src/coro_rpc/examples/file_transfer/file_server.cpp:14:43:   required from here
include/ylt/coro_rpc/impl/coro_rpc_server.hpp:267:30: error: moving a local object in a return statement prevents copy elision [-Werror=pessimizing-move]
  267 |       return std::move(future);
      |                              ^
include/ylt/coro_rpc/impl/coro_rpc_server.hpp:267:30: note: remove ‘std::move’ call
cc1plus: all warnings being treated as errors
INFO: Elapsed time: 63.387s, Critical Path: 24.35s
INFO: 54 processes: 43 internal, 11 linux-sandbox.
ERROR: Build did NOT complete successfully
Error: Process completed with exit code 1.

Changes

  • BUILD.bazel: Added missing "cc_test" to the existing load() statement (was only loading cc_binary and cc_library).
  • src/coro_rpc/examples/file_transfer/BUILD.bazel: Added load("@rules_cc//cc:defs.bzl", "cc_binary") — was completely missing.
  • src/struct_json/examples/BUILD.bazel: Added load("@rules_cc//cc:defs.bzl", "cc_binary") — was completely missing.

Verification

Local bazel build //... with Bazel 9.0.0 confirms all packages load successfully after this fix.

… 9 removed built-in cc_binary, cc_test, and cc_library rules.\nThey must now be explicitly loaded from @rules_cc//cc:defs.bzl.\n\n- BUILD.bazel: add missing \"cc_test\" to existing load()\n- src/coro_rpc/examples/file_transfer/BUILD.bazel: add load() for \"cc_binary\"\n- src/struct_json/examples/BUILD.bazel: add load() for \"cc_binary\"
Copilot AI review requested due to automatic review settings February 28, 2026 06:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds explicit load() statements for rules_cc C++ rules to keep the build working under Bazel 9, where cc_* rules are no longer built-ins.

Changes:

  • Load cc_test from @rules_cc//cc:defs.bzl in the root BUILD.bazel.
  • Add missing cc_binary loads to example BUILD.bazel files that define cc_binary targets.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
BUILD.bazel Loads cc_test from rules_cc to avoid Bazel 9 removed-builtin rule errors.
src/coro_rpc/examples/file_transfer/BUILD.bazel Adds missing cc_binary load for Bazel 9 compatibility.
src/struct_json/examples/BUILD.bazel Adds missing cc_binary load for Bazel 9 compatibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

for detail, goto summary download Artifacts base-ylt-cov-report(base commit coverage report) and ylt-cov-report(current pull request coverage report)

@github-actions
Copy link

github-actions bot commented Mar 1, 2026

for detail, goto summary download Artifacts base-ylt-cov-report(base commit coverage report) and ylt-cov-report(current pull request coverage report)

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.

2 participants