Re: go -buildmode=shared for packages
Hi Jérémy, thanks for the reply!
On Wed Jul 23, 2025 at 2:27 PM CEST, Jérémy Lal wrote:
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.
I wouldn't say this is a no. To expand on the part which you didn't
quote, they are saying that there's no interest in supporting long-term
stable ABIs, as I have mentioned in my original reply. Shared library
linking is supported, just not as well as in classic C libraries.
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.
Yes, that's my point. Right now, all packages depending on a given
library need to be rebuilt when the library is updated. With this other
model, all Go packages would need to be rebuilt when the compiler
changes, but it would be possible to make small security fixes without
recompiling. Is this a trade-off which would make sense to make?
Oh and also: don't we already recompile the world with new Go releases?
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 ?
Regular golang-go does not support all the architectures either, so
I guess we could modify golang-any to depend on gccgo-go where shared
linking isn't supported.
Bye :)
Reply to: