Today I encountered what seems to be a bug in gccgo.
What I'm trying to do is to link and use a C-library in my application
written in Go. I have narrowed the C-library down to having a method
printing "hi" on stdio.
The directory structure is:
$ tree cfuncer ccombo
cfuncer
├── inc
│ └── cfuncer.h
├── libcfunker.a
└── src
└── cfuncer.c
ccombo
└── ccombo.go
The main Go-program looks like:
http://play.golang.org/p/h9cXKM6WzG
the C-library consists of the following code:
http://play.golang.org/p/BIVXB0wZjg
and is compiled in the following way:
$ cd cfunker
$ gcc -I inc -Wall -c cfuncer.c
$ ar cruv libcfuncer.a cfuncer.o
Compiling the main program as:
$ cd ../ccombo
$ go build main.go
works, but when using gccgo like:
$ go build -compiler=gccgo main.go
it fails with the error:
# command-line-arguments
/tmp/go-build937064904/command-line-arguments/_obj/ccombo.cgo2.o: In
function `_cgo_53b96737dc38_Cfunc_cfunction':
ccombo.cgo2.c:(.text+0x3): undefined reference to `cfunction'
collect2: error: ld returned 1 exit status
My compilers has the following versions:
$ go version
go version go1.2 linux/amd64
$ gccgo -v
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/opt/gccgo-stable/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.2/configure --prefix=/opt/gccgo-stable
--enable-languages=c,c++,go
Thread model: posix
gcc version 4.8.2 (GCC)
I have also tried to do the same compilation with gcc 4.9.0 but it produces
the same error.
$ gccgo -v
Using built-in specs.
COLLECT_GCC=/opt/gccgo/bin/gccgo
COLLECT_LTO_WRAPPER=/opt/gccgo/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/opt/gccgo --with-arch-32=i586
--enable-languages=c,c++,go
Thread model: posix
gcc version 4.9.0 20131127 (experimental) (GCC)
--
Fredrik Pettersson
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.