I don't know if anybody has tried gccgo on a MIPS GNU/Linux target, but
I don't know of any reason why it would not work. Gccgo has been used
successfully on MIPS Irix targets.
Ian
func main() {
fmt.Println(pi(5000))
}
// pi launches n goroutines to compute an
// approximation of pi.
func pi(n int) float64 {
package main
import (
"fmt"
"net/http"
)
type Hello struct{}
func (h Hello) ServeHTTP(
w http.ResponseWriter,
r *http.Request) {
fmt.Fprint(w, "Hello!")
}
func main() {
var h Hello
http.ListenAndServe("localhost:4000",h)
}
I tried to run it from gdb but there is not enough memory for gdb.... sigh...
Then I tried to recompile gccgo using the "default" openwrt libc library, uclibc instead og eglibc, but gccgo doesn't compile because it require set/make/context routines which are not implemented by uclibc.....so stucked with eglibc (and a bigger footprint)toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04/libgo/runtime/proc.c: In function '__go_go':toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04/libgo/runtime/proc.c:1368:2: error: implicit declaration of function 'makecontext' [-Werror=implicit-function-declaration]
So not so easy to run Go on embedded devices :(
I'll take a look at what the getcontext/savecontext/makecontext routines should look like... I hope it's not processor specific.
Concerning the http example segfault that's easy, no stacktrace just :$./httpSegmentation faultexactly like the peano output I sent a few emails ago, nothing else than "Segmentation fault", no address, nothing, void.
I'll printout tonight the gdb errors but basically it says it cannot allocate 3Mb of RAM to do some stuff as soon as I ask him to start my go program.I never used gdbserver, how does it work in a few words or in other words, what should I compile on my openwrt router ?
Yep I found this message : http://www.mail-archive.com/ucl...@uclibc.org/msg08376.html, I emailed the guy... I wait now :) But it seems he had some issues.Using eglibc (hidden option of openwrt), it solves the issue but so few RAM left... I have to learn how to squeeze eglibc footprint...(e.g. remove useless features)
How to get "mips-openwrt-linux-gccgo"?
Thanks minux .I found a simple method:1. vim toolchain/common.mkupdate TARGET_LANGUAGES, add "CONFIG_INSTALL_GCCGO"SEP:=,TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)$(if $(CONFIG_INSTALL_GCCGO),$(SEP)go)"2. vim toolchain/Config.inadd :config INSTALL_GCCGOboolprompt "Build/install gccgo compiler?" if TOOLCHAINOPTSdefault nhelpBuild/install GNU gccgo compiler ?3. make menuconfig (select gccgo in toolchain)4. make V=995. ........../home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04/libgo/runtime/proc.c: In function 'runtime_gogo':/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04/libgo/runtime/proc.c:300:2: error: implicit declaration of function 'setcontext' [-Werror=implicit-function-declaration]/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04/libgo/runtime/proc.c: In function 'runtime_mcall':/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04/libgo/runtime/proc.c:335:3: error: implicit declaration of function 'getcontext' [-Werror=implicit-function-declaration]/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04/libgo/runtime/proc.c: In function '__go_go':/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04/libgo/runtime/proc.c:1368:2: error: implicit declaration of function 'makecontext' [-Werror=implicit-function-declaration]cc1: all warnings being treated as errorsmake[8]: *** [proc.lo] Error 1make[8]: Leaving directory `/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04-final/mips-openwrt-linux-uclibc/libgo'make[7]: *** [all-recursive] Error 1make[7]: Leaving directory `/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04-final/mips-openwrt-linux-uclibc/libgo'make[6]: *** [all] Error 2make[6]: Leaving directory `/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04-final/mips-openwrt-linux-uclibc/libgo'make[5]: *** [all-target-libgo] Error 2make[5]: Leaving directory `/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04-final'make[4]: *** [all] Error 2make[4]: Leaving directory `/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04-final'make[3]: *** [/home/justin/OpenWRT/trunk/build_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/gcc-linaro-4.7-2012.04-final/.built] Error 2make[3]: Leaving directory `/home/justin/OpenWRT/trunk/toolchain/gcc/final'make[2]: *** [toolchain/gcc/final/compile] Error 2make[2]: Leaving directory `/home/justin/OpenWRT/trunk'make[1]: *** [/home/justin/OpenWRT/trunk/staging_dir/toolchain-mips_r2_gcc-4.7-linaro_uClibc-0.9.33.2/stamp/.toolchain_install] Error 2make[1]: Leaving directory `/home/justin/OpenWRT/trunk'make: *** [world] Error 2
minux於 2012年10月7日星期日UTC+8下午1時34分07秒寫道: