Skip to content

Commit

Permalink
Use prebuilt protoc toolchain
Browse files Browse the repository at this point in the history
This downloades a prebuilt protoc binary and uses that through regular
toolchain resolution (with the incompatible flag). This increases build
speed and removes the many compiler warnings that pop-up during
compilation of protoc sources. And more importantly works better on
Windows. Where for some reason the protoc compilation fails from an
external module:

    gits/bb-deployments $ bazel build \
        --override_module protobuf=../protobuf \
        @protobuf//src/google/protobuf:timestamp_proto
    ERROR: C:/tmp/eprbnvuo/external/protobuf~/src/google/protobuf/compiler/java/BUILD.bazel:99:11: Compiling src/google/protobuf/compiler/java/context.cc [for tool] failed: undeclared inclusion(s) in rule '@@protobuf~//src/google/protobuf/compiler/java:java':
    this rule is missing dependency declarations for the following files included by 'src/google/protobuf/compiler/java/context.cc':
      'bazel-out/x64_windows-opt-exec-ST-d57f47055a04/bin/external/protobuf~/src/google/protobuf/compiler/java/_virtual_includes/java/google/protobuf/compiler/java/context.h'

Whereas it does work when building from its own checkout:

    ~/gits/protobuf $ bazel build \
        //src/google/protobuf:timestamp_proto
    Target //src/google/protobuf:timestamp_proto up-to-date:
      bazel-bin/src/google/protobuf/timestamp_proto-descriptor-set.proto.bin
    INFO: Build completed successfully, 1 total action
  • Loading branch information
stagnation committed Jul 2, 2024
1 parent 8815a6a commit 5db9741
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ build:remote-ubuntu-22-04 --extra_execution_platforms=//tools/remote-toolchains:

# When running bare executors on your own host machine.
build:remote-local --config=remote-exec

common --incompatible_enable_proto_toolchain_resolution
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bazel_dep(name = "rules_oci", version = "1.7.5")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "rules_proto", version = "6.0.0-rc2")
bazel_dep(name = "toolchains_llvm", version = "1.0.0")
bazel_dep(name = "toolchains_protoc", version = "0.3.1")

bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)

Expand Down
9 changes: 6 additions & 3 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5db9741

Please sign in to comment.