public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug go/67976] New: Cgo + Gccgo not working like Cgo + Golang? @ 2015-10-15 14:03 vogt at linux dot vnet.ibm.com 2015-10-23 17:15 ` [Bug go/67976] " vogt at linux dot vnet.ibm.com ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: vogt at linux dot vnet.ibm.com @ 2015-10-15 14:03 UTC (permalink / raw) To: gcc-bugs 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? ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug go/67976] Cgo + Gccgo not working like Cgo + Golang? 2015-10-15 14:03 [Bug go/67976] New: Cgo + Gccgo not working like Cgo + Golang? vogt at linux dot vnet.ibm.com @ 2015-10-23 17:15 ` vogt at linux dot vnet.ibm.com 2015-10-23 17:49 ` ian at airs dot com ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: vogt at linux dot vnet.ibm.com @ 2015-10-23 17:15 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67976 --- Comment #1 from Dominik Vogt <vogt at linux dot vnet.ibm.com> --- When cgo encounters the "C.foo_cgo", it determines that it must be a variable, but finds no C definition, so it generates "extern char foo_cgo[]" (out.go) as the type. This conflicts with the declaration in the comment at the beginning of the file. Replacing /* int foo_cgo(unsigned); */ with /* extern char foo_cgo[]; */ Makes this code compile for me. Is this kind of declaration supported by the cgo version from the golang repository? (If not, what would the symbol C.foo_cgo be good for). ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug go/67976] Cgo + Gccgo not working like Cgo + Golang? 2015-10-15 14:03 [Bug go/67976] New: Cgo + Gccgo not working like Cgo + Golang? vogt at linux dot vnet.ibm.com 2015-10-23 17:15 ` [Bug go/67976] " vogt at linux dot vnet.ibm.com @ 2015-10-23 17:49 ` ian at airs dot com 2015-10-27 10:52 ` vogt at linux dot vnet.ibm.com 2015-10-27 13:01 ` vogt at linux dot vnet.ibm.com 3 siblings, 0 replies; 5+ messages in thread From: ian at airs dot com @ 2015-10-23 17:49 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67976 --- Comment #2 from Ian Lance Taylor <ian at airs dot com> --- This is probably https://golang.org/issue/8945 , which is fixed in the gc repository but not in the gccgo repository. That fix should come in when I merge in the Go 1.5 sources. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug go/67976] Cgo + Gccgo not working like Cgo + Golang? 2015-10-15 14:03 [Bug go/67976] New: Cgo + Gccgo not working like Cgo + Golang? vogt at linux dot vnet.ibm.com 2015-10-23 17:15 ` [Bug go/67976] " vogt at linux dot vnet.ibm.com 2015-10-23 17:49 ` ian at airs dot com @ 2015-10-27 10:52 ` vogt at linux dot vnet.ibm.com 2015-10-27 13:01 ` vogt at linux dot vnet.ibm.com 3 siblings, 0 replies; 5+ messages in thread From: vogt at linux dot vnet.ibm.com @ 2015-10-27 10:52 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67976 --- Comment #3 from Dominik Vogt <vogt at linux dot vnet.ibm.com> --- When do you expect Go 1.5 to be merged? ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug go/67976] Cgo + Gccgo not working like Cgo + Golang? 2015-10-15 14:03 [Bug go/67976] New: Cgo + Gccgo not working like Cgo + Golang? vogt at linux dot vnet.ibm.com ` (2 preceding siblings ...) 2015-10-27 10:52 ` vogt at linux dot vnet.ibm.com @ 2015-10-27 13:01 ` vogt at linux dot vnet.ibm.com 3 siblings, 0 replies; 5+ messages in thread From: vogt at linux dot vnet.ibm.com @ 2015-10-27 13:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67976 --- Comment #4 from Dominik Vogt <vogt at linux dot vnet.ibm.com> --- The patch behind the link in comment 2 fixes the problem. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-10-27 13:01 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-10-15 14:03 [Bug go/67976] New: Cgo + Gccgo not working like Cgo + Golang? vogt at linux dot vnet.ibm.com 2015-10-23 17:15 ` [Bug go/67976] " vogt at linux dot vnet.ibm.com 2015-10-23 17:49 ` ian at airs dot com 2015-10-27 10:52 ` vogt at linux dot vnet.ibm.com 2015-10-27 13:01 ` vogt at linux dot vnet.ibm.com
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).