Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implicit dependencies for grpc Status / Code break a custom compilers #2362

Closed
asv opened this issue Feb 6, 2020 · 3 comments
Closed

Implicit dependencies for grpc Status / Code break a custom compilers #2362

asv opened this issue Feb 6, 2020 · 3 comments

Comments

@asv
Copy link

asv commented Feb 6, 2020

What version of rules_go are you using?

v0.21.2

What version of gazelle are you using?

v0.19.1

What version of Bazel are you using?

v2.0.0

Does this issue reproduce with the latest releases of all the above?

Yes.

Current rules_go HEAD (7d825a3)
Current gazelle HEAD (b38f32ee6304d3fb1d98e83497ce238cbcc5e2e0)

What operating system and processor architecture are you using?

Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic

Linux asmirnov 5.0.0-25-generic #26~18.04.1-Ubuntu SMP Thu Aug 1 13:51:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

What did you do?

  1. Write code for custom go grpc compiler (using github.com/golang/protobuf/protoc-gen-go/generator).
  2. Register it via go_proto_compiler.
  3. Using via gazelle macro as default go_grpc_compiler.
  4. Generate BUILD.bazel using gazelle task (bazel run //:gazelle).
  5. Try to build go_proto_library (bazel build //proto/...).

reprorepo:
https://github.com/asv/bazel_rules_go_custom_comp_bug

bazel build //proto/...

What did you expect to see?

Success build outputs.

What did you see instead?

INFO: Analyzed 3 targets (0 packages loaded, 0 targets configured).
INFO: Found 3 targets...
ERROR: /home/asmirnov/devel/github.com/asv/bazel_rules_go_custom_comp_bug/proto/BUILD.bazel:11:1: GoCompilePkg proto/linux_amd64_stripped/bug_go_proto%/github.com/asv/bazel_rules_go_custom_comp_bug/proto.a failed (Exit 1) builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix linux_amd64 -src ... (remaining 41 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
compilepkg: missing strict dependencies:
	/home/asmirnov/.cache/bazel/_bazel_asmirnov/a2c85f36c8c7a0c4443065a75d892093/sandbox/linux-sandbox/551/execroot/__main__/bazel-out/k8-fastbuild/bin/proto/linux_amd64_stripped/bug_go_proto%/github.com/asv/bazel_rules_go_custom_comp_bug/proto/bug.pb.go: import of "google.golang.org/grpc/codes"
	/home/asmirnov/.cache/bazel/_bazel_asmirnov/a2c85f36c8c7a0c4443065a75d892093/sandbox/linux-sandbox/551/execroot/__main__/bazel-out/k8-fastbuild/bin/proto/linux_amd64_stripped/bug_go_proto%/github.com/asv/bazel_rules_go_custom_comp_bug/proto/bug.pb.go: import of "google.golang.org/grpc/status"
No dependencies were provided.
Check that imports in Go sources match importpath attributes in deps.
INFO: Elapsed time: 0.233s, Critical Path: 0.05s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
@jayconrod
Copy link
Contributor

It looks like your compiler generates code that imports google.golang.org/grpc/codes and google.golang.org/grpc/status but does not add dependencies on those libraries. The rules can't know what imports are present during the analysis phase because they can't do any I/O.

Could you try adding @org_golang_google_grpc//codes:go_default_library and @org_golang_google_grpc//status:go_default_library to the deps attribute of //protoc-gen-gogrpcbug:go_grpc_bug? go_proto_compiler has more info.

@asv
Copy link
Author

asv commented Feb 6, 2020

I think this is due to golang/protobuf#785 in golang/protobuf@v1.3.2 release.

@asv
Copy link
Author

asv commented Feb 6, 2020

Hmm ... Adding @org_golang_google_grpc//codes:go_default_library / @org_golang_google_grpc//status:go_default_library to the deps fixes a problem. I definitely tried it today and it did not work ...

Thank you! Apparently a bug in my carelessness...

@asv asv closed this as completed Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants