Skip to content

Generated Protos are no longer considered as virtual_imports in Bazel 7 #21075

Open
@XuanWang-Amos

Description

Description of the bug:

One of our test starts failing in Bazel 7, after some investigation, we found out it's because Bazel 7.0.0 removed the generated file check and stopped symlink our generated proto to _virtual_imports.

  • Bazel 6.4.0 will symlink generated proto to _virtual_imports because it's a generated file (link to code):
    generate_protos_in_virtual_imports = False
    if ctx.fragments.proto.generated_protos_in_virtual_imports():
        generate_protos_in_virtual_imports = any([not src.is_source for src in srcs])

    if import_prefix != "" or strip_import_prefix != "" or generate_protos_in_virtual_imports:
        # Use virtual source roots
        return _symlink_to_virtual_imports(ctx, srcs, import_prefix, strip_import_prefix)
  • Bazel 7.0.0 removed the generated file check thus it will not symlink generated proto to _virtual_imports (link to code):
    if import_prefix != "" or strip_import_prefix != "":
        # Use virtual source roots
        return _symlink_to_virtual_imports(ctx, srcs, import_prefix, strip_import_prefix)
    else:
        # No virtual source roots
        return "", srcs

Is this change of behavior expected? If it is, can someone share some context on why it was changed?

Link to our issue: grpc/grpc#35391

Which category does this issue belong to?

Rules API

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

Build this with Bazel 7: https://github.com/grpc/grpc/blob/714640d71f07d415a14aab2c68e8f37d74c644aa/test/distrib/bazel/python/BUILD#L123

Which operating system are you running Bazel on?

Not related

What is the output of bazel info release?

Not related

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

Not related

What's the output of git remote get-url origin; git rev-parse HEAD ?

Not related

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No

Have you found anything relevant by searching the web?

No

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

No response

Metadata

Assignees

No one assigned

    Labels

    P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)team-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions