-
Notifications
You must be signed in to change notification settings - Fork 409
Description
Build/link regression after upgrading gazelle and re-running //:gazelle. This appears due #2071. With this change we are seeing link time failures when there we define messages and service in two different files of the same go_proto_library.
The https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc tool (as used by the grpc_v2 compiler) does not generate the necessary struct definitions. This appears to be the task of https://github.com/protocolbuffers/protobuf-go/tree/master/cmd/protoc-gen-go which is not yet used in rules_go.
I created https://github.com/zecke/gazelle-grpc as a simple reproducer. There are two protobuf files in the root. One defines a Message and the other a gRPC service that uses the message. With the latest gazelle it fails to link due undefined references.
bazel build //:gazelle-grpc
INFO: Analyzed target //:gazelle-grpc (1 packages loaded, 5 targets configured).
ERROR: /Users/ich/source/sre/github.com/zecke/gazelle-grpc/BUILD.bazel:26:11: GoCompilePkg gazelle-grpc.a failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target //:gazelle-grpc) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_go++go_sdk+main___download_0/builder_reset/builder compilepkg -sdk external/rules_go++go_sdk+main___download_0 -goroot ... (remaining 71 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
bazel-out/darwin_arm64-fastbuild/bin/gazelle_grpc_go_proto_/github.com/zecke/gazelle-grpc/service_grpc.pb.go:29:36: undefined: Foo
bazel-out/darwin_arm64-fastbuild/bin/gazelle_grpc_go_proto_/github.com/zecke/gazelle-grpc/service_grpc.pb.go:40:62: undefined: Foo
bazel-out/darwin_arm64-fastbuild/bin/gazelle_grpc_go_proto_/github.com/zecke/gazelle-grpc/service_grpc.pb.go:42:13: undefined: Foo
bazel-out/darwin_arm64-fastbuild/bin/gazelle_grpc_go_proto_/github.com/zecke/gazelle-grpc/service_grpc.pb.go:54:29: undefined: Foo
bazel-out/darwin_arm64-fastbuild/bin/gazelle_grpc_go_proto_/github.com/zecke/gazelle-grpc/service_grpc.pb.go:64:65: undefined: Foo
bazel-out/darwin_arm64-fastbuild/bin/gazelle_grpc_go_proto_/github.com/zecke/gazelle-grpc/service_grpc.pb.go:88:12: undefined: Foo
bazel-out/darwin_arm64-fastbuild/bin/gazelle_grpc_go_proto_/github.com/zecke/gazelle-grpc/service_grpc.pb.go:100:53: undefined: Foo
compilepkg: error running subcommand external/rules_go++go_sdk+main___download_0/pkg/tool/darwin_arm64/compile: exit status 2
Target //:gazelle-grpc failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.341s, Critical Path: 0.09s
INFO: 2 processes: 2 action cache hit, 2 internal.
ERROR: Build did NOT complete successfully
ls -la bazel-out/darwin_arm64-fastbuild/bin/gazelle_grpc_go_proto_/github.com/zecke/gazelle-grpc/
total 16
drwxr-xr-x 4 k wheel 128 Aug 15 17:21 .
drwxr-xr-x 3 k wheel 96 Aug 15 17:21 ..
-r-xr-xr-x 1 k wheel 32 Aug 15 17:21 message_grpc.pb.go
-r-xr-xr-x 1 k wheel 4091 Aug 15 17:21 service_grpc.pb.go
Changing compilers
in the go_proto_library rule back to the previous compiler is fixing the build issue. My proposal would be to revert #2071 until rules_go allows to fully move away from "github.com/golang/protobuf/protoc-gen-go
(there is another issue is that the compilers will use @io_bazel_rules_go regardless of having/not having a repo_name set in MODULE.bazel)