Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a small Go program for MIPS with no hardware floating point (softfloat required)

I have small program written in go that I'm trying to cross compile to get working on a MIPS architecture machine. I've been trying to cross compile using the XGO cross compilation library but have had limited success getting my program to run (https://github.com/karalabe/xgo).

Here is the cpuinfo of the device, which is currently running a version of openwrt.

system type     : Qualcomm Atheros QCA9533 ver 2 rev 0
machine         : GL.iNet GL-AR750
processor       : 0
cpu model       : MIPS 24Kc V7.4
BogoMIPS        : 432.53
wait instruction    : yes
microsecond timers  : yes
tlb_entries     : 16
extra interrupt vector  : yes
hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa         : mips1 mips2 mips32r1 mips32r2
ASEs implemented    : mips16
shadow register sets    : 1
kscratch registers  : 0
package         : 0
core            : 0
VCED exceptions     : not available
VCEI exceptions     : not available

Running the program I get a SIGILL Illegal instruction from the following:

Program terminated with signal SIGILL, Illegal instruction.
#0  0x008274a8 in __sigsetjmp_aux () 

I can see that __sigsetjmp_aux() is defined here

/usr/lib/gcc-cross/mips-linux-gnu/5/../../../../mips-linux-gnu/lib/../lib/libc.a(setjmp_aux.o): definition of __sigsetjmp_aux 

How can I ensure all my dependencies are compiled using SOFTFLOAT ?

I've been passing xgo the following environment variables but it seems GLIBC is not being compiled as soft-float

CC=mips-linux-gnu-gcc-5 CXX=mips-linux-gnu-g++-5 GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=1 CFLAGS=msoft-float

Any help would be appreciated thanks!

EDIT Here is the asm layout

    0x8274a4 <__sigsetjmp_aux+4>    addiu  gp,gp,-19312                                                                                                                          │
  >│0x8274a8 <__sigsetjmp_aux+8>    sdc1   $f20,56(a0)                                                                                                                           │
   │0x8274ac <__sigsetjmp_aux+12>   sdc1   $f22,64(a0) 
like image 214
MattLock Avatar asked Mar 05 '23 00:03

MattLock


1 Answers

I had to run Go on MIPS one time, and solved the problem by building the kernel with floating point emulation. It's slow but it works.

like image 120
Zan Lynx Avatar answered Apr 28 '23 02:04

Zan Lynx