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: using stdlib package plugin from within non-main package doesn't work as expected #18120

Open
typetetris opened this issue Nov 30, 2016 · 3 comments
Milestone

Comments

@typetetris
Copy link

@typetetris typetetris commented Nov 30, 2016

Please answer these questions before submitting your issue. Thanks!

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

go version devel +5d1b53a Wed Nov 30 19:46:00 2016 +0000 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/erwo/golang-plugin"
GORACE=""
GOROOT="/home/erwo/go-devel"
GOTOOLDIR="/home/erwo/go-devel/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build569578387=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

Wrote a non-main package using stdlib package plugin to open a plugin.

https://github.com/erwo42/golang-plugin

Just run from within the workdir of a clone of above repo:

go install indirect
go build -buildmode=plugin testplugin
bin/indirect

What did you expect to see?

Yay!

What did you see instead?

2016/11/30 22:00:03 plugin.Open: plugin was built with a different version of package runtime

Other maybe relevant issues

#17928
#17150

@typetetris typetetris changed the title using stdlib package plugin from within non-main package doesn't work as expected plugin: using stdlib package plugin from within non-main package doesn't work as expected Dec 1, 2016
@crawshaw

This comment has been minimized.

Copy link
Contributor

@crawshaw crawshaw commented Dec 1, 2016

What do you see if you build the binary "indirect" with -gcflags=-dynlink?

@typetetris

This comment has been minimized.

Copy link
Author

@typetetris typetetris commented Dec 1, 2016

It is still the same message.

erwo@vm-debian:~/golang-plugin$ export GOPATH=$(pwd)
erwo@vm-debian:~/golang-plugin$ go version
go version devel +16c3399 Thu Dec 1 07:17:51 2016 +0000 linux/amd64
erwo@vm-debian:~/golang-plugin$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/erwo/golang-plugin"
GORACE=""
GOROOT="/home/erwo/go-devel"
GOTOOLDIR="/home/erwo/go-devel/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build228390996=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
erwo@vm-debian:~/golang-plugin$ go install -gcflags=-dynlink indirect
erwo@vm-debian:~/golang-plugin$ go build -buildmode=plugin testplugin
erwo@vm-debian:~/golang-plugin$ bin/indirect
2016/12/01 18:37:04 plugin.Open: plugin was built with a different version of package runtime
erwo@vm-debian:~/golang-plugin$
@rsc rsc added this to the Go1.9Early milestone Jan 4, 2017
@bradfitz bradfitz modified the milestones: Go1.10, Go1.9Early May 3, 2017
@bradfitz bradfitz modified the milestones: Go1.10, Go1.11 Dec 13, 2017
@cherrymui

This comment has been minimized.

Copy link
Contributor

@cherrymui cherrymui commented Apr 24, 2018

Does it work with tip now? It works fine for me on both linux/amd64 and darwin/amd64.

$ git clone https://github.com/typetetris/golang-plugin.git
Cloning into 'golang-plugin'...
remote: Counting objects: 19, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 19 (delta 3), reused 19 (delta 3), pack-reused 0
Unpacking objects: 100% (19/19), done.
$ cd golang-plugin
$ GOPATH=$PWD go install indirect
$ GOPATH=$PWD go build -buildmode=plugin testplugin
$ bin/indirect 
Yay!

@gopherbot gopherbot modified the milestones: Go1.11, Unplanned May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.