https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67976
Bug ID: 67976 Summary: Cgo + Gccgo not working like Cgo + Golang? Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: go Assignee: ian at airs dot com Reporter: vogt at linux dot vnet.ibm.com CC: cmang at google dot com Target Milestone: --- The authors of the Ethereum project seem to assume that cgo can handle the code below in a sensible way, but when using the -gccgo option that is not the case. -- snip -- package foo /* int foo_cgo(unsigned); */ import "C" import "unsafe" //export foo func foo(x C.unsigned) C.int { return 0 } func () bar() { _ = unsafe.Pointer(C.foo_cgo) } -- snip -- Running this through $ mkdir _obj $ cgo -objdir _obj -gccgo foo.go Results in this code in _cgo_main.c: extern char foo_cgo[]; void *_cgohack_foo_cgo = foo_cgo; #include "_cgo_export.h" And this line in _cgo_export.h: int foo_cgo(unsigned); Redeclaring foo_cgo results in an error message when trying to compile _cgo_main.c. Maybe _cgo_export.h should simply be emitted to _cgo_main.c *before* all the declarations?