gonative icon indicating copy to clipboard operation
gonative copied to clipboard

Failing to cross-compile when using gonative, gox and Go 1.5.1

Open tchap opened this issue 9 years ago • 14 comments

I am using gonative and gox to cross-compile an executable using os/user. It has always been working, but it broke down when CircleCI upgraded their Golang to 1.5.1 I think. Now I am getting user: Current not implemented on darwin/amd64 from the cross-compiled executables. Any ideas what might be wrong now before I try to dive deep into Go 1.5 cross-compilation changes myself?

CC @inconshreveable

tchap avatar Jan 04 '16 15:01 tchap

Hmm, works locally, I will close this before I can prove it's not just CircleCI env setup error...

tchap avatar Jan 04 '16 16:01 tchap

It works locally on 1.5.1 but not on circle? That's pretty bizarre.

inconshreveable avatar Jan 04 '16 18:01 inconshreveable

Yeah, something weird. When I do everything locally and try the cross-compiled executable, it works. When I SSH into a CircleCI container and do the same thing manually, I get the error that user.Current is not specified...

tchap avatar Jan 04 '16 22:01 tchap

Some possibilities:

  • Inside circle, the binaries are being built with their version of Go instead of the one created by gonative
  • gonative is failing silently and producing a Go installation that doesn't used the downloaded libraries

inconshreveable avatar Jan 05 '16 03:01 inconshreveable

Thanks for the hints. What is weird for me is that it has always been working just fine, it just broke for some reason recently. I did refactor the build scripts, but they should be doing the same thing...

tchap avatar Jan 05 '16 07:01 tchap

Well, the good part is that I changed the scripts to work locally as well and the executables are broken even when run locally, so the scripts are simply wrong somehow. No idea why it used to work then, but whatever...

tchap avatar Jan 05 '16 15:01 tchap

Actually I am getting the same error locally when using the commands as in README examples, i.e.

$ go get -u github.com/mitchellh/gox
$ <build current gonative using make>
$ cd /your/project
$ gonative build
$ PATH=$PWD/go/bin/:$PATH gox

Weird, I though that this was working...

tchap avatar Jan 06 '16 08:01 tchap

Actually it doesn't work even when I use system Go 1.5.2 like

gox -osarch=darwin/amd64

It starts working when I add -cgo...

tchap avatar Jan 06 '16 09:01 tchap

Seems like a gox issue to me, somehow...

tchap avatar Jan 06 '16 09:01 tchap

I basically don't understand why the following command rebuilds the standard library...

$ GOROOT_BOOTSTRAP="..." gonative build --platforms 'darwin_amd64 linux_amd64 windows_amd64'
...
$ PATH="`pwd`/go/bin:$PATH" GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v
runtime
errors
math
sync/atomic
unicode/utf8
sort
unicode
sync
...

tchap avatar Jan 06 '16 10:01 tchap

Yeah, confirmed that the same thing totally works when using --version 1.4.3 with gonative. Forwarded to golang-nuts mailing list...

tchap avatar Jan 06 '16 10:01 tchap

I can't seem to get gonative to work for go >= 1.5. It always seems to rebuild the stdlib.

databus23 avatar Feb 24 '16 23:02 databus23

Maybe its related to this change: https://go-review.googlesource.com/#/c/9154/.

databus23 avatar Feb 24 '16 23:02 databus23

Dunno. I actually asked on the mailing list, but no one replied. I ended up downgrading to Go 1.4.3 actually...

tchap avatar Feb 25 '16 07:02 tchap