3 ms·
Does Go support separate compilation? The approach sounds like a change in the implementation of a generic function (changing the gcshapes) could cause client c
by layer8 5y ago
Does Go support separate compilation? The approach sounds like a change in the implementation of a generic function (changing the gcshapes) could cause client code to break unless it is recompiled as well. What am I missing?
- whateveracct 5y agoGo is all from source
- Groxx 5y agoExcept for plugins. But plugins are pretty darn niche, and feel more experimental than anything: https://pkg.go.dev/plugin https://pkg.go.dev/plugin
- LukeShu 5y agoNote that if a plugin and the main program have any packages in common, the build-hash (Go binaries include a hash for each included package) must be identical between the program and the plugin. If the hashes don't match, then the program's `plugin.Open(…)` call will return an error. So if there is a package in common such that an implementation change could cause something like a cgshape change, well the cgshape change won't matter since any implementation change will change the package's build-hash. And so everything will need recompiled anyway, regardless of whether the cgshape changed or not.
- Groxx 5y agoInteresting I hadn't caught that requirement before. It both kinda makes sense and kinda doesn't... and sadly throws some cold water on a few "it'd be fun to try to do X" ideas I've had floating around in my head. I suppose there's always RPC-like options.
- EE84M3i 5y agoDoes this even include the standard library?
- LukeShu 5y agoYes, it does include the standard library.
- Laremere 5y agoWhile (iirc) Go uses caching in its build system internally, it builds quickly enough that this is not a concern.
- ainar-g 5y agoThere are "shared" and "c-shared" build modes[1], if that's what you mean. The latter is fairly obvious. The former is so rarely used that there was a proposal to remove it, but it turned out that some people did actually use it, but almost exclusively because of license terms. [1]: https://pkg.go.dev/cmd/go#hdr-Build_modes https://pkg.go.dev/cmd/go#hdr-Build_modes
- bboozzoo 5y agoYocto/OE used to build Go in this shared mode just to conserve space that would otherwise be wasted by each Go program shipping its own copy of the standard library. It did shave off some MBs, so hard to say it wasn't useful especially if a bunch of +20MB binary blobs are a concern.
- uluyol 5y agoThis is also true in C++ templates, and C macros for that matter.
- 4ad 5y agoYou say "separate compilation", but what you are really asking is whether Go supports forward-compatible shared libraries. Go does separate compilation, it's an extremely important property for Go. Go code can be built as a shared library, loadable by both C or Go code, albeit this is an unusual use case for Go. However, when multiple Go shared objects are to be linked together, they must share the same Go version, including the toolchain version, so there is no forward compatibility.