From 50399773bc354fa30f0da06b207c5c74559467a9 Mon Sep 17 00:00:00 2001 From: Nils Wireklint Date: Mon, 1 Jul 2024 15:38:50 +0200 Subject: [PATCH] Use prebuilt protoc toolchain This downloads 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 --- .bazelrc | 2 ++ MODULE.bazel | 1 + MODULE.bazel.lock | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 3752b49..fb54aa4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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 diff --git a/MODULE.bazel b/MODULE.bazel index 7130709..3f338f0 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -22,6 +22,7 @@ bazel_dep(name = "rules_oci", version = "1.7.6") bazel_dep(name = "rules_pkg", version = "0.10.1") bazel_dep(name = "rules_proto", version = "6.0.2") bazel_dep(name = "toolchains_llvm", version = "1.0.0") +bazel_dep(name = "toolchains_protoc", version = "0.3.1") # # Workarounds 2026-06-27 # ERROR: in tag at https://bcr.bazel.build/modules/grpc-java/1.62.2/MODULE.bazel:89:15: no repository visible as '@com_google_protobuf_javalite' to the repository '@@grpc-java~', but referenced by label '@com_google_protobuf_javalite//:protobuf_javalite' in attribute 'target' of tag 'override'. Is the module 'grpc-java' missing a bazel_dep or use_repo(..., "com_google_protobuf_javalite")? diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 00fbead..5a48810 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -76,13 +76,14 @@ "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", "https://bcr.bazel.build/modules/opentelemetry-proto/1.3.1/MODULE.bazel": "0141a50e989576ee064c11ce8dd5ec89993525bd9f9a09c5618e4dacc8df9352", "https://bcr.bazel.build/modules/opentelemetry-proto/1.3.1/source.json": "4ea3f46eb63107e1f1164adc1897bd95bf0fe9673ea632f56cae2f0572eaecc7", + "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", + "https://bcr.bazel.build/modules/platforms/0.0.10/source.json": "f22828ff4cf021a6b577f1bf6341cb9dcd7965092a439f64fc1bb3b7a5ae4bd5", "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", "https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d", "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", - "https://bcr.bazel.build/modules/platforms/0.0.9/source.json": "cd74d854bf16a9e002fb2ca7b1a421f4403cda29f824a765acd3a8c56f8d43e6", "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", "https://bcr.bazel.build/modules/protobuf/23.1/MODULE.bazel": "88b393b3eb4101d18129e5db51847cd40a5517a53e81216144a8c32dfeeca52a", "https://bcr.bazel.build/modules/protobuf/27.1/MODULE.bazel": "703a7b614728bb06647f965264967a8ef1c39e09e8f167b3ca0bb1fd80449c0d", @@ -161,6 +162,8 @@ "https://bcr.bazel.build/modules/stardoc/0.5.6/source.json": "956954c9c45ef492ea4001ce579dc40431fbd75090151e8f9eadf9ed6377a108", "https://bcr.bazel.build/modules/toolchains_llvm/1.0.0/MODULE.bazel": "410c05d8a21179f501e1d0dc6c325eac78c885d4f44c5438331392ba094bf819", "https://bcr.bazel.build/modules/toolchains_llvm/1.0.0/source.json": "85babe13e588c25e032d10984ef3ed33fae30554f97bc3cc48867833e52a21ec", + "https://bcr.bazel.build/modules/toolchains_protoc/0.3.1/MODULE.bazel": "b6574a2a314cbd40cafb5ed87b03d1996e015315f80a7e33116c8b2e209cb5cf", + "https://bcr.bazel.build/modules/toolchains_protoc/0.3.1/source.json": "b589ee1faec4c789c680afa9d500b5ccbea25422560b8b9dc4e0e6b26471f13b", "https://bcr.bazel.build/modules/upb/0.0.0-20211020-160625a/MODULE.bazel": "6cced416be2dc5b9c05efd5b997049ba795e5e4e6fafbe1624f4587767638928", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/MODULE.bazel": "c0df5e35ad55e264160417fd0875932ee3c9dda63d9fccace35ac62f45e1b6f9", @@ -1837,7 +1840,7 @@ "@@platforms//host:extension.bzl%host_platform": { "general": { "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", - "usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=", + "usagesDigest": "V1R2Y2oMxKNfx2WCWpSCaUV1WefW1o8HZGm3v1vHgY4=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {},