Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

osx: compilation fails with linker error #30

Closed
tamird opened this issue Nov 3, 2015 · 13 comments
Closed

osx: compilation fails with linker error #30

tamird opened this issue Nov 3, 2015 · 13 comments

Comments

@tamird
Copy link
Contributor

tamird commented Nov 3, 2015

Another one from cockroachdb:

xgo --go=1.5.1 --targets=darwin-10.9/amd64 .
Checking docker installation...
Client:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:49:29 UTC 2015
 OS/Arch:      darwin/amd64

Server:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:49:29 UTC 2015
 OS/Arch:      linux/amd64

Checking for required docker image karalabe/xgo-1.5.1... found.
Cross compiling github.com/cockroachdb/cockroach...
Building locally github.com/cockroachdb/cockroach...
Compiling for darwin-10.9/amd64...
# github.com/cockroachdb/cockroach
/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: internal error: atom not found in symbolIndex(__ZN6snappy17SnappyArrayWriter14AppendFromSelfEmm) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

2015/11/03 15:04:18 Failed to cross compile package: exit status 2.

FWIW, we do all our development on OS X, so it does work natively (i.e. not via xgo).

@karalabe
Copy link
Owner

karalabe commented Nov 4, 2015

This is very strange because it works flawlessly on my machine...

$ xgo --go=1.5.1 --targets=darwin-10.9/amd64 .
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:39:44 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:39:44 UTC 2015
 OS/Arch:      linux/amd64

Checking for required docker image karalabe/xgo-1.5.1... found.
Cross compiling github.com/cockroachdb/c-rocksdb...
Building locally github.com/cockroachdb/c-rocksdb...
Compiling for darwin-10.9/amd64...
ls -al
[...]
-rw-r--r--  1 root     root     4598342 Nov  4 09:20 c-rocksdb-darwin-10.9-amd64

@karalabe
Copy link
Owner

karalabe commented Nov 4, 2015

Could you please run it via xgo --go=1.5.1 -x -v --targets=darwin-10.9/amd64 .? It seems to me that on my machine a different linker is being invoked than on your machine. My ld doesn't complain about -s, yours does, and hence the linker error (-s should strip out unneeded stuff, which gets left in on your end, and later not found).

@karalabe
Copy link
Owner

karalabe commented Nov 4, 2015

Maybe try logging into the cross compiler container and check the environment and ld being used?

$ docker run -it --entrypoint=/bin/bash karalabe/xgo-latest`
# env
# whereis ld
# ld -v

where $ is on the host and # is inside the container.

@tamird
Copy link
Contributor Author

tamird commented Nov 4, 2015

Looks like you built https://github.com/cockroachdb/c-rocksdb rather than https://github.com/cockroachdb/cockroach? Indeed, c-rocksdb does compile successfully and without the -s warning.

@karalabe
Copy link
Owner

karalabe commented Nov 4, 2015

Ah indeed, didn't notice the repo change. Will look into it.

@karalabe
Copy link
Owner

karalabe commented Nov 4, 2015

If fails with a compiler error on my side:

# github.com/cockroachdb/cockroach/storage/engine/rocksdb
In file included from storage/engine/rocksdb/api.pb.cc:5:
storage/engine/rocksdb/cockroach/roachpb/api.pb.h:9:10: fatal error: 'google/protobuf/stubs/common.h' file not found
github.com/cockroachdb/cockroach/storage/engine/rocksdb

@tamird
Copy link
Contributor Author

tamird commented Nov 4, 2015

Did you go get the repo? Looks like you are missing c-protobuf, one of the dependencies.

@karalabe
Copy link
Owner

karalabe commented Nov 5, 2015

Played around with it some more, but it seems it's an osxcross/golang combo issue. osxcross doesn't support generating debugging symbols, so the workaround is -s linker option, but that removes all symbols, not just debug. However, Go linked the debug info skipping to -s, so the corrent -w (or -S?) flag won't skip them. golang/go#11994

@tamird
Copy link
Contributor Author

tamird commented Nov 8, 2015

Some updates:
Apparently it's possible to build osxcross with llvm-dsymutil: tpoechtrager/osxcross#1 (comment)
My patch to fix golang/go#11994 was accepted. Not sure if you're keen on testing with Go tip, but I'd certainly appreciate it!

@karalabe
Copy link
Owner

karalabe commented Nov 9, 2015

I'll try and piece together a developer version og xgo that will pull the latest Go tip and assemble the images based off that, though I'm at a dev conference this week with extremely poor internet access (i.e. git clone is already an issue), so I will probably only get around to this next week. However thanks lot for looking into this.

@karalabe
Copy link
Owner

$ xgo --go=develop -v -x --targets=darwin-10.9/amd64 .
$ ls -al cockroach*
-rwxr-xr-x 1 root root 31785552 Nov 20 17:05 cockroach-darwin-10.9-amd64

Let me just make sure I didn't break anything and I'll push a final version dropping the -s for Go 1.6+.

@karalabe
Copy link
Owner

I've pushed the darwin symbolic table fixes into xgo. Docker Hub just started to crunch through the thing. You should be able to try it out in 1-2 hours (given that docker hub doesn't choke on the build, sometimes it happens to it).

@tamird
Copy link
Contributor Author

tamird commented Nov 20, 2015

Works for me. Thanks for all your help on this issue!

@tamird tamird closed this as completed Nov 20, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants