shawn1m / overture

A customized DNS relay server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MT7620 RAMIPS 架构无法运行预编译版本

LGA1150 opened this issue · comments

OpenWrt 15.05
运行 overture-linux-mips 时报错:
./overture-linux-mips: line 1: syntax error: unexpected "("
运行 overture-linux-mipsle 时报错:
Illegal instruction

commented

这个不清楚,这是 Go 1.8 的新特性,可能会有一些问题。我没办法调试,你可以自己交叉编译试试看。

我有交叉编译环境,要怎么配置Go的交叉编译呢?

commented

搜了一下有:http://studygolang.com/articles/7326 ,这是匹配以前版本的。
当前版本可以

GOOS=linux GOARCH=mips CGO_ENABLED=0 go build -o overture-linux-mips main/main.go

GOOS GOARCH 参数可选项参见:https://golang.org/doc/install/source

据悉如果是 RAMIPS ,应该把 GOARCH 设为 mips32le

官方的编译器似乎不能设置为 mips32le ,编译会报错,设为 mipsle 后运行时仍然有 Illegal instruction.

之后我找到了 https://github.com/gomini/go-mips32 ,成功编译了可以运行的版本 overture-linux-mips32le

以下是执行 file 命令的输出:

root@OpenWrt:/tmp/overture# file overture-linux-mipsle
overture-linux-mipsle: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), statically linked, not stripped
root@OpenWrt:/tmp/overture# file overture-linux-mips32le
overture-linux-mips32le: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), statically linked, not stripped

可以运行的多了个 rel2

commented

golang/go#18880
你可以试一下是不是 FPU 的问题。

fatedier/frp#245
看来是的,然而得重新编译固件加入 FPU 模拟才能用
在 Golang 解决这个问题之前,暂时用 gomini/go-mips32 编译 MIPS 用的版本吧

编译时加上参数 -ldflags "-s -w" 可以稍微减少编译的可执行文件大小
我编译好的文件大小达到 6.7MB ,快赶上路由器固件大小了,加上参数后减小到了 4.7MB

又用 UPX 压缩了一下,大小只有约 900K 了,需要的可以下载
overture-linux-ramips.zip

commented

非常感谢。

为什么不把 ramips 加进 release 呢

commented

Release 是直接用 build.py 自动生成的,我这里没有 ramips 的编译和测试环境,所以就没有放进来。我刚才试了一下,如果要编译 go 的话需要处理很多依赖关系,我这里没法做。Release 的内容是由自动化脚本决定的。

commented

或者新版本如果你编译好了上传我放进去。

@LGA1150 重新编译固件会导致内核改变 无法安装官方仓库的 kmod 包

lede AR71XX mips 版不工作Illegal instruction