$ gccgo -static helloworld.go
$./a.out
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0]
goroutine 2 [syscall]:
goroutine 1 [runnable]:
$
$gccgo -v
Utilisation des specs internes.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configuré avec: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Modèle de thread: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1)
$
I haven't sorted out precisely why this happens, but to fix it add
-Wl,-u,pthread_create to your link line.
package main
func main() {
}
$LC_ALL=C gccgo -Wl,-u,pthread_create -nostdlib empty.go
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400144
/tmp/cc1el2AA.o: In function `main.main':
toto.go:(.text+0x18): undefined reference to `__morestack'
/tmp/cc1el2AA.o: In function `__go_init_main':
toto.go:(.text+0x3b): undefined reference to `__morestack'
collect2: error: ld returned 1 exit status
$
I tried to compile my own mini-kernel in Go (here : https://groups.google.com/forum/?fromgroups=#!searchin/golang-nuts/easy$20kernel/golang-nuts/P7uct7eTOIQ/iw1PNkbHmUkJ) but I had some strange errors. Because I don't use gccgo as often as go-compiler, I ran some tests and I found some strange behaviours. For example, when I compile a simple HelloWorld program with gccgo, no problems but if I had the "-static" flag, I had those errors when I run it :$ gccgo -static helloworld.go$./a.outpanic: runtime error: invalid memory address or nil pointer dereference[signal 0xb code=0x1 addr=0x0]
goroutine 2 [syscall]:
goroutine 1 [runnable]:
$