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

Binary distribution of a package using plugins #34261

Closed
Julio-Guerra opened this issue Sep 12, 2019 · 2 comments
Closed

Binary distribution of a package using plugins #34261

Julio-Guerra opened this issue Sep 12, 2019 · 2 comments

Comments

@Julio-Guerra
Copy link

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

$ go version
go version go1.12 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/julio/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/julio/go"
GOPROXY=""
GORACE=""
GOROOT="/home/julio/sdk/go1.12"
GOTMPDIR=""
GOTOOLDIR="/home/julio/sdk/go1.12/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build607805819=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I would like to distribute some cgo bindings to a C++ library as a pre-compiled binary package in order to avoid asking users of this package to enable cgo and install gcc.
So I ended up on #28152 which says to use the Go plugins to do so. But now that I have my plugin wrapping the cgo bindings, I discover through my failing tests and in #28983 (comment) that "you have to build the plugin with the same dependencies as the binary".

I am unsure of what is exactly checked, but in this given use-case, the plugin cannot be built with the same packages as the binary that will load it. This binary is unknown in my case and I wanted to use the plugins as a way to load my package with cgo into any Go binary.

So this is very unexpected given the "plugin" name, and I am back to my starting point, for now giving up with plugins and rather document what it takes to use cgo because of my package.

Note that I also tried to find a way to simply use -buildmode archive and simply pass the compiled archive to go build or install without success.

@ianlancetaylor
Copy link
Contributor

I think that everything you say in true. You can only use a plugin with the exact same Go release. Yes, this is a serious limitation on plugins, but there are no current plans to expand them. Sorry.

I'm going to close this issue because I don't really see any action we can take. Please comment if you disagree. You may also want to discuss this on a forum; see https://golang.org/wiki/Questions.

@Julio-Guerra Julio-Guerra changed the title Binary distribution of a package cgo using plugins Binary distribution of a package using plugins Sep 13, 2019
@Julio-Guerra
Copy link
Author

Julio-Guerra commented Sep 13, 2019

You can only use a plugin with the exact same Go release.

@iamoryanmoshe It's even stronger than this: the compiled dependencies needs to be the same, and this seems to be enforced by checking the import paths in the importcfg.

(PS: no one answered me on golang-nuts ;-))

@golang golang locked and limited conversation to collaborators Sep 15, 2020
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