Comments (18)
"Apple does not support statically linked binaries on Mac OS X. A statically linked binary assumes binary compatibility at the kernel system call interface, and we do not make any guarantees on that front. Rather, we strive to ensure binary compatibility in each dynamically linked system library and framework." ~Apple Developer Website
from xgo.
I'm encountering this exact same issue: building for OS X fails without much detail.
$ xgo --targets=darwin/* github.com/mattn/go-sqlite3/_example/simple
Checking docker installation...
Client:
Version: 1.8.2
API version: 1.20
Go version: go1.4.2
Git commit: 0a8c2e3
Built: Thu Sep 10 19:19:00 UTC 2015
OS/Arch: linux/amd64
Server:
Version: 1.8.2
API version: 1.20
Go version: go1.4.2
Git commit: 0a8c2e3
Built: Thu Sep 10 19:19:00 UTC 2015
OS/Arch: linux/amd64
Checking for required docker image karalabe/xgo-latest... found.
Cross compiling github.com/mattn/go-sqlite3/_example/simple...
Fetching main repository github.com/mattn/go-sqlite3/_example/simple...
github.com/mattn/go-sqlite3 (download)
Compiling for darwin/amd64...
go build github.com/mattn/go-sqlite3: /usr/local/go/pkg/tool/linux_amd64/cgo: exit status 2
2015/10/21 22:31:24 Failed to cross compile package: exit status 1.
Similar to @kabukky, building for windows/linux works just fine.
Apart from some black magic restrictions to limit the CPU feature set allowed, the only way around this is to build the containers locally on your own machine, which will circumvent the issue.
@karalabe
I'm attempting this workaround right now... It's going to take a while on my sad little laptop, so I figured I'd report this while I waited. Keeping my fingers crossed!
Your xgo project is a huge lifesaver. I'm sincerely grateful for all your work!
Update: It worked! Building the containers locally was the way to go! 👍
Extremely detailed write-up, for anyone who might not be familiar with docker:
-
Git clone karalabe/xgo locally, and change to the
docker/base
dir:git clone https://github.com/karalabe/xgo.git cd xgo/docker/base
-
Docker build the xgo base container locally:
docker build -t xgo-local-base .
-
Determine the latest go-specific image, which uses the base image. As of today,
docker/go-latest/Dockerfile
points todocker/go-1.5.x/Dockerfile
which finally points todocker/go-1.5.1/Dockerfile
. Change dir fromdocker/base
todocker/go-1.5.1
:cd ../go-1.5.1
-
Edit the
Dockerfile
to use your newly created base image:vim Dockerfile ## Change `FROM karalabe/xgo-base` ## to `FROM xgo-local-base`
-
Docker build the go-specific container locally:
docker build -t xgo-local-go-latest .
-
Now you're free to use your locally-built docker container for the
xgo
command.
Just include the flag--image=xgo-local-go-latest
:xgo --image=xgo-local-go-latest github.com/target/path
from xgo.
Just a heads up: It works fine on my other Debian Wheezy VM that I set up a few weeks ago, even after doing a fresh
docker pull karalabe/xgo-latest
Here's the output:
Checking docker installation...
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.4.1
Git commit (client): a8a31ef
OS/Arch (client): linux/amd64
Server version: 1.5.0
Server API version: 1.17
Go version (server): go1.4.1
Git commit (server): a8a31ef
Checking for required docker image karalabe/xgo-latest... found.
Cross compiling github.com/kabukky/journey...
Fetching dependencies...
Fetching github.com/kabukky/journey...
Compiling for linux/amd64...
Compiling for linux/386...
Compiling for linux/arm...
Compiling for windows/amd64...
Compiling for windows/386...
Compiling for darwin/amd64...
Compiling for darwin/386...
Moving binaries to host...
from xgo.
The interesting thing is that in the first instance (the failing one) Go tries to cross compile with the linux toolchain for osx, whicn obviously won't work. Though I've no clue why it would do that. I'll try and look at it a bit later.
from xgo.
Ok, I think I know what the issue was. Docker uses fairly new CPUs to build the images, and the OSX build tools are compiled while building the images. So the OSX cross compilers will actually use fairly modern CPU instructions, which will fail if running (the cross compilation) on an old CPU. Apart from some black magic restrictions to limit the CPU feature set allowed, the only way around this is to build the containers locally on your own machine, which will circumvent the issue.
from xgo.
Glad it worked :D So, then indeed the issue is that the OSX cross compiler suite in the docker image assembled by docker hub contains newer CPU instructions, that will plain crash on an older CPU. When I find the time, I'll write up a small section about this in the readme so people will be aware and I'll also try to incorporate your detailed writeup about the needed steps. Thanks a lot for taking the time to experiment with the issue and detail the exact steps other might need. Cheers :)
from xgo.
I tried @harrytruong suggestions and darwin builds are now failing with a different error message.
Compiling for darwin/amd64...
WORK=/tmp/go-build348372251
mkdir -p $WORK/github.com/jessevdk/go-flags/_obj/
mkdir -p $WORK/github.com/jessevdk/
mkdir -p $WORK/github.com/pksunkara/cbind/parser/_obj/
cd /go/src/github.com/jessevdk/go-flags
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/github.com/jessevdk/go-flags.a -trimpath $WORK -p github.com/jessevdk/go-flags -complete -buildid 64ee345c1d8c958df2a261cc29ac0dc3a4ab6aac -D _/go/src/github.com/jessevdk/go-flags -I $WORK -pack ./arg.go ./closest.go ./command.go ./completion.go ./convert.go ./error.go ./flags.go ./group.go ./help.go ./ini.go ./man.go ./multitag.go ./option.go ./optstyle_other.go ./parser.go ./termsize.go ./termsize_unix.go
mkdir -p $WORK/github.com/pksunkara/cbind/
cd /go/src/github.com/pksunkara/cbind/parser
CGO_LDFLAGS="-g" "-O2" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/pksunkara/cbind/parser/_obj/ -importpath github.com/pksunkara/cbind/parser -- -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ parser.go
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -print-libgcc-file-name
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_main.o -c $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_main.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_export.o -c $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_export.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo2.o -c $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo2.c
o64-clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/Bind.cc.o -c ./Bind.cc
o64-clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/cbind.cc.o -c ./cbind.cc
o64-clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_.o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_main.o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_export.o $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo2.o $WORK/github.com/pksunkara/cbind/parser/_obj/Bind.cc.o $WORK/github.com/pksunkara/cbind/parser/_obj/cbind.cc.o -g -O2
/usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/pksunkara/cbind/parser/_obj/ -dynpackage parser -dynimport $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_.o -dynout $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_import.go
o64-clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/github.com/pksunkara/cbind/parser/_obj/_all.o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_export.o $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo2.o $WORK/github.com/pksunkara/cbind/parser/_obj/Bind.cc.o $WORK/github.com/pksunkara/cbind/parser/_obj/cbind.cc.o -g -O2 -Wl,-r -nostdlib
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/github.com/pksunkara/cbind/parser.a -trimpath $WORK -p github.com/pksunkara/cbind/parser -buildid 35701231d9dfeef99a7d3d46cf8e682c6059d87b -D _/go/src/github.com/pksunkara/cbind/parser -I $WORK -pack $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_gotypes.go $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo1.go $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_import.go
pack r $WORK/github.com/pksunkara/cbind/parser.a $WORK/github.com/pksunkara/cbind/parser/_obj/_all.o # internal
mkdir -p $WORK/github.com/pksunkara/cbind/_obj/
mkdir -p $WORK/github.com/pksunkara/cbind/_obj/exe/
cd /go/src/github.com/pksunkara/cbind
CGO_LDFLAGS="-g" "-O2" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/pksunkara/cbind/_obj/ -importpath github.com/pksunkara/cbind -- -I $WORK/github.com/pksunkara/cbind/_obj/ main.go
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I $WORK/github.com/pksunkara/cbind/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/_obj/_cgo_main.o -c $WORK/github.com/pksunkara/cbind/_obj/_cgo_main.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I $WORK/github.com/pksunkara/cbind/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/_obj/_cgo_export.o -c $WORK/github.com/pksunkara/cbind/_obj/_cgo_export.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I $WORK/github.com/pksunkara/cbind/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/_obj/main.cgo2.o -c $WORK/github.com/pksunkara/cbind/_obj/main.cgo2.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/github.com/pksunkara/cbind/_obj/_cgo_.o $WORK/github.com/pksunkara/cbind/_obj/_cgo_main.o $WORK/github.com/pksunkara/cbind/_obj/_cgo_export.o $WORK/github.com/pksunkara/cbind/_obj/main.cgo2.o -g -O2
/usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/pksunkara/cbind/_obj/ -dynpackage main -dynimport $WORK/github.com/pksunkara/cbind/_obj/_cgo_.o -dynout $WORK/github.com/pksunkara/cbind/_obj/_cgo_import.go
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/github.com/pksunkara/cbind/_obj/_all.o $WORK/github.com/pksunkara/cbind/_obj/_cgo_export.o $WORK/github.com/pksunkara/cbind/_obj/main.cgo2.o -g -O2 -Wl,-r -nostdlib
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/github.com/pksunkara/cbind.a -trimpath $WORK -p main -buildid 84a9c22e1c580296a9a3f6beaf9d37bd990b4828 -D _/go/src/github.com/pksunkara/cbind -I $WORK -I /go/pkg/darwin_amd64 -pack $WORK/github.com/pksunkara/cbind/_obj/_cgo_gotypes.go $WORK/github.com/pksunkara/cbind/_obj/main.cgo1.go $WORK/github.com/pksunkara/cbind/_obj/_cgo_import.go
pack r $WORK/github.com/pksunkara/cbind.a $WORK/github.com/pksunkara/cbind/_obj/_all.o # internal
cd .
/usr/local/go/pkg/tool/linux_amd64/link -o $WORK/github.com/pksunkara/cbind/_obj/exe/a.out -L $WORK -L /go/pkg/darwin_amd64 -extld=o64-clang++ -buildmode=exe -buildid=84a9c22e1c580296a9a3f6beaf9d37bd990b4828 -s -extldflags -static $WORK/github.com/pksunkara/cbind.a
# github.com/pksunkara/cbind
/usr/local/go/pkg/tool/linux_amd64/link: running o64-clang++ failed: exit status 1
ld: warning: option -s is obsolete and being ignored
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
from xgo.
Btw, I've pushed a osx wrapper fix that should now avoid any native CPU optimisations (i.e. it shoulnd't fail with illegal instruction errors any more). The updates are still building.
from xgo.
@karalabe So, we should rebuild our xgo again from our local repo? Or can we use docker's directly? And will it solve the -lcrt0.o
problem I am encountering?
from xgo.
I just confirmed that I was able to build @pksunkara's cbind test repo by (1) using my locally built docker image, and also by (2) using @karalabe's latest docker image.
@pksunkara -- try again with the latest docker image? make sure you run docker pull karalabe/xgo-latest
first, before running your usual xgo
command.
I'm testing the latest docker image against my personal projects now... will report back later. Great work @karalabe!
from xgo.
@harrytruong There seem to be some very strange quirk with running docker on osx. I've got a separate report too about linker errors like the one reported in here, but they never occur on my machine, only reported by people running docker on osx. Also that error (that -s
is not recognized) isn't produced by the linux ld, as the gnu ld supports it. So i'm a bit puzzled how the wrong ld
is called, or even where the wrong ld comes from.
from xgo.
@harrytruong Weird. I will try again using the latest master branch of xgo and report back. By the way, I am using docker on Ubuntu 15.10. Not OS X.
from xgo.
@pksunkara Really? I'm sorry, don't know where I saw darwin. Could you try and report back on your results?
from xgo.
@karalabe Rebuilt the xgo image from this repository. This is the error I am getting:
My system: ubuntu 15.10
pksunkara@codecave [~] #18 → xgo --image=xgo -ldflags='-extldflags "-static"' -targets='darwin/*' -x github.com/pksunkara/cbind
Checking docker installation...
Client:
Version: 1.8.3
API version: 1.20
Go version: go1.4.2
Git commit: f4bf5c7
Built: Mon Oct 12 05:42:26 UTC 2015
OS/Arch: linux/amd64
Server:
Version: 1.8.3
API version: 1.20
Go version: go1.4.2
Git commit: f4bf5c7
Built: Mon Oct 12 05:42:26 UTC 2015
OS/Arch: linux/amd64
Checking for required docker image xgo... found.
Cross compiling github.com/pksunkara/cbind...
Fetching main repository github.com/pksunkara/cbind...
github.com/pksunkara/cbind (download)
github.com/jessevdk/go-flags (download)
Compiling for darwin-10.6/amd64...
WORK=/tmp/go-build695569170
mkdir -p $WORK/github.com/jessevdk/go-flags/_obj/
mkdir -p $WORK/github.com/jessevdk/
cd /go/src/github.com/jessevdk/go-flags
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/github.com/jessevdk/go-flags.a -trimpath $WORK -p github.com/jessevdk/go-flags -complete -buildid 64ee345c1d8c958df2a261cc29ac0dc3a4ab6aac -D _/go/src/github.com/jessevdk/go-flags -I $WORK -pack ./arg.go ./closest.go ./command.go ./completion.go ./convert.go ./error.go ./flags.go ./group.go ./help.go ./ini.go ./man.go ./multitag.go ./option.go ./optstyle_other.go ./parser.go ./termsize.go ./termsize_unix.go
mkdir -p $WORK/github.com/pksunkara/cbind/parser/_obj/
mkdir -p $WORK/github.com/pksunkara/cbind/
cd /go/src/github.com/pksunkara/cbind/parser
CGO_LDFLAGS="-g" "-O2" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/pksunkara/cbind/parser/_obj/ -importpath github.com/pksunkara/cbind/parser -- -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ parser.go
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -print-libgcc-file-name
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_main.o -c $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_main.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_export.o -c $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_export.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo2.o -c $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo2.c
o64-clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/Bind.cc.o -c ./Bind.cc
o64-clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I. -I $WORK/github.com/pksunkara/cbind/parser/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/parser/_obj/cbind.cc.o -c ./cbind.cc
o64-clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_.o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_main.o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_export.o $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo2.o $WORK/github.com/pksunkara/cbind/parser/_obj/Bind.cc.o $WORK/github.com/pksunkara/cbind/parser/_obj/cbind.cc.o -g -O2
/usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/pksunkara/cbind/parser/_obj/ -dynpackage parser -dynimport $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_.o -dynout $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_import.go
o64-clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/github.com/pksunkara/cbind/parser/_obj/_all.o $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_export.o $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo2.o $WORK/github.com/pksunkara/cbind/parser/_obj/Bind.cc.o $WORK/github.com/pksunkara/cbind/parser/_obj/cbind.cc.o -g -O2 -Wl,-r -nostdlib
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/github.com/pksunkara/cbind/parser.a -trimpath $WORK -p github.com/pksunkara/cbind/parser -buildid 35701231d9dfeef99a7d3d46cf8e682c6059d87b -D _/go/src/github.com/pksunkara/cbind/parser -I $WORK -pack $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_gotypes.go $WORK/github.com/pksunkara/cbind/parser/_obj/parser.cgo1.go $WORK/github.com/pksunkara/cbind/parser/_obj/_cgo_import.go
pack r $WORK/github.com/pksunkara/cbind/parser.a $WORK/github.com/pksunkara/cbind/parser/_obj/_all.o # internal
mkdir -p $WORK/github.com/pksunkara/cbind/_obj/
mkdir -p $WORK/github.com/pksunkara/cbind/_obj/exe/
cd /go/src/github.com/pksunkara/cbind
CGO_LDFLAGS="-g" "-O2" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/pksunkara/cbind/_obj/ -importpath github.com/pksunkara/cbind -- -I $WORK/github.com/pksunkara/cbind/_obj/ main.go
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I $WORK/github.com/pksunkara/cbind/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/_obj/_cgo_main.o -c $WORK/github.com/pksunkara/cbind/_obj/_cgo_main.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I $WORK/github.com/pksunkara/cbind/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/_obj/_cgo_export.o -c $WORK/github.com/pksunkara/cbind/_obj/_cgo_export.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I $WORK/github.com/pksunkara/cbind/_obj/ -g -O2 -o $WORK/github.com/pksunkara/cbind/_obj/main.cgo2.o -c $WORK/github.com/pksunkara/cbind/_obj/main.cgo2.c
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/github.com/pksunkara/cbind/_obj/_cgo_.o $WORK/github.com/pksunkara/cbind/_obj/_cgo_main.o $WORK/github.com/pksunkara/cbind/_obj/_cgo_export.o $WORK/github.com/pksunkara/cbind/_obj/main.cgo2.o -g -O2
/usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/pksunkara/cbind/_obj/ -dynpackage main -dynimport $WORK/github.com/pksunkara/cbind/_obj/_cgo_.o -dynout $WORK/github.com/pksunkara/cbind/_obj/_cgo_import.go
o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/github.com/pksunkara/cbind/_obj/_all.o $WORK/github.com/pksunkara/cbind/_obj/_cgo_export.o $WORK/github.com/pksunkara/cbind/_obj/main.cgo2.o -g -O2 -Wl,-r -nostdlib
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/github.com/pksunkara/cbind.a -trimpath $WORK -p main -buildid 84a9c22e1c580296a9a3f6beaf9d37bd990b4828 -D _/go/src/github.com/pksunkara/cbind -I $WORK -I /go/pkg/darwin_amd64 -pack $WORK/github.com/pksunkara/cbind/_obj/_cgo_gotypes.go $WORK/github.com/pksunkara/cbind/_obj/main.cgo1.go $WORK/github.com/pksunkara/cbind/_obj/_cgo_import.go
pack r $WORK/github.com/pksunkara/cbind.a $WORK/github.com/pksunkara/cbind/_obj/_all.o # internal
cd .
/usr/local/go/pkg/tool/linux_amd64/link -o $WORK/github.com/pksunkara/cbind/_obj/exe/a.out -L $WORK -L /go/pkg/darwin_amd64 -extld=o64-clang++ -buildmode=exe -buildid=84a9c22e1c580296a9a3f6beaf9d37bd990b4828 -s -extldflags -static $WORK/github.com/pksunkara/cbind.a
# github.com/pksunkara/cbind
/usr/local/go/pkg/tool/linux_amd64/link: running o64-clang++ failed: exit status 1
ld: warning: option -s is obsolete and being ignored
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
2015/11/05 16:03:46 Failed to cross compile package: exit status 2.
I have even tried adding the flag --go=1.5.1
and also changing targets to darwin-10.9/amd64
. Both are giving the same error.
from xgo.
@pksunkara Remove -ldflags='-extldflags "-static"'
, there is no static version of crt0.o
.
from xgo.
@karalabe I understand that. But I want to build a static binary for darwin. Can we make xgo do that?
from xgo.
@pksunkara Remove -ldflags='-extldflags "-static"', there is no static version of crt0.o.
I ran into this issue, but how can i build static binaries for everything except darwin within a single xgo call?
from xgo.
@karalabe thank you so much 👍 This single comment saved my day. I didn't get why golang's ld step wouldn't find my library (which I even checked for find -name libasound.so || exit 1
). But I didn't compile the static version...
Remove -ldflags='-extldflags "-static"', there is no static version of crt0.o.
#15 (comment)
from xgo.
Related Issues (20)
- Handle ellipsis (cmd/...) syntax for producing multiple distinct programs HOT 2
- Cleanup leftover docker containers on main process kill
- Outside project not in GOPATH can't use go mod with build tags -mod=vendor
- Using with libgit2 (git2go) HOT 1
- How to set go env `GOPROXY=https://goproxy.cn,direct` in the docker container? HOT 1
- Provide precompiled binary on gh-action
- [Feature Request] Support building MSI
- Can't cross-compile a project because of the need for Go 1.14. Is this project still in development?
- Zig equivalent
- How do I set CGO_CFLAGS?
- compile gon2n error
- No $GOPATH is set or forwarded to xgo HOT 1
- Is this project dead? HOT 1
- Upgrade to Go 1.16 (latest) HOT 2
- provide additional header files HOT 1
- Windows binaries silently fail to execute
- Stable release? HOT 2
- Support for go1.16 HOT 1
- C/C++ equivalent?
- Windows 10 Defender flags exe as trojan HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xgo.