inconshreveable / gonative

Build Go Toolchains /w native libs for cross-compilation
340 stars 36 forks source link

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

Open tchap opened 8 years ago

tchap commented 8 years ago

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 commented 8 years ago

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

inconshreveable commented 8 years ago

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

tchap commented 8 years ago

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...

inconshreveable commented 8 years ago

Some possibilities:

tchap commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

tchap commented 8 years ago

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 commented 8 years ago

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

databus23 commented 8 years ago

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

databus23 commented 8 years ago

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

tchap commented 8 years ago

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