Nomad: Cross-compilation failure on OS X host

Created on 26 Nov 2015  路  11Comments  路  Source: hashicorp/nomad

This issue has been mentioned here: https://github.com/hashicorp/nomad/pull/438#issuecomment-157568019

$ go version
go version go1.5.1 darwin/amd64

$ make updatedeps
--> Installing build dependencies
--> Updating build dependencies

$ make bin
/Users/legal/go/src/github.com/hashicorp/nomad
==> Getting dependencies...
==> Removing old directory...
==> Building...
Number of parallel builds: 4

-->   windows/amd64: github.com/hashicorp/nomad
-->     linux/amd64: github.com/hashicorp/nomad
-->       linux/386: github.com/hashicorp/nomad
-->    darwin/amd64: github.com/hashicorp/nomad
-->     windows/386: github.com/hashicorp/nomad

2 errors occurred:
--> linux/amd64 error: exit status 2
Stderr: # runtime/cgo
ld: unknown option: --build-id=none
clang: error: linker command failed with exit code 1 (use -v to see invocation)

--> linux/386 error: exit status 2
Stderr: # runtime/cgo
ld: unknown option: --build-id=none
clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [bin] Error 1

I'm new with Golang :(. Please, advice - how can I fix that? I believe, it should be possible to cross-compile Nomad for Linux.

P.s. Seems like there is some new stuff in Go 1.5, related to cross-compilation:
http://dave.cheney.net/2015/03/03/cross-compilation-just-got-a-whole-lot-better-in-go-1-5
Is it the reason of this issue?

cc: @cbednarski

themcore typbug

Most helpful comment

Quick question, does this mean that scripts/build.sh is s broken since it's back to using -cgo? I am encountering the same issue with another project and wanted to see what would be the workaround.

All 11 comments

421 removes the CGO dependency, so you could just use Go's native cross-compiling.

@carlosdp Thanks! I will subscribe on it.

@legal90 Thanks for opening an issue. We are already using the go 1.5 cross-compilation improvements via gox. I will take a look at this today in conjunction with #421.

You should now be able to cross-compile with GOOS=linux GOARCH=amd64 build -o bin/nomad . but make bin is still broken. I will need to dig more.

Perfect, It works fine!
Thank you, @cbednarski, @c4milo

Just updating this issue, we will have to go back to CGO since the user lookup mechanism based on /etc/passwd is not working on coreos

Where does coreos store that?

@diptanu So now (due to #591) this issue is reproduced again:

2 errors occurred:
--> linux/amd64 error: exit status 2
Stderr: # runtime/cgo
ld: unknown option: --build-id=none
clang: error: linker command failed with exit code 1 (use -v to see invocation)

--> linux/386 error: exit status 2
Stderr: # runtime/cgo
ld: unknown option: --build-id=none
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Should it be reopen?

It shouldn't be reopened because this project needs cgo. So cross compiling should not be expected to work.

So cross compiling should not be expected to work.

OK, I got it. Thanks.

Quick question, does this mean that scripts/build.sh is s broken since it's back to using -cgo? I am encountering the same issue with another project and wanted to see what would be the workaround.

Was this page helpful?
0 / 5 - 0 ratings