By the way, this existed at one point. Early versions of the Go toolchain included C compilers (6c, 8c, etc.) designed to work together nicely with Go code. If I remember right, most of the Go runtime was written in C, and compiled with these compilers. But they used an unusual dialect of C (which came from Plan 9) instead of ANSI C, so they couldn't compile most C libraries.

When the Go runtime was translated from C to Go, these compilers were dropped.

If you wanted to revive them and make them ANSI compliant, you would need to write a new libc that calls into the Go standard library for its system calls—because C code compiled with this compiler would not be able to call into the system libc without CGo!

Andy

On 3/13/21 10:57 PM, Jason E. Aten wrote:
I was noodling about how to minimize the cost of crossing the CGO barrier from Go code into C code and back.

Then I thought, what if I look at this the other way around.

Instead of teaching the Go compiler how to better run C code, what if a C compiler (e.g. clang) was taught to generate code that used the Go stack and calling conventions.

Theoretically, the cc output "in Go convention" could be linked with Go code without paying the CGO penalty, no?

How crazy is this? :)
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com <mailto:golang-nuts+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/028ecd62-5f9f-4cb6-95df-a0b48ff3d825n%40googlegroups.com <https://groups.google.com/d/msgid/golang-nuts/028ecd62-5f9f-4cb6-95df-a0b48ff3d825n%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/bf013837-7b1c-6cb3-801f-03776ec5cdd4%40gmail.com.

Reply via email to