[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: go -buildmode=shared for packages





Le mer. 23 juil. 2025 à 13:50, Andrea Pappacoda <tachi@debian.org> a écrit :
Hi!

First message here on the list :)

Yesterday I came across go's -buildmode=shared and -linkshared options.
As far as I know, there hasn't been any discussion about them here.

In case you don't know what they do (just like myself a few days ago),
they can be used to achieve dynamic linking in Go programs. Unlike other
languages like C, though, binary compatibility is not guaranteed across
compiler releases. -buildmode=shared can be used while building to
generate a shared object, while -linkshared tells the toolchain to use
such shared objects for linking. More information can be found running
`go help buildmode` and at <https://go.dev/s/execmodes>.

Why aren't we using them in Debian? Did we already have this discussion,
and I have simply missed it?

It's a known fact that go doesn't support shared libraries.

To quote the document about execmodes:

C shared libraries ../.. There is no intention to support any of these techniques for Go. 
Updating the Go runtime to a new version requires rebuilding all Go programs that use it.

So this is a hard *no* from upstream golang/go.
 
This mode is mainly intended to support distro builders. 
They can distribute Go packages or groups of packages as shared libraries, and can thus update all Go programs by updating the shared libraries, without requiring the programs to be relinked.

If the Go runtime doesn't change (meaning all packages need to be rebuilt when it does),
in theory it might be possible.
 
In the Go 1.5 release this is implemented for the linux-amd64 target only.  In the Go 1.6 release it is additionally implemented for linux-386, linux-arm, linux-arm64, and linux-ppc64le.  When using gccgo it is implemented for any supported target.

Another issue: to support all architectures, that mode needs to be compiled by gccgo.
I don't know how well that is supported by all golang packages ?

Jérémy


Reply to: