-
-
Notifications
You must be signed in to change notification settings - Fork 678
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
Cross compilation is broken with golang.org/x/sys/unix #1215
Comments
I forgot to mention that |
Running into the same issue, with the same error message
|
Running into the same issue, with the same error message
|
Running into the same issue, with the same error message
|
Just to explain what's happening here, most of the sources in golang.org/x/sys/unix have build constraints. Gazelle (via
An appropriate list of sources is selected by Bazel using the target platform, which is usually provided on the command line. However, when a The other approach to cross-compiling is to set the target platform on the command line instead of in
This seems to be broken for a different reason. I've opened #1304 to track that. We will fix that soon. Unfortunately, setting the target platform on the command line doesn't work well for multi-platform builds, e.g., if you want to build a release package that includes binaries for multiple platforms. There's no good solution for this yet. |
We found a workaround for this problem. Apparently this 'select' is not required at all. If you try to compile all sources for all platforms, underlying compiler is following // +build specs and produce correct result. Here is our vendor/golang.org/x/sys/unix/BUILD: `load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( |
Seems like a good short-term solution. I think the only reason we use
|
EDIT: it seems you already commented that @jayconrod, sorry |
Any better solution other than manually changing the BUILD files and removing |
@srikumarb At the moment, no. I'm planning to have Gazelle (and EDIT: Using |
@jayconrod, I tried specifying --platforms in build command but that throws lot of random import errors all the time:
Do you have any idea why it does not work? |
@jayconrod, we have been using Any workaround is highly appreciated. we have many packages imported hence manually fixing select is not an option for me. |
@jayconrod could you let me know the path to use for master? I can quickly try it and confirm before you tag it. |
@srikumar-b Sure, just replace the
|
@jayconrod works like a charm. Thanks a lot. |
@jayconrod If you are going to tag it in next couple of hours, I would choose to wait and use the release tag directly. Thanks again. |
Release is tagged now. |
@jayconrod Thanks Jay. I am getting an interesting error with the new release now... I get build errors with dependency resolution with package https://github.com/PuerkitoBio/purell because Build Error:
Generated BUILD.bazel with 0.9.0:
Generated BUILD.bazel with 0.10.0:
|
@srikumar-b I've filed bazel-contrib/bazel-gazelle#137 to address this. In the mean time, you should be able to work around this by changing the name of the rule in WORKSPACE that imports this repository to |
Thanks @jayconrod I only see these entries in Gopkg.lock but not in WORKSPACE. Is it possible to override these entries from WORKSPACE?
|
I'm guessing you're using I'd recommend using |
@jayconrod I have manually added those to WORKSPACE but now I am getting this issue: kubernetes/kubernetes#50975 |
@srikumar-b That seems like an issue in the implementation of |
(Re-triaging old issues) Closing as obsolete. This issue covered a lot of problems, most of which have been fixed. The main problem, that |
I am trying to cross compile to linux binary on darwin_amd64 machine. Compiling to darwin_amd64 target works file, cross compiling to linux_amd64 produces the following error:
This problem makes it impossible to build a linux binary (and, consequentially, docker image) referring golang.org/x/sys/unix or any of 2244 packages dependent on it https://godoc.org/golang.org/x/sys/unix?importers. We got this while trying to use github.com/fsnotify/fsnotify.
How to reproduce:
clone github.com/apesternikov/bazel_go_repr
bazel build //:doit
works fine,bazel build //:doit_cross
fails.https://github.com/apesternikov/bazel_go_repr/blob/master/BUILD
The text was updated successfully, but these errors were encountered: