-
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
plugin: add Windows support #19282
Comments
There is currently nobody working on it, as far as I know. |
mean in |
@QuestionPython, yes, it's even documented in multiple places: https://golang.org/pkg/plugin/
https://golang.org/doc/go1.8#plugin
|
I am not working on it. Sorry. Alex |
We delete all "me too" voting comments per https://golang.org/wiki/NoMeToo. Vote with emoji reactions at top instead. |
The "me too" comments wouldn't stop, so this issue is now locked. If there are updates, they will be made here. |
Out of curiosity, do we know how much effort it would take to implement windows support? Or if there are any blockers to it (and what they are?) |
Notably, the recently published Go kernel for Jupyter notebooks is using buildmode=shared, and thus doesn't currently support Windows natively. This is a very cool use case, adding a REPL-like live coding feature to the Go ecosystem, thus it would be really awesome if someone tried to start work on buildmode=shared on Windows to support this use case. Similar to @0xdevalias , I'm quite interested in some hints as to what is missing for this to work on Windows? I'm especially curious what extra work is needed given that c-shared is already implemented on Windows? |
@0xdevalias and @akavel I don't have any effort estimation or any hints as to what missing here. I have not actually looked at what is involved. I am so much behind at fixing old issues ... Alex |
@alexbrainman Thanks! I'll ask on golang-dev then, maybe someone else can shed some light (edit: link to the thread) |
There doesn't seem to be a huge amount to it in the src: https://github.com/golang/go/tree/master/src/plugin My completely naive guess would be figuring the windows equivalents to the C-bindings in The main functions I can see there are:
Googling for "dlopen equivalent windows" led me to the following:
And "dlsym equivalent windows":
So from that, it sounds like we have the following premise to work from:
The main definitions in FlexDLL don't look too complex.. but there is quite a bit of extra code around those that may be required too: Hopefully this helps scope out what will be required/start pointing in the right direction :) |
All the posts seem to be concerned with the loading of symbols, but does the compiler support producing a plugin (presumably DLL) on Windows? |
It is possible to build Windows DLL from your Go code. You want -buildmode=c-shared 'go build' flag for that. See #26714 for an example. 'go build' command uses gcc under covers to build DLL. Alex |
I've been hacking on this issue for a while and it seems to be going well for now. I've managed to load a dll built with -buildmode=c-shared and call its init function. The only limitation of this is that the plugin needs to have a main function or it won't compile. I'm developing on Linux using GCC and Wine. Just a few questions if anyone could clarify: What exactly is going on in this function? The dlopen implementation calls this function and apparently returns the symbols; it doesn't work with Windows's shared objects. Secondly, I couldn't find any consistent guidelines for using wide strings with CGO so I ended up depending on unicode/utf16 and unicode/utf8. However, Edit: I guess this isn't so straightforward as I thought. -buildmode=plugin adds some metadata that is needed to find the exported symbols. Reading the PE data (using pev's |
ref: golang/go#19282 Signed-off-by: Avelino <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
Hey guys, I have tried to implement plugin for windows. Unfortunately the dynlink in the ASM for windows does not work. R15 can not be used as dynlink because this is a global variable. Since I am not familiar with ASM it is hard to implement. Or can someone help?
|
@zandercodes I'm not familiar with ASM either, but I would also like to implement plugins for windows. Is there a branch or fork that I can review to see what you've done so far? |
This comment was marked as spam.
This comment was marked as spam.
https://github.com/Linkangyis/GoLangLinkDLL |
The current Plugin model has the following disadvantages
I think to do this, the following ideas can be considered.
If you can follow the above method to achieve. Then go will have its own plug-in system. Instead of relying on c or windows dll or something. |
People might be interested in my (still janky) fork of pkujhd's goloader (tested on It doesn't depend on libdl doing the legwork of symbol deduplication - it directly reads Go archive files and loads code and applies relocations. It doesn't necessarily require |
I'm currently working on an embedded project that requires strong versatility. It has the potential to run on Linux or Windows. The fact that the plugin package only works on Linux is causing me a lot of headaches. |
@lvyonghuan I think the best path forward here at the moment is to leverage compilation to wasm via either tinygo or go with wasip1, and then load the the wasm 'plugin' in with something like https://github.com/tetratelabs/wazero. You can get pretty far with this approach, it checks a lot of boxes for dynamically loading and executing code. |
Yah, it's not as clean as the go plugin interface, but https://extism.org/ is a great plugin option at this point. |
I don't have much knowledge about WebAssembly. Does it typically require a browser environment to function properly? In our environment, there may not be a browser. |
You probably want to look out something like WASM runtime -> https://github.com/appcypher/awesome-wasm-runtimes. |
给你提供一个思路 go->c->go 能跑起来,c做桥,但是在windows下,dll和主程序是几乎完全不同的内存空间,撑死加载一下func,引入相同的包实际内存地址也是完全不一样的 |
https://github.com/Linkangyis/GoLangLinkDLL 你可以尝试参考这个实现 |
This comment was marked as duplicate.
This comment was marked as duplicate.
I'm pessimistic. I feel like people have forgotten that the plugin package exists - it's too rudimentary and has limited support. But I feel that if the plugin package can be done well, what it can achieve is still very powerful. To some extent, go lacks a multi-terminal hot reloading mechanism. The plugin package makes up for this. The problem is that it is only applicable to Linux and has many shortcomings. Maybe the plugin feature is just an experimental product. When I was thinking about a new project today, I wanted to implement some kind of hot reloading and other features. I found that go is really suitable, but the biggest flaw is that the plugin package is terrible. It's quite sigh-worthy. Last year, I published my needs under this problem. This year, the bottom is still my needs and other people's solutions. It just stopped there. By the way, isn't it because win is owned by Microsoft? |
hi
Plugin Pkg Work for Windows!?
i want use this for mac,linux,win,... os.
when(what time) fix this?
https://golang.org/pkg/plugin/
The text was updated successfully, but these errors were encountered: