Cross-compile go_binary for linux

237 views
Skip to first unread message

Paul Johnston

unread,
Aug 20, 2016, 10:29:49 AM8/20/16
to bazel-discuss
On my osx machine, I'd like compile a go_binary target for inclusion into a docker_build rule for alpine linux.  

Anyone know if the rules_go supports cross-compilation?  If so, what is the correct way to invoke bazel?

Thanks,
Paul

Yugui

unread,
Aug 22, 2016, 6:23:09 AM8/22/16
to Paul Johnston, bazel-discuss
On Sat, Aug 20, 2016 at 11:29 PM Paul Johnston <pcj...@gmail.com> wrote:
On my osx machine, I'd like compile a go_binary target for inclusion into a docker_build rule for alpine linux.  

Anyone know if the rules_go supports cross-compilation?  If so, what is the correct way to invoke bazel?

No, it does not support.
There are two problems as you have already found out by yourself.
  1. Bazel refuses it, like
    ERROR: No toolchain found for cpu 'k8'. Valid cpus are: [
    
    IIUC, Bazel is trying to locate C++ toolchain for the platform when it validate -c flag even if we are trying to build go binary.  I wonder if this is an expected behavior.
  2. GOROOT does not contain a prebuilt std library for the platform. Probably we can extend go_repositories rules to cross compile the std library, but I want to think a bit more about the solution.
    Let's discuss it at #70
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/d7484c3f-52ee-4143-a38e-3a08f2da74cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages