169 points · by ConceitedCode · 12y ago · 21 comments
Of course the Go team is aware of this, but once you support dynamic linking, ABIs become very hard to change. A bad one will weigh you down for a long time! Apple famously used PC-relative addressing on PowerPC, which has no program counter register. It was, let's say, measurably suboptimal, but they were stuck with it until the Intel transition (or technically the PPC64 one).
Both D and Go use an unusual convention. The GCC maintainers raised issues over D's ABI during discussions regarding integrating the GCC-based D compiler. I wonder how did this apply to Go's inclusion? Or did GCC support the Plan9 ABI before Go's inclusion?
* Go can't dynamically link to C libraries (.so). It can, however, dynamically link to DLLs, which is interesting.
* C can't dynamically link things built with Go
If I were to guess, they're trying to tackle the first problem.
Please see my comment here: https://news.ycombinator.com/item?id=7679041
In short, The Go linker can link with ELF shared objects just fine, just as it can link with PE-COFF shared objects, but it supports only the most basic of relocations in both cases (and this is a property of the design, as we can't expect the presence of the shared object because that would break cross-compilation), and it's not what you probably want anyway.
Although, the most recent discussion I can find seems to suggest disagreement on how to approach this for a final solution, so not likely to see anything soon: https://groups.google.com/d/topic/golang-dev/Lp59oYc4Ta8/dis...
The Go calling convention is described correctly, but the runtime is largely C (compiled by a modified Plan 9 C compiler), and C compilers return values in a register, not on the stack.
The Plan 9 ABI is significantly different. Yes, the compilers come from Plan 9 (Inferno, actually), but the calling convention was modified. E.g. on Plan 9 first argument is usually passed in register.