Skip to content

Upgrade to Bazel 9.1.1#3846

Open
williamckha wants to merge 6 commits into
UBC-Thunderbots:masterfrom
williamckha:william/bazel9
Open

Upgrade to Bazel 9.1.1#3846
williamckha wants to merge 6 commits into
UBC-Thunderbots:masterfrom
williamckha:william/bazel9

Conversation

@williamckha

@williamckha williamckha commented Jul 12, 2026

Copy link
Copy Markdown
Member

Description

Upgrades our repo from Bazel 8.2.1 to 9.1.1. I see two advantages to upgrading:

  • Offline builds seem to work properly now, given that you've already fetched all external dependencies. You can rebuild without Internet even after bazel clean, bazel query works offline when fuzzy-finding via tbots.py, etc.
  • Bazel 9 includes support for a prebuilt protobuf compiler.

Testing Done

Resolved Issues

Length Justification and Key Files to Review

Bazel 9 requires explicit load() statements for rules previously available as built-ins (cc_library, cc_binary, cc_test, py_binary, py_library, etc.). The bulk of this PR is dedicated to adding these load() statements. Some of our dependencies (googletest, platformio_rules, pybind11_protobuf, hedron_compile_commands) have not been updated yet for Bazel 9 and require patches due to this breaking change.

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

Comment thread src/toolchains/cc/BUILD Outdated
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Seems like protobuf now depends on rules_android, which needs the Android SDK

Comment thread src/.bazelrc
# See https://docs.bazel.build/versions/master/remote-caching.html#disk-cache
build --disk_cache=~/.cache/thunderbots_bazel_disk_cache

build --experimental_remote_merkle_tree_cache # partial repo caching optimization

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It appears that this option is no longer supported

@williamckha williamckha changed the title [WIP] Upgrade to Bazel 9.1.1 Upgrade to Bazel 9.1.1 Jul 13, 2026
Comment thread src/.bazelrc

build --experimental_remote_merkle_tree_cache # partial repo caching optimization
common --incompatible_enable_proto_toolchain_resolution # protoc caching
common --@protobuf//bazel/toolchains:prefer_prebuilt_protoc

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.

I'm not sure that the prebuilt binaries will actually work in the nanopb pipeline for compiling the onboard protobufs. This will need to be tested with a real robot to verify, but for some context, this feature is simply the now upstream variant of the alex eagle toolchains protobuf repo. During the Bazel 8 migration, I had attempted to use this optimization (622a89a), but to no avail.

Here is the thread I inquired upon the issue with, but to no response aspect-archives/toolchains_protoc#21

I can't quite recall what exactly didn't work, so it is probably a good idea to test on-robot.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think I've got the nanopb pipeline using prebuilt protoc now. bazel cquery deps(//proto:tbots_nanopb_proto) shows the prebuilt binary (@@protobuf++protoc+prebuilt_protoc.linux_x86_64//:bin/protoc) in the build graph instead of @protobuf//:protoc which builds from source.

@williamckha
williamckha requested review from Andrewyx and nycrat July 19, 2026 06:10
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.

3 participants