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

overwritting gogo/protobuf dependency makes protobuf compilation fail #1405

Closed
kevindrosendahl opened this issue Mar 25, 2018 · 2 comments
Closed
Labels

Comments

@kevindrosendahl
Copy link

kevindrosendahl commented Mar 25, 2018

if you import a different version of github.com/gogo/protobuf than what rules_go natively includes, you can no longer compile gogo protobufs.

reproduction:

hello.proto:

syntax = "proto3";

import "google/protobuf/any.proto";

message Foo {
};

WORKSPACE:

http_archive(
    name = "io_bazel_rules_go",
    url = "https://github.com/bazelbuild/rules_go/releases/download/0.10.1/rules_go-0.10.1.tar.gz",
    sha256 = "4b14d8dd31c6dbaf3ff871adcd03f28c3274e42abc855cb8fb4d01233c0154dc",
)
load("@io_bazel_rules_go//go:def.bzl", "go_repository", "go_rules_dependencies", "go_register_toolchains")

go_repository(
    name="com_github_gogo_protobuf",
    commit="1adfc126b41513cc696b209667c8656ea7aac67c",
    importpath="github.com/gogo/protobuf"
)

go_rules_dependencies()
go_register_toolchains()

(note this is even the same version as the one that rules_go natively includes, but also reproducible with other versions)

BUILD.bazel:

load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
    name = "hello_proto",
    srcs = ["hello.proto"],
    visibility = ["//visibility:public"],
    deps = ["@com_google_protobuf//:any_proto"],
)

go_proto_library(
    name = "hello_go_proto",
    compilers = ["@io_bazel_rules_go//proto:gogo_proto"],
    importpath = "example.com/repo",
    proto = ":hello_proto",
    visibility = ["//visibility:public"],
)
$  bazel build //...
INFO: Analysed 2 targets (56 packages loaded).
INFO: Found 2 targets...
ERROR: /private/var/tmp/_bazel_kevinrosendahl/938430ea243630148906fc2cce0e7852/external/com_github_gogo_protobuf/gogoproto/BUILD.bazel:19:1: GoCompile external/com_github_gogo_protobuf/gogoproto/darwin_amd64_stripped/go_default_library~/github.com/gogo/protobuf/gogoproto.a failed (Exit 1)
external/com_github_gogo_protobuf/gogoproto/helper.go:35:37: cannot use E_Embed (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetBoolExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:39:37: cannot use E_Nullable (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetBoolExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:43:37: cannot use E_Stdtime (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetBoolExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:47:37: cannot use E_Stdduration (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetBoolExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:94:36: cannot use E_Enumdecl (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetBoolExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:94:85: cannot use E_EnumdeclAll (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetBoolExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:98:39: cannot use E_Typedecl (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetBoolExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:98:88: cannot use E_TypedeclAll (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetBoolExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:106:37: cannot use E_Customtype (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:119:37: cannot use E_Casttype (type *"github.com/golang/protobuf/proto".ExtensionDesc) as type *"github.com/gogo/protobuf/proto".ExtensionDesc in argument to "github.com/gogo/protobuf/proto".GetExtension
external/com_github_gogo_protobuf/gogoproto/helper.go:119:37: too many errors
2018/03/24 18:17:17 error running compiler: exit status 1
INFO: Elapsed time: 32.263s, Critical Path: 2.50s
FAILED: Build did NOT complete successfully
@kevindrosendahl kevindrosendahl changed the title overwritting gog overwritting gogo/protobuf dependency makes protobuf compilation fail Mar 25, 2018
@jayconrod
Copy link
Contributor

com_github_gogo_protobuf needs some special handling. They have Makefiles that run protoc with some additional flags when generating their .pb.go files. Gazelle (and go_repository) won't be able to figure that out automatically.

I'd recommend using the .pb.go files they have checked in rather than regenerating them with Bazel. Just add build_file_proto_mode = "disable" to the go_repository rule. That will skip generating go_proto_library rules and will treat .pb.go files like normal Go source files.

go_repository(
    name="com_github_gogo_protobuf",
    commit="1adfc126b41513cc696b209667c8656ea7aac67c",
    importpath="github.com/gogo/protobuf",
    build_file_proto_mode = "disable",
)

@kevindrosendahl
Copy link
Author

makes sense, thanks. you can feel free to close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants