Skip to content

False-positive diag::err_undeclared_use_of_module possibly due to long paths #147220

Open
@froody

Description

@froody

I recently started using clang-19.1.7 with bazel and I'm seeing errors sometimes like:

external/grpc+/src/core/load_balancing/oob_backend_metric.cc:30:10: error: module grpc+//:oob_backend_metric does not depend on a module exporting 'google/protobuf/duration.upb.h'
   30 | #include "google/protobuf/duration.upb.h"
      |          ^

When I look at the clang invocation I see:

-fmodule-map-file=bazel-out/k8-fastbuild/bin/external/protobuf+/src/google/protobuf/duration_proto.upb.cppmap

and the contents of that file is below. I suspect that the overuse of ../ in the paths generated by bazel is creating very long paths inside clang resulting in truncation, but I'm not sure how to validate this.

Can someone familiar with module maps shed any light on this?

duration_proto.upb.cppmap:

module "protobuf+//src/google/protobuf:duration_proto.upb" {
  export *
  textual header "../../../../../../../../bazel-out/k8-fastbuild/bin/external/protobuf+/src/google/protobuf/_virtual_imports/duration_proto/google/protobuf/duration.upb.h"
  use "protobuf+//src/google/protobuf:duration_proto.upb_minitable"
  use "protobuf+//upb:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me"
  use "crosstool"
}
extern module "protobuf+//src/google/protobuf:duration_proto.upb_minitable" "../../../../../../../../bazel-out/k8-fastbuild/bin/external/protobuf+/src/google/protobuf/duration_proto.upb_minitable.cppmap"
extern module "protobuf+//upb:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me" "../../../../../../../../bazel-out/k8-fastbuild/bin/external/protobuf+/upb/generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me.cppmap"
extern module "crosstool" "../../../../../../../../bazel-out/k8-fastbuild/bin/external/toolchains_llvm++llvm+llvm_toolchain/module-x86_64-linux.modulemap"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bazel"Peripheral" support tier build system: utils/bazel

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions