Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: Cross compile for linux failed on Mac osx (10.10.5) with Golang 1.5 #12248

Closed
gfremex opened this issue Aug 21, 2015 · 2 comments
Closed
Milestone

Comments

@gfremex
Copy link

gfremex commented Aug 21, 2015

I am doing my development work in Eclipse Mars with Goclipse plugin on Mac osx (10.10.5).

I need to cross compile for linux/amd64.

After set GOOS=linux and GOARCH=amd64 in "Preferences" -> "Go", the following error occurred:

************ Building Go project: xxx ************
with GOPATH: ......
Running: /usr/local/go/bin/go install -v -gcflags "-N -l" ./...
runtime
go install runtime: mkdir /usr/local/go/pkg/linux_amd64/: permission denied
^^^ Terminated, exit code: 1 ^^^
************ Build terminated. ************

go was going to create the wrong directory: /usr/local/go/pkg/linux_amd64/

Then I tried this command line manually:

export GOOS=linux

export GOARCH=amd64

/usr/local/go/bin/go install -x -v -gcflags "-N -l" ./...

WORK=/var/folders/2f/c4ny3kl920sc6dxdkpmw54vr0000gn/T/go-build250175624
runtime
mkdir -p $WORK/runtime/_obj/
mkdir -p $WORK/
cd /usr/local/go/src/runtime
/usr/local/go/pkg/tool/darwin_amd64/compile -o $WORK/runtime.a -trimpath $WORK -N -l -p runtime -+ -buildid 6d5354bd14cc24df376bca66e501e715c0c9847b -D _/usr/local/go/src/runtime -I $WORK -pack -asmhdr $WORK/runtime/_obj/go_asm.h ./alg.go ./arch1_amd64.go ./arch_amd64.go ./atomic_amd64x.go ./atomic_pointer.go ./cgo.go ./cgocall.go ./cgocallback.go ./chan.go ./compiler.go ./complex.go ./cpuprof.go ./cputicks.go ./debug.go ./defs_linux_amd64.go ./env_posix.go ./error.go ./extern.go ./hash64.go ./hashmap.go ./hashmap_fast.go ./heapdump.go ./iface.go ./lfstack.go ./lfstack_amd64.go ./lock_futex.go ./malloc.go ./mbarrier.go ./mbitmap.go ./mcache.go ./mcentral.go ./mem_linux.go ./mfinal.go ./mfixalloc.go ./mgc.go ./mgcmark.go ./mgcsweep.go ./mgcwork.go ./mheap.go ./mprof.go ./msize.go ./mstats.go ./netpoll.go ./netpoll_epoll.go ./os1_linux.go ./os2_linux.go ./os_linux.go ./panic.go ./panic1.go ./parfor.go ./print1.go ./print1_write.go ./proc.go ./proc1.go ./race0.go ./rdebug.go ./rune.go ./runtime.go ./runtime1.go ./runtime2.go ./select.go ./sema.go ./signal1_unix.go ./signal_amd64x.go ./signal_linux.go ./signal_linux_amd64.go ./signal_unix.go ./sigpanic_unix.go ./sigqueue.go ./slice.go ./softfloat64.go ./sqrt.go ./stack1.go ./stack2.go ./string.go ./string1.go ./stubs.go ./stubs2.go ./symtab.go ./sys_x86.go ./time.go ./trace.go ./traceback.go ./type.go ./typekind.go ./typekind1.go ./unaligned1.go ./vdso_linux_amd64.go ./wbfat.go ./zgoarch_amd64.go ./zgoos_linux.go ./zversion.go
/usr/local/go/pkg/tool/darwin_amd64/asm -o $WORK/runtime/_obj/asm.o -trimpath $WORK -I $WORK/runtime/_obj/ -I /usr/local/go/pkg/include -D GOOS_linux -D GOARCH_amd64 ./asm.s
/usr/local/go/pkg/tool/darwin_amd64/asm -o $WORK/runtime/_obj/asm_amd64.o -trimpath $WORK -I $WORK/runtime/_obj/ -I /usr/local/go/pkg/include -D GOOS_linux -D GOARCH_amd64 ./asm_amd64.s
/usr/local/go/pkg/tool/darwin_amd64/asm -o $WORK/runtime/_obj/duff_amd64.o -trimpath $WORK -I $WORK/runtime/_obj/ -I /usr/local/go/pkg/include -D GOOS_linux -D GOARCH_amd64 ./duff_amd64.s
/usr/local/go/pkg/tool/darwin_amd64/asm -o $WORK/runtime/_obj/memclr_amd64.o -trimpath $WORK -I $WORK/runtime/_obj/ -I /usr/local/go/pkg/include -D GOOS_linux -D GOARCH_amd64 ./memclr_amd64.s
/usr/local/go/pkg/tool/darwin_amd64/asm -o $WORK/runtime/_obj/memmove_amd64.o -trimpath $WORK -I $WORK/runtime/_obj/ -I /usr/local/go/pkg/include -D GOOS_linux -D GOARCH_amd64 ./memmove_amd64.s
/usr/local/go/pkg/tool/darwin_amd64/asm -o $WORK/runtime/_obj/rt0_linux_amd64.o -trimpath $WORK -I $WORK/runtime/_obj/ -I /usr/local/go/pkg/include -D GOOS_linux -D GOARCH_amd64 ./rt0_linux_amd64.s
/usr/local/go/pkg/tool/darwin_amd64/asm -o $WORK/runtime/_obj/sys_linux_amd64.o -trimpath $WORK -I $WORK/runtime/_obj/ -I /usr/local/go/pkg/include -D GOOS_linux -D GOARCH_amd64 ./sys_linux_amd64.s
pack r $WORK/runtime.a $WORK/runtime/_obj/asm.o $WORK/runtime/_obj/asm_amd64.o $WORK/runtime/_obj/duff_amd64.o $WORK/runtime/_obj/memclr_amd64.o $WORK/runtime/_obj/memmove_amd64.o $WORK/runtime/_obj/rt0_linux_amd64.o $WORK/runtime/_obj/sys_linux_amd64.o # internal
mkdir -p /usr/local/go/pkg/linux_amd64/
go install runtime: mkdir /usr/local/go/pkg/linux_amd64/: permission denied

This never happenned with Golang 1.4.2

@ianlancetaylor ianlancetaylor changed the title Cross compile for linux failed on Mac osx (10.10.5) with Golang 1.5 cmd/go: Cross compile for linux failed on Mac osx (10.10.5) with Golang 1.5 Aug 21, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Aug 21, 2015
@zeayes
Copy link

zeayes commented Aug 21, 2015

I installed go1.5 with homebrew on mac pro.
Cross compile go as follows:

cd  /usr/local/opt/go/libexec/src 
GOROOT_BOOTSTRAP=/usr/local/Cellar/go/1.4.2/libexec GOOS=linux GOARCH=amd64 ./make.bash --no-clean

@davecheney
Copy link
Contributor

Hello, that step is no longer necessary in go 1.5. With Go 1.5 you cannot cross compiled without preparation by setting the required environment variables and using go build.

Please see my blog post for more information.

http://dave.cheney.net/2015/03/03/cross-compilation-just-got-a-whole-lot-better-in-go-1-5

@golang golang locked and limited conversation to collaborators Aug 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants