golang/go

runtime: illegal instruction on mipsel (mipsle) platform

Baozisoftware opened this issue · 3 comments

What version of Go are you using (go version)?

go1.8rc3.linux-amd64
DL:https://storage.googleapis.com/golang/go1.8rc3.linux-amd64.tar.gz

What operating system and processor architecture are you using (go env)?

All use default.

What did you do?

1.Create a test.go:

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello world!")
}

2.Buid to mipsle:

GOARCH=mipsle go build test.go

3.use "file test" output:

test: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), statically linked, not stripped

4.Copy the file to OpenWrt router(kernel:4.4.14):
---cat /proc/cpuinfo---

system type		: MediaTek MT7620A ver:2 eco:6
machine			: OY-0001
processor		: 0
cpu model		: MIPS 24KEc V5.0
BogoMIPS		: 398.13
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes




hardware watchpoint	: yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16 dsp
shadow register sets	: 1
kscratch registers	: 0
package			: 0
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available
system type		: MediaTek MT7620A ver:2 eco:6
machine			: OY-0001
processor		: 0
cpu model		: MIPS 24KEc V5.0
BogoMIPS		: 398.13
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16 dsp
shadow register sets	: 1
kscratch registers	: 0
package			: 0
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

5.use "test" in router output:
Illegal instruction

What did you expect to see?

output:
Hello world!

What did you see instead?

output:
Illegal instruction

Is kernel FPU emulation enabled on the target machine? That is required for running go1.8 on mipsle:

Go now supports 32-bit MIPS on Linux for both big-endian (linux/mips) and little-endian machines (linux/mipsle) that implement the MIPS32r1 instruction set with FPU or kernel FPU emulation. Note that many common MIPS-based routers lack an FPU and have firmware that doesn't enable kernel FPU emulation; Go won't run on such machines.

OpenWrt:
make kernel_menuconfig
--> Kernel type
---->set MIPS FPU Emulator = y

Build image.
enjoy,thanks very much!

minux commented