GeertJohan / openwrt-go

Fork of the openwrt project to add gccgo and libgo
GNU General Public License v2.0
244 stars 38 forks source link

Run cross compiled go program on original openwrt mips32 firmware #19

Open bettermanbao opened 8 years ago

bettermanbao commented 8 years ago

Does anyone know the advantage of re-compile openwrt firmware with this repo? Currently I could run cross compiled go program on original openwrt mips32 firmware, but the performance is very poor.

I tried an UDP tunnel program which written in golang, but when it runs on my mips32 router after cross compiled, the transfer rate is only 2-3Mbps.

So I'm looking for some optimized metheds to run golang on my mips32 router now. Thanks!

My cross compile bin attahed, source code here: https://github.com/xtaci/kcptun

kcptun-client_mips32_little_endian.zip kcptun-client_mips32_big_endian.zip

ligf commented 8 years ago

你是怎么编译的 编译时候的参数都有哪些 我编译出来的有7m呢

bettermanbao commented 8 years ago

cd git clone https://github.com/gomini/go-mips32.git cd go-mips32/src export GOOS=linux export GOARCH=mips32 <== Change to mips32le if ramips sudo mkdir /opt/mipsgo ./make.bash cd .. sudo cp -R * /opt/mipsgo export GOROOT=/opt/mipsgo export PATH=/opt/mipsgo/bin:$PATH vi helloworld.go go build helloworld.go

hbl0307106015 commented 7 years ago

I have trouble when building mips32go on x86_64 machine, please help me:

/home/tymon/work/test/go-mips32-dev.github/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic? /home/tymon/work/test/go-mips32-dev.github/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic? runtime/cgo(.text): unexpected relocation type 298 runtime/cgo(.text): unexpected relocation type 298

cmd/go

/home/tymon/work/test/go-mips32-dev.github/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic? /home/tymon/work/test/go-mips32-dev.github/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic? runtime/cgo(.text): unexpected relocation type 298 runtime/cgo(.text): unexpected relocation type 298

awgh commented 7 years ago

To make the "unexpected relocation" errors go away, change the ./make.bash command to: CGO_ENABLED=0 ./make.bash