From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 2 Feb 2013 07:24:19 -0800 From: Anthony Martin To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20130202152419.GA30387@dinah> References: <631828b4eaee51d49ac685c47b6b3554@proxima.alt.za> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] Go: CGO and Plan 9 Topicbox-Message-UUID: 13f411b0-ead8-11e9-9d60-3106f5b1d025 Aram H=C4=83v=C4=83rneanu once said: > ?c and ?g use the same calling convention, and segmented stacks are > implemented by the linker. You don't need cgo in order to call C code > from Go. Why do you want cgo? This isn't true. Most of the Plan 9 compilers will pass the first function argument in a register (not including 8c) and return the result in a register (including 8c). The C compilers in the Go toolchain pass everything on the stack and return the result in a register. The Go compilers pass everything on the stack including the output parameters. No registers are involved in the calling convention. Another difference is in C is variadic functions in the face of segmented stacks. The C compilers in the Go toolchain will not compile a variadic function without a NOSPLIT annotation. And even then, only if the resulting stack frame is small. > Look at the various C files in the Go standard library, especially > inside runtime. Those are compiled with the Plan 9 compiler and Go > calls it just fine. They're also careful not to validate the above assumptions and they do not include any outside header files. The right way to solve this problem is to modify cgo. I just haven't had the time. Cheers, Anthony