Skip to content

cc_proto_library does not filter blacklisted protos inside the protobuf repo #10590

@Yannic

Description

@Yannic

For Bazel //:src/google/protobuf/any.proto and @com_google_protobuf//:src/google/protobuf/any.proto are different files, which causes blacklisting of .proto sources to fail inside the protobuf repo.

protocolbuffers/protobuf#7075 (comment)

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

git clone --branch proto_blacklist_test https://github.com/Yannic/protobuf.git
cd protobuf
bazel test @com_google_protobuf//:cc_proto_blacklist_test //:cc_proto_blacklist_test
# @com_google_protobuf//:cc_proto_blacklist_test passes
# //:cc_proto_blacklist_test fails
bazel test --proto_toolchain_for_cc=//:cc_toolchain @com_google_protobuf//:cc_proto_blacklist_test //:cc_proto_blacklist_test
# //:cc_proto_blacklist_test passes
# @com_google_protobuf//:cc_proto_blacklist_test fails

What operating system are you running Bazel on?

N/A

What's the output of bazel info release?

Tested with several versions between 0.22.0 and 2.0.0

Any other information, logs, or outputs that you want to share?

This is mostly an issue for the protobuf repo or for users defining their own proto_lang_toolchain, which shouldn't be too many.

I see two possible fixes:

  • a: Teach Bazel that //:src/google/protobuf/any.proto and @com_google_protobuf//:src/google/protobuf/any.proto are equivalent.
  • b: Filter .proto files based on their import path.

b Is blocked on making ProtoInfo mandatory for proto_lang_toolchain#blacklisted_protos (cc @cushon). I have no idea how hard a would be. Is it related to --incompatible_remap_main_repo (cc @aehlig)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)team-Rules-CPPIssues for C++ rulestype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions