-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
affected/package: plugin.Open does not work properly when cross compiled #59654
Comments
Please include this self-contained reproducer in the report, including the commands to run |
This has the sample code to reproduce the problem: |
CGo is necessary. CGo is disabled when cross compiling, you'll need to explicitly enable it, and configure an appropriate C cross compiler toolchain. |
CGo code is not the one getting cross compiled. It is the Go module which is getting cross compiled. CGo is compiled as a plugin on Linux. The Go code using this plugin is the one getting cross compiled which should have worked |
BTW, I have updated my example without any cgo dependency but still get the same error. Please reopen this issue |
using plugins requires cgo, regardless of whether you use it in your code. |
Ok, but is that is the case for the plugin itself, or also the caller of the plugin ? My problem is with the caller of the plugin. If I try to cross compile the plugin, it is not compiling. But why the plugin calling code (which got cross compiled) is failing ? If that also requires cgo, then it should not have cross compiled successfully in the first place ? |
see #19569 |
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?
I wrote a go plugin which needs to call some external C library functions. I compiled this plugin on a linux machine. Then in another go module, I am opening this plugin using plugin.Open and calling one of the functions provided. When I compile this go module (which is calling the plugin.Open) on Linux and run it on another Linux box (where I have put the compiled plugin already at the appropriate location), it works as expected, it is able to call the C function.
But when I cross compile the go module (which is calling plugin.Open) on my Mac for linux and then run this module on the same Linux machine (where the compiled plugin is already present at the correct location), it does not work. The same code, if compiled on Linux, works correctly as explained before. I use the following command to cross-compile on my Mac:
GOOS=linux GOARCH=amd64 go build -mod=vendor -o test ./gomodule
What did you expect to see?
It should have worked similarly whether built on Linux or cross compiled on Mac for Linux. The code is exactly same.
What did you see instead?
I see the following error for the cross compiled module:
plugin: not implemented
The text was updated successfully, but these errors were encountered: