-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
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.