Navigation Menu

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

plugin: catch an error when cross compile with plugin in macOS #25327

Closed
PeerXu opened this issue May 10, 2018 · 3 comments
Closed

plugin: catch an error when cross compile with plugin in macOS #25327

PeerXu opened this issue May 10, 2018 · 3 comments

Comments

@PeerXu
Copy link

PeerXu commented May 10, 2018

What version of Go are you using (go version)?

go version go1.10.1 darwin/amd64

Does this issue reproduce with the latest release?

Not test with the latest release.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/peer/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/peer/.golang"
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/m1/2yvmbf5d64q7rh73rsqcph2c0000gn/T/go-build467835613=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I write a demo to reproducing the error.

I try to cross compile a plugin in macOS to ARM platform(RPi Zero W), but got an error.

$ git clone https://github.com/PeerXu/error-golang-cross-compile-with-plugin.git
$ cd error-golang-cross-compile-with-plugin
$ make
GOOS=linux GOARCH=arm GOARM=5 go build -o plugin.so -buildmode=plugin plugin/plugin.go
# command-line-arguments
loadinternal: cannot find runtime/cgo
/usr/local/opt/go/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
clang: error: invalid linker name in argument '-fuse-ld=gold'

make: *** [all] Error 2

What did you expect to see?

Compile pass without any error.

What did you see instead?

# command-line-arguments
loadinternal: cannot find runtime/cgo
/usr/local/opt/go/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
clang: error: invalid linker name in argument '-fuse-ld=gold'

make: *** [all] Error 2
@AlexRouSg
Copy link
Contributor

dupe of #18157

You need to install a C cross-compiler and then set the following environmental variables:

CGO_ENABLED=1
CC=replace-this-with-the-arm-cross-compiler

If you require further help please ask around in one of the places listed in https://github.com/golang/go/wiki/Questions as the bug tracker is only for bug reports.

@PeerXu
Copy link
Author

PeerXu commented May 10, 2018

Thank @AlexRouSg .
Should I close this issue?

@AlexRouSg
Copy link
Contributor

Yes

@PeerXu PeerXu closed this as completed May 10, 2018
@golang golang locked and limited conversation to collaborators May 10, 2019
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