$ GOOS=linux go build -buildmode=plugin plugin.go
# command-line-arguments
warning: unable to find runtime/cgo.a
/Users/urso/.gvm/gos/go1.8beta1/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Linux:
$ GOOS=darwin go build -buildmode=plugin plugin.go
# command-line-arguments
warning: unable to find runtime/cgo.a
/home/urso/.gvm/gos/go1.8beta1/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: -f may not be used without -shared
collect2: error: ld returned 1 exit status
The text was updated successfully, but these errors were encountered:
Cross compiling plugins needs to use external linking, and therefore
you need to have cross compiling toolchain for the target platform
installed.
i.e. for the first case, you need linux toolchain installed on Darwin
and for the 2nd case, you need darwin toolchain install on Linux.
Related issues:
#17620: cmd/go: docs need section on cross-compiling
#16395: cmd/go: provide better error message when cross-compiling toolchain
is required
maybe we can merge this one into #16395?
Better error handling is covered by #16395, any solution to that will work here.
There are two potential feature requests here, the first is internal linking of plugins which don't use cgo when GOOS=linux, the second is the same for GOOS=darwin.
Let's turn this issue into a feature request for GOOS=linux, -buildmode=plugin internal linking. It's not a priority for me, but it's an entirely reasonable feature request.
@urso if you want, you can file a separate bug for GOOS=darwin, -buildmode=plugin internal linking.
crawshaw
changed the title
plugin: cross compiling fails
cmd/link: internal linking for GOOS=linux, -buildmode=plugin
Dec 3, 2016
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?(1.8beta1)
go version devel +41908a5 Thu Dec 1 02:54:21 2016 +0000 darwin/amd64
What operating system and processor architecture are you using (
go env
)?Darwin:
Linux:
What did you do?
Try to cross compile the plugin by setting GOOS=linux (darwin)
What did you expect to see?
plugin being build
What did you see instead?
Darwin:
Linux:
The text was updated successfully, but these errors were encountered: