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

rules_go breaks with incompatible_require_linker_input_cc_api #2720

Closed
shahms opened this issue Nov 16, 2020 · 11 comments
Closed

rules_go breaks with incompatible_require_linker_input_cc_api #2720

shahms opened this issue Nov 16, 2020 · 11 comments
Milestone

Comments

@shahms
Copy link
Contributor

shahms commented Nov 16, 2020

(See kythe/kythe#4760)

What version of rules_go are you using?

v0.24.7

What version of gazelle are you using?

v0.22.2

What version of Bazel are you using?

3.7.0

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

yes

What did you do?

bazel test --incompatible_require_linker_input_cc_api //kythe/...

What did you expect to see?

A successful build.

What did you see instead?

ERROR: /usr/local/google/home/shahms/.cache/bazel/_bazel_shahms/f0c8a49cbf1bfaa82de86be744427f4b/external/com_github_jmhodges_levigo/BUILD.bazel:9:11: in go_library rule @com_github_jmhodges_levigo//:levigo:
Traceback (most recent call last):
        File "/usr/local/google/home/shahms/.cache/bazel/_bazel_shahms/f0c8a49cbf1bfaa82de86be744427f4b/external/io_bazel_rules_go/go/private/rules/library.bzl", line 38, column 25, in _go_library_impl
                archive = go.archive(go, source)
        File "/usr/local/google/home/shahms/.cache/bazel/_bazel_shahms/f0c8a49cbf1bfaa82de86be744427f4b/external/io_bazel_rules_go/go/private/actions/archive.bzl", line 82, column 28, in emit_archive
                cgo = cgo_configure(
        File "/usr/local/google/home/shahms/.cache/bazel/_bazel_shahms/f0c8a49cbf1bfaa82de86be744427f4b/external/io_bazel_rules_go/go/private/rules/cgo.bzl", line 112, column 31, in cgo_configure
                cc_libs = _cc_libs(d)
        File "/usr/local/google/home/shahms/.cache/bazel/_bazel_shahms/f0c8a49cbf1bfaa82de86be744427f4b/external/io_bazel_rules_go/go/private/rules/cgo.bzl", line 191, column 67, in _cc_libs
                libraries_to_link = as_iterable(target[CcInfo].linking_context.libraries_to_link)
Error: 'LinkingContext' value has no field or method 'libraries_to_link'
@jayconrod jayconrod added this to the v0.25 milestone Nov 16, 2020
@meteorcloudy
Copy link
Contributor

meteorcloudy commented Nov 17, 2020

Strangely, rules_go is green in Bazel downstream. Do we lack test coverage for this?
https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1767

@shahms
Copy link
Contributor Author

shahms commented Nov 17, 2020

We see these failures for two very straightforward cgo-using targets:
@com_github_jmhodges_levigo//:levigo

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

go_library(
    name = "levigo",
    srcs = [
        "batch.go",
        "cache.go",
        "comparator.go",
        "conv.go",
        "db.go",
        "doc.go",
        "env.go",
        "filterpolicy.go",
        "iterator.go",
        "options.go",
        "version.go",
    ],
    cdeps = ["@com_github_google_leveldb//:leveldb"],
    cgo = True,
    importpath = "github.com/jmhodges/levigo",
    visibility = ["//visibility:public"],
)

@com_github_google_brotli_go_cbrotli//:cbrotli

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

go_library(
    name = "cbrotli",
    srcs = [
        "reader.go",
        "writer.go",
    ],
    cdeps = [
        "@org_brotli//:brotlidec",
        "@org_brotli//:brotlienc",
    ],
    cgo = True,
    importpath = "github.com/google/brotli/go/cbrotli",
)

The cc_library targets on which they depend are similarly straightforward. Poking at the rules_go tests a bit, it seems like this case should be covered.

@meteorcloudy
Copy link
Contributor

Looks like 3f47128 fixed the problem, but it's not yet included in a release.
@jayconrod When is the next rules_go release?

@jayconrod
Copy link
Contributor

@meteorcloudy The next minor release is scheduled for mid-December. I couldn't include this change in a patch release because it increased the minimum supported version of Bazel.

Is this needed sooner? I haven't had time to look into this yet beyond basic triage, so I'm not sure what the state of the flag is.

@meteorcloudy
Copy link
Contributor

The flag is flipped and will be included in the 4.0 Bazel LTS release (which is probably going out in Dec). We caught the problem in downstream for Kythe, it's better to have a rules_go version that people can upgrade to for 4.0.

In the meantime, @shahms do you want to wait for the rules_go release or can you ping it to a specific commit?

@jayconrod
Copy link
Contributor

@meteorcloudy Ok cool. I'll pull in the rules_go release as much as I can, but the earliest it could go out is ~2 weeks from now.

@jayconrod
Copy link
Contributor

Confirmed that @com_github_google_brotli_go//cbrotli is broken with rules_go v0.24.7 but passes at master when --incompatible_require_linker_input_cc_api is set. Since this was fixed in #2683, I'll close this issue.

@shahms
Copy link
Contributor Author

shahms commented Nov 19, 2020

@meteorcloudy Generally prefer to wait for a rules_go release, but willing to pin to a git commit if you need. Thanks!

@meteorcloudy
Copy link
Contributor

@shahms If you can pin rules_go to a commit, we can still test Bazel@HEAD with Kythe in downstream so that we can catch other potential breakages for you. ;)

@mrmeku
Copy link

mrmeku commented Jan 21, 2021

@jayconrod I believe this bug should be reopened. On bazel 4.0 (which flips --incompatible_require_linker_input_cc_api to true by default) this bug is replicated. And I've confirmed manually setting the flag to false fixes the bug.

@jayconrod
Copy link
Contributor

@mrmeku This seems to be working on master and on the 0.25 branch. The fix cannot be backported to the 0.24 branch because the minimum supported version of Bazel (2.2.0) did not support this API.

rrbutani added a commit to rrbutani/bazel-toolchain that referenced this issue Feb 9, 2021
rrbutani added a commit to rrbutani/bazel-toolchain that referenced this issue Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants