Skip to content

cmd/ld: Failure to link cgo program on darwin / Mac OS X 10.6 #8791

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

Closed
gopherbot opened this issue Sep 22, 2014 · 4 comments
Closed

cmd/ld: Failure to link cgo program on darwin / Mac OS X 10.6 #8791

gopherbot opened this issue Sep 22, 2014 · 4 comments

Comments

@gopherbot
Copy link
Contributor

by jobi@litl.com:

I'm trying to compile a program that uses cgo on Mac OS X 10.6. I've tried both the
internal and host linkers, without much luck:

$ go version
go version go1.3.1 darwin/amd64

$ go build
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol close
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol access
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol getcwd
(...)

$ go build -ldflags -linkmode=external
ld: unknown option: -no_pie
collect2: ld returned 1 exit status
/Users/jobi/go-sdk/pkg/tool/darwin_amd64/6l: running gcc failed: unsuccessful exit
status 0x100
@gopherbot
Copy link
Contributor Author

Comment 1 by jobi@litl.com:

I recompiled go to avoid passing -no_pie, but it then fails in a new way:
$ go build -ldflags -linkmode=external
ld: in /var/folders/iw/iwdRbYdtH1etu4cSq1ucFk+++TI/-Tmp-//go-link-u19OHO/go.o, in
section __TEXT,__text reloc 0: local relocation for address 0x000020CB in section __text
does not target section __rodata
collect2: ld returned 1 exit status
/Users/jobi/go/pkg/tool/darwin_amd64/6l: running gcc failed: unsuccessful exit status
0x100

@ianlancetaylor
Copy link
Contributor

Comment 2:

From some web searches it looks like the -no_pie option was added to the Darwin linker
in Max OS X 10.7.  That explains why you are seeing that error when doing an external
link.
Since your program uses cgo, I don't know why you are getting the external linker by
default.
The error when using the internal linker is issue #8211.
Omitting the -no_pie option was a good idea, but it looks like the 10.6 linker really
insists on seeing PIE, and we don't generate it.

Labels changed: added repo-main, release-none, os-macosx.

@gopherbot
Copy link
Contributor Author

Comment 3 by jobi@litl.com:

If I compile the program on OS X 10.7, do you expect it to run on 10.6?

@rsc
Copy link
Contributor

rsc commented Apr 28, 2015

Per #9511, we will not be making any further bug fixes specific to 10.6.

@rsc rsc closed this as completed Apr 28, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 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

4 participants