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

go_library fails to link shared library created by cc_binary #1871

Closed
robin-thomas opened this issue Dec 22, 2018 · 1 comment
Closed

go_library fails to link shared library created by cc_binary #1871

robin-thomas opened this issue Dec 22, 2018 · 1 comment

Comments

@robin-thomas
Copy link

robin-thomas commented Dec 22, 2018

Description

Currently, if any of the dependencies of go_library in cgo mode are not cc_library, objc_library, cc_proto_library or cc_import, it fails the build.

But in the case of external dependencies which are unable to use cc_library to bundle all its transitive dependencies (because of bazelbuild/bazel#492), they need to use cc_binary to create a *.so shared library.

Expected outcome

go_library should support linking shared libraries even if they are created by cc_binary.

Bazel version

0.20.0

OS version

Ubuntu 16.04

@jayconrod
Copy link
Contributor

Are you able to use cc_import for this? I think that's supposed to be the tool to solve this problem.

For example, this works for me (but I'm not sure it's suitable for anything more than this trivial case):

load("@io_bazel_rules_go//go:def.bzl", "go_binary")

cc_binary(
    name = "libhello.so",
    srcs = ["hello.c"],
    linkshared = True,
)

cc_import(
    name = "hello",
    shared_library = ":libhello.so",
)

go_binary(
    name = "gello",
    srcs = ["gello.go"],
    cdeps = [":hello"],
    cgo = True,
)

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