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

cmd/go: error when building plugin with GOOS=linux under macos (cross compiling) #22452

Closed
xupeilin opened this issue Oct 26, 2017 · 7 comments
Closed
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@xupeilin
Copy link

Build cannot be executed. Get error

xupeilin@~/go/src/dso$ GOOS=linux go build -buildmode=plugin go.go 
can't load package: package main: build constraints exclude all Go files in /Users/xupeilin/go/src/

This program is a test plugin demo and can be compiled successfully under Ubuntu.

Go Version: 1.9.2

go env

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/xupeilin/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_t/pkms_qx931x8_94gnhkx2kfm0000gn/T/go-build934344293=/tmp/go-build -gno-record-gcc-switches -fno-common"
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"
@ALTree ALTree changed the title Get error when building plugin with GOOS=linux under macos(cross compiling) cmd/go: error when building plugin with GOOS=linux under macos (cross compiling) Oct 26, 2017
@ALTree
Copy link
Member

ALTree commented Oct 26, 2017

This program is a test plugin demo and can be compiled successfully under Ubuntu.

Please include this self-contained reproducer in the report.

@xupeilin
Copy link
Author

@ALTree
I notice that plugins is only available on Linux in go1.8 release note(https://golang.org/doc/go1.8#plugin).

This means GOOS only support linux?

In my environment, GOOS=linux, but GOHOSTOS=darwin. Does plugins support cross compiling like this?

@davecheney
Copy link
Contributor

@xupeilin it’ll be easier to explain once you provide a runnable code sample that others can try to reproduce the issue you are seeing.

@davecheney davecheney added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 26, 2017
@xupeilin
Copy link
Author

xupeilin commented Oct 26, 2017

source file: test.go

package main

import "C"

type Msger struct{}

func (Msger) Msg() string {
        return "hello, world"
}

I want to compile to test.so.

@cherrymui
Copy link
Member

cgo is by default disabled in cross-compiling. You need to set CGO_ENABLED=1 explicitly.

Also I think you need a cross C compiler targeting Linux (which you probably already have), and set CC to its path.

@xupeilin
Copy link
Author

You need to set CGO_ENABLED=1 explicitly.

This is the reason, and now compiling can start. As @cherrymui said, I still need a cross C compiler to finish compiling...but I don't have.

Thanks guys @ALTree @davecheney @cherrymui .

@gopherbot
Copy link

Change https://golang.org/cl/73870 mentions this issue: font/sfnt: implement font.Face interface

@golang golang locked and limited conversation to collaborators Oct 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants