Contributing to buildmode=shared on Windows: any hints?

504 views
Skip to first unread message

Mateusz Czapliński

unread,
Apr 23, 2018, 7:29:58 AM4/23/18
to golang-dev
Could anyone give some hints as to how one could potentially start contributing towards making -buildmode=shared work on Windows?

Per his comment in https://golang.org/issue/19282, Alex Brainman is currently unable to help, as he's unfortunately overloaded with other work, so if anyone else could help even in a slightest way, any hints are greatly appreciated!

Notably, given that -buildmode=c-shared is already implemented on Windows, what is the general idea of the extra work needed to make =shared work? I imagine this question could be answered in a platform-agnostic way to some extent (at least on a high level)? At this moment, I wouldn't even know where to start...

Also, is anybody aware of any blockers, or candidates? some serious architectural or OS-level challenges?

To give some background, my interest was piqued by the recent news of a Go kernel for Jupyter notebooks (https://medium.com/@yunabe/interactive-go-programming-with-jupyter-93fbf089aff1), which uses buildmode=shared internally, and as such is not supported natively on Windows.

Thanks for any hints,
/Mateusz.

Ian Lance Taylor

unread,
Apr 24, 2018, 12:45:58 AM4/24/18
to Mateusz Czapliński, golang-dev
On Mon, Apr 23, 2018 at 4:29 AM, Mateusz Czapliński <czap...@gmail.com> wrote:
>
> Could anyone give some hints as to how one could potentially start
> contributing towards making -buildmode=shared work on Windows?
>
> Per his comment in https://golang.org/issue/19282, Alex Brainman is
> currently unable to help, as he's unfortunately overloaded with other work,
> so if anyone else could help even in a slightest way, any hints are greatly
> appreciated!
>
> Notably, given that -buildmode=c-shared is already implemented on Windows,
> what is the general idea of the extra work needed to make =shared work? I
> imagine this question could be answered in a platform-agnostic way to some
> extent (at least on a high level)? At this moment, I wouldn't even know
> where to start...
>
> Also, is anybody aware of any blockers, or candidates? some serious
> architectural or OS-level challenges?

I don't know the answer. But if -buildmode=c-shared works, then I
don't know of any fundamental obstacles to -buildmode=shared. I think
someone familiar with the details of precisely how DLLs work on
Windows should just try implementing it and see what happens.

Ian

Anca Emanuel

unread,
Apr 24, 2018, 6:34:51 PM4/24/18
to golang-dev
If you want to work on this I think you want to read https://msdn.microsoft.com/en-us/library/ms235636.aspx
For an introduction.
But for hacking ? Disassemble the viruses.
I think that is important  to talk to http://www.pouet.net authors.
They have the expertize.
I think some of them will help.

Mateusz Czapliński

unread,
Apr 25, 2018, 5:11:36 AM4/25/18
to golang-dev
Ok, thanks! I'm gonna try and see where it takes me, with the limited time I have.

Some "trivial" dev questions:
- can I expect this to work if I build with CGO_ENABLED=0, or do I have to install mingw?
- can you suggest some easier (faster) way to iterate the development than running make.bat after every change? Will it work if I just go to src/cmd/go and run go build?
- I see there's misc/cgo/testshared; what do I have to do to run it with "my" in-development go binary & ecosystem?

TIA
/Mateusz.

Ian Lance Taylor

unread,
Apr 25, 2018, 9:36:46 AM4/25/18
to Mateusz Czapliński, golang-dev
On Wed, Apr 25, 2018 at 2:11 AM, Mateusz Czapliński <czap...@gmail.com> wrote:
> Ok, thanks! I'm gonna try and see where it takes me, with the limited time I
> have.
>
> Some "trivial" dev questions:
> - can I expect this to work if I build with CGO_ENABLED=0, or do I have to
> install mingw?

At least on GNU/Linux, the Go linker invokes the external linker to
create a shared library. I would expect the same thing to happen on
Windows, so CGO_ENABLED=0 would not be supported.

> - can you suggest some easier (faster) way to iterate the development than
> running make.bat after every change? Will it work if I just go to src/cmd/go
> and run go build?

Once you have a complete installation, you can update the go tool at
any time by running `go install cmd/go`. Similarly with `go install
cmd/link`.

> - I see there's misc/cgo/testshared; what do I have to do to run it with
> "my" in-development go binary & ecosystem?

Change to that directory and run `go test`.

Ian

Mateusz Czapliński

unread,
Apr 25, 2018, 3:17:59 PM4/25/18
to golang-dev
Hmm; I've found https://golang.org/issue/23126 (support buildmode=shared on darwin) and through it a WIP CL https://golang.org/cl/57750. It looks like it'd be best for me to work on those changes, as they seem to improve cross-platform-ness of related code. Not sure however to what extent this CL is a working PoC, or just some intermediate work. Also it starts to look like I'm most probably not going to have enough time to work on this, unfortunately :(
Reply all
Reply to author
Forward
0 new messages