-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Closed
Labels
Description
My MODULE.bazel
bazel_dep(name = "toolchains_protoc", version = "0.3.6")
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
protoc.toolchain(
google_protobuf = "com_google_protobuf",
version = "v26.0",
)
use_repo(protoc, "com_google_protobuf", "toolchains_protoc_hub")
register_toolchains("@toolchains_protoc_hub//:all")
bazel_dep(name = "googleapis", version = "0.0.0-20240819-fe8ba054a")
# single_version_override(module_name = "protobuf", version = "29.3")
.bazelrc
common --incompatible_enable_proto_toolchain_resolution
I use Bazel 7.4.1
With Protobuf v26.0 .. v28.3, proto_library uses prebuilt toolchain and the build finishes instantly.
$ bazel query 'deps(@googleapis//google/type:color_proto)'
@googleapis//google/type:color.proto
@googleapis//google/type:color_proto
@@protobuf~//:wrappers_proto
@@protobuf~//src/google/protobuf:wrappers.proto
@@protobuf~//src/google/protobuf:wrappers_proto
$ bazel build @googleapis//google/type:color_proto
...
INFO: Elapsed time: 1.267s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
With protobuf >= v29.0 by uncommenting the single_version_override line at the bottom, bazel starts compiling protoc
$ bazel query 'deps(@googleapis//google/type:color_proto)'
@googleapis//google/type:color.proto
@googleapis//google/type:color_proto
@@protobuf~//:LICENSE
@@protobuf~//:license
@@protobuf~//:wrappers_proto
@@protobuf~//bazel/private:experimental_proto_descriptor_sets_include_source_info
@@protobuf~//bazel/private:experimental_proto_descriptor_sets_include_source_info_setting
@@protobuf~//bazel/private:strict_proto_deps
@@protobuf~//bazel/private:strict_proto_deps_setting
@@protobuf~//bazel/private:strict_public_imports
@@protobuf~//bazel/private:strict_public_imports_setting
@@protobuf~//src/google/protobuf:wrappers.proto
@@protobuf~//src/google/protobuf:wrappers_proto
$ bazel build @googleapis//google/type:color_proto
<< bazel starts compiling absl and proto >>
INFO: Elapsed time: 73.891s, Critical Path: 18.82s
INFO: 984 processes: 537 internal, 447 darwin-sandbox.
INFO: Build completed successfully, 984 total actions
For Bazel 7.4.1, Bazel uses precompiled binary when protobuf=v26.0 or v28.3, but not for v29.0...v29.3 as I mentioned above.
For Bazel 8.0.1, Bazel starts compiling protoc for both protobuf=v26.0 and v29.0.
Thus I'm guessing that proto_library
being migrated from Bazel to starlark has something to do with this.
I wasn't able to reproduce this behavior for simpler targets like @protobuf//:any_proto
or @googleapis//google/type:calendar_period_proto