bazelbuild / rules_proto

Protocol buffer rules for Bazel
Apache License 2.0
167 stars 69 forks source link

rules_proto is broken with grpc 1.55+ #178

Closed jasonqsong closed 10 months ago

jasonqsong commented 1 year ago

Error

ERROR: /home/nagi/.cache/bazel/_bazel_nagi/aa4b8136c93fe278edb3dd1fe70e4b47/external/upb/BUILD:517:28: no such target '@com_google_protobuf//:descriptor_proto_srcs': target 'descriptor_proto_srcs' not declared in package '' defined by /home/nagi/.cache/bazel/_bazel_nagi/aa4b8136c93fe278edb3dd1fe70e4b47/external/com_google_protobuf/BUILD (Tip: use query "@com_google_protobuf//:*" to see all the targets in that package) and referenced by '@upb//:gen_descriptor_upb_proto_stage1'

Root cause

grpc 1.55+ uses protobuf 22+, which brings incompatible changes.

rules_proto is still stick to protobuf 21

Verified

Start with https://github.com/arcticmatt/grpc_getting_started

Test with

$ bazel build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //:greeter_server

WORKSPACE (failed)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_proto",
    strip_prefix = "rules_proto-5.3.0-21.7",
    urls = [
        "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
    ],
)
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()

http_archive(
    name = "com_github_grpc_grpc",
    urls = [
        "https://github.com/grpc/grpc/archive/v1.55.3.tar.gz",
    ],
    strip_prefix = "grpc-1.55.3",
)
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()

WORKSPACE (success)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_proto",
    strip_prefix = "rules_proto-5.3.0-21.7",
    urls = [
        "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
    ],
)
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()

http_archive(
    name = "com_github_grpc_grpc",
    urls = [
        "https://github.com/grpc/grpc/archive/v1.54.3.tar.gz",
    ],
    strip_prefix = "grpc-1.54.3",
)
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()
comius commented 1 year ago

This needs upgrade of protobuf dependency. Accepting contributions.