C uses the cdecl, which I've looked into and called with from assembly. It feels well enough, so why break the compatibility? Why was another convention needed?
In Linux, GCC sets the de facto standard for calling conventions. Since GCC version 4.5, the stack must be aligned to a 16-byte boundary when calling a function (previous versions only required a 4-byte alignment). A version of cdecl is described in System V ABI for i386 systems.
Calling conventions specify how arguments are passed to a function, how return values are passed back out of a function, how the function is called, and how the function manages the stack and its stack frame. In short, the calling convention specifies how a function call in C or C++ is converted into assembly language.
Because there's no advantage in having the same calling convention. Go code and C code cannot call each other directly even when the calling convention would be the same because Go uses split stacks.
OTOH, it makes sense in gccgo, as gcc supports C split stacks for some architectures. And, IIRC, there the calling convention is because of that compatible. (More details here.)
Disclaimer: I didn't ever actually used gccgo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With