RT: go基本已经通吃了所有主流处理器。MIPS64的处理器也已经支持了,但是唯独MIPS32的处理器不支持。
目前有个需求就是在MIPS处理器上也能用上GO。目前知道的只有GCCGO了。
老版本的gccgo可以编译成功,gcc 4.8.3这个我就成功了
但是新版本我基本上试过,所有的办法去编译mips的gccgo 5.X,6.X版本。
1、直接从GCC源码编译。
2、crosstool-ng工具编译。
3、buildroot工具编译。
4、通过openwrt编译工具编译
都失败了。 工具基本能编译出来(gccgo,go1等),但是库编译就报错,编译不通过。
基本是gcc\libffi\src\mips\o32.s这个文件报错。
94行 l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
101行 l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
等等这样的汇编错误。 我已经搞疯了。实在没招了。
问问有哪位大神搞过MIPS处理器的GCCGO 指导一下。
有疑问加站长微信联系(非本文作者)

完整的错误信息如下:
GCCGO编译信息:
Using built-in specs. COLLECT_GCC=./gccgo Target: mipsel-unknown-linux-gnu Configured with: /home/czlz/mips/mipsel-unknown-linux-gnu/.build/src/gcc-5.3.0/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=mipsel-unknown-linux-gnu --prefix=/home/czlz/mips/x-tools/mipsel-unknown-linux-gnu --with-sysroot=/home/czlz/mips/x-tools/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sysroot --enable-languages=c,c++,go --with-arch=mips32r2 --with-abi=32 --with-float=soft --with-pkgversion='crosstool-NG crosstool-ng-1.22.0-134-ge1d494a' --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --enable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --with-gmp=/home/czlz/mips/mipsel-unknown-linux-gnu/.build/mipsel-unknown-linux-gnu/buildtools --with-mpfr=/home/czlz/mips/mipsel-unknown-linux-gnu/.build/mipsel-unknown-linux-gnu/buildtools --with-mpc=/home/czlz/mips/mipsel-unknown-linux-gnu/.build/mipsel-unknown-linux-gnu/buildtools --with-isl=/home/czlz/mips/mipsel-unknown-linux-gnu/.build/mipsel-unknown-linux-gnu/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --enable-plugin --with-mips-plt --disable-nls --disable-multilib --with-local-prefix=/home/czlz/mips/x-tools/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sysroot --enable-long-long Thread model: posix gcc version 5.3.0 (crosstool-NG crosstool-ng-1.22.0-134-ge1d494a)
错误信息:
我用Ubuntn系统测试了gccgo-6 编译go代码可以在ubuntu上,之后安装 gccgo-6-mips-linux-gnu,编译出来的来程序无法在openwrt上运行。 不想折腾下去了。人生苦短,还是少折腾 linux 和 gccgo。 如果那位能让go程序在 openwrt/mips32 上运行,可否告诉我一下。我的Q/Q: 276 846 259
参考: https://groups.google.com/forum/#!topic/golang-nuts/0PtkEbR-Y7k https://golang.org/doc/install/gccgo https://github.com/zoobab/openwrt-15.05-go/blob/dac14e7a64b8925ab1b849fcae518a194a0c0561/build.sh.txt http://packages.ubuntu.com/yakkety/devel/
命令(gccgo需要ln /usr/bin/mips-linux-gnu-gccgo-6 /usr/bin/gccgo): go build -x -compiler gccgo --gccgoflags "-Wl,-R,$LD_LIBRARY_PATH -static -Wall -L $ROOTDIR/lib"
打印出来: WORK=/tmp/go-build439502237 mkdir -p $WORK/_/root/go/test/obj/ mkdir -p $WORK//root/go/test/obj/exe/ cd /root/go/test /usr/bin/gccgo -I $WORK -c -g -fgo-relative-import-path=/root/go/test -o $WORK/_/root/go/test/_obj/go.o -Wl,-R,/usr/lib/gcc-cross/mips-linux-gnu/6 -static -Wall -L /lib ./test.go ar rc $WORK//root/go/libtest.a $WORK//root/go/test/_obj/go.o cd . /usr/bin/gccgo -o $WORK/_/root/go/test/obj/exe/a.out $WORK//root/go/test/_obj/go.o -Wl,-( -Wl,--whole-archive -Wl,--no-whole-archive -Wl,-) -Wl,-R,/usr/lib/gcc-cross/mips-linux-gnu/6 -static -Wall -L /lib mv $WORK/_/root/go/test/_obj/exe/a.out test