bazelbuild / rules_go

Go rules for Bazel
Apache License 2.0
1.37k stars 649 forks source link

arm build broken #615

Closed bamnet closed 6 years ago

bamnet commented 7 years ago

I'm trying to build a small go_library on a Raspberry Pi 3 using Bazel 0.5.1 + rules_go 0.5.0. I end up getting a bunch of errors from go build:

$ bazel build //server/... --verbose_failures
INFO: Found 1 target...
ERROR: /home/bamnet/.cache/bazel/_bazel_bamnet/36aeec6e43c52c934780da1889073e82/external/io_bazel_rules_go/go/tools/builders/BUILD:21:1: error executing shell command: '-o' failed: go failed: error executing command 
  (exec env - \
    GOROOT=/home/bamnet/.cache/bazel/_bazel_bamnet/36aeec6e43c52c934780da1889073e82/external/go1_8_3_linux_amd64 \
  external/go1_8_3_linux_amd64/bin/go build -o bazel-out/host/bin/external/io_bazel_rules_go/go/tools/builders/compile external/io_bazel_rules_go/go/tools/builders/compile.go external/io_bazel_rules_go/go/tools/builders/filter.go)

Use --sandbox_debug to see verbose messages from the sandbox.
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: uE@p@8: not found
external/go1_8_3_linux_amd64/bin/go: 2: external/go1_8_3_linux_amd64/bin/go: @$: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: ELF: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: �: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: �: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: �{�{k�: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: �: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: L: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: �: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: G�{�: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: cannot open 0B�?BN
                                                                                               ?BHB�HBN�
                                                                                                       ?Q���o@E�@ENH
                                                                                                                    ^���o�E��ENP: No such file
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: -R: not found
external/go1_8_3_linux_amd64/bin/go: 2: external/go1_8_3_linux_amd64/bin/go:F�FN�
                                                                                ��FNm4@H�@HN: not found
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: JN: not found
external/go1_8_3_linux_amd64/bin/go: 2: external/go1_8_3_linux_amd64/bin/go: ��: not found
external/go1_8_3_linux_amd64/bin/go: 4: external/go1_8_3_linux_amd64/bin/go:?O�M��MN�: not found
c��Nm���Nk: not foundx_amd64/bin/go: 4: external/go1_8_3_linux_amd64/bin/go: Y�����Np
external/go1_8_3_linux_amd64/bin/go: 1: external/go1_8_3_linux_amd64/bin/go: Syntax error: Unterminated quoted string
Use --strategy=GoBuildTool=standalone to disable sandboxing for the failing actions.
Target //server:go_default_library failed to build
INFO: Elapsed time: 298.168s, Critical Path: 4.49s

During the initial setup, it looks like the amd64 build of Go is downloaded, not the arm6l build I would expect: Downloading https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz.

I tried mucking around in the skylark but couldn't figure out where go_repositories() is deciding to use the amd64 variant.

$ uname -a
Linux pi-2 4.9.30-v7+ #1001 SMP Fri May 26 16:09:18 BST 2017 armv7l GNU/Linux
ianthehat commented 7 years ago

Until the new platform system is fully ready (hopefully in the next month or so) we don't directly support building for anything except amd64 in linux or mac flavours. If you look in go/private/toolchain.bzl#L54 you will see it picking linux_x86_64 if the host os is linux. You can try to change that and see if it works. Let us know how you get on.

gyliu513 commented 6 years ago

I also build failed on POWER ppc64le with bazel 0.5.4 and filed an issue here https://github.com/bazelbuild/bazel/issues/3815

ianthehat commented 6 years ago

This should now all be working. We detect s390x and ppc64le based on uname -p in go/private/sdk.bzl#L28. If you need a new addition to the list it's a very easy change (but we can't make it without a platform to test it on, so we happily accept contributions)