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

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).