-
Notifications
You must be signed in to change notification settings - Fork 18k
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: "built with a different version of package" error with go 1.18 & CGO #51955
Comments
I'm a little confused. When you build the plugin, you use |
The general
Am pretty confident this is working, as we don't see any issue with Go 1.17.8 or older - this problem only occurs with Go 1.18... and the error occurs only for a particular package that uses cgo. Other plugins that don't use our I can pull out the strings section for Go 1.17.8 (which works) tomorrow, with exactly the same build flags / GOFLAGS to clarify a bit further. |
I moved The main binary now builds with:
The plugin now builds with:
As before, everything works in Go 1.17.8 (or prior), but not with Go 1.18... With Go 1.17.8 plugin.Open succeeds The main binary and plugin build correctly, plugin.Open succeeds, and the plugin can be used. Strings for
Strings for
These are identical between main binary and plugin, so there is no pkghash mismatch / failure with plugin.Open Note that there is no path information in either. There are references to There is also no reference to With Go 1.18 plugin.Open fails
Strings for
Strings for
The strings for I can build other plugins that don't use |
By looking into When building with a
... it's apparent that AbsFile doesn't receive the rewrite that will remove the
If I drop the
|
So, similar to #47256 , use the high level |
Our main binary compilation uses the I'll look into whether we can do this more sanely, but at the time it was the implementation that a developer came up with to allow people to build plugins via our own CLI. I guess I'm interested in pursuing this a bit more, as it used to work up to and including 1.17 - and presumably the gcflag trimpath could just be appended to the rewrites that AbsFile sees, rather than replace them... which would maintain the 1.17 behavior? Edit - understood that there may not be any appetite for pursuing this further, though, so I'll put most of my efforts on us coming up with something a bit more straightforward to avoid the issue :-) Edit 2 - there may more to it, w.r.t. the reason for asmflags and gcflags... we're using CGO in our main binary and plugins, and I noticed mention of #27751, #36072 in the linked #47256 - I'll stop speculating and look into it properly. |
Having come across a definitive message, while browsing through issues, that...
... we'll drop back to a more restrictive approach for building plugins in our app, that doesn't require that. Apologies for the noise! |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
We have a plugin (https://github.com/sylabs/singularity/blob/master/e2e/plugin/testdata/runtime_singularity/callback.go) that indirectly imports a package containing some CGO code (https://github.com/sylabs/singularity/tree/master/internal/pkg/util/user).
I have tried to extract a simpler reproducer, but haven't managed to hit the same issue yet... so what follows is, unfortunately, a terse description of a rather complicated build...
Our main binary is compiled with the following
go build
andGOFLAGS
contains-trimpath
The plugin is built by copying the source into a temporary directory, and then using the following
go build
:What did you expect to see?
With Go 1.17.8 or prior, the compiled plugin can be loaded by the main binary without issue.
What did you see instead?
With Go 1.18, the plugin is compiled without issue, but when the main binary attempts to load it, it fails with an error:
Examining the pkghashbytes for the "github.com/sylabs/singularity/pkg/image" package, I can see a difference between the main binary and plugin:
I can see that there is a difference in the strings section exposed in
cmd/compile/internal/typecheck/iexport.go
:Grabbing these and converting to text we have:
strings section in the main binary build…
strings section in the plugin build…
The difference here being an extra
,/tmp/go-build2510098997/b050/
prior to_cgo_gotypes.gouser
in the build of the main binary.I'm not sure what might have changed from 1.17.x -> 1.18 to cause this?
A quick
strings $(which singularity)
(main binary) for different 1.18 and 1.17.8 builds shows at least some kind of difference without the context:Go 1.18
Go 1.17.8
Any pointers on where to go here would be appreciated!
The text was updated successfully, but these errors were encountered: