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

go/build: allow @ in #cgo lines for OS X special paths #13720

Closed
andlabs opened this issue Dec 23, 2015 · 1 comment
Closed

go/build: allow @ in #cgo lines for OS X special paths #13720

andlabs opened this issue Dec 23, 2015 · 1 comment

Comments

@andlabs
Copy link
Contributor

andlabs commented Dec 23, 2015

At present, safeCgoName in src/go/build/build.go does not allow @ in a #cgo line, preventing the use of @ on any platform. Simple nonworking test:

package main
// #cgo LDFLAGS: @fail
import "C"

results in

can't load package: /tmp/x.go: malformed #cgo argument: @fail

Why is @ needed? OS X does not use $ORIGIN in its rpath for indicating that binaries should look in the binary's directory for their shared libraries; instead, it uses the special name @executable_path. There are a number of these special names provided by Apple's loader (and more in other links I can't find right now).

I don't know what the consequences of adding @ to the list of safe cgo runes would be, or why @ was omitted, so I am submitting a bug instead of a patch.

After this fix, Go packages that use -rpath @executable_path in its #cgo LDFLAGS line should be able to build. Furthemore, TestCgoHandlesWlORIGIN in src/cmd/go/go_test.go could also be adjusted to work on OS X as well.

I am running

go version devel +49065cb Fri Sep 18 18:09:15 2015 +0000 linux/amd64

but manually confirmed the issue will still happen on master. Here is an issue where someone else runs into it in my code using stable go1.5.2.

@gopherbot
Copy link

CL https://golang.org/cl/18331 mentions this issue.

@rsc rsc closed this as completed in dba926d Jan 7, 2016
@golang golang locked and limited conversation to collaborators Jan 7, 2017
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

3 participants