Sorry for my confused responses before. 
The thing was my hardware board lacked fpu, so that's why I could not 
make it work a simple hello world compiled with: GOOS=linux GOARCH=mips go 
build hello.go
because the go compiler did not emmit softfloat.

For other people who are facing the same problem, it can be done without 
modifying 
the original image (withouting recompiling the kernel) by using the patch 
on this issue:
https://github.com/golang/go/issues/18162

I got it done using the Vladimir patches with the following command:
env GOOS=linux GOARCH=mips GOMIPS=r2softfloat /home/lucas/Desktop/bin/go 
build -a helloworld.go

It seems ematsu shared his backport also recently, with a newest patch 
(with some fixes).


I would like to ask one question. I am trying to use c code in a go 
application. I was able to do the crosscompile 
of the code for an arm board, but not for a mips board. The go build 
command I am using:

env CGO_ENABLED=1 GOOS=linux GOARCH=mips GOMIPS=r2softfloat 
CC=/home/lucas/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_glibc-2.19.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-5.3.0_glibc-2.19/bin/mips-openwrt-linux-gccgo
 
CGO_LDFLAGS="-s -w -static-libgo 
-L/home/lucas/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_glibc-2.19.Linux-x86_64/staging_dir/target-mips_34kc_glibc-2.19/usr/lib"
 
/home/lucas/Desktop/go-mips32/bin/go build -a -v mypackage/program

It generates a binary but when i try to run on my board, it gives me the 
following: 'program' not found

When do I set a cross compile (CC), does it overwrite the go build compiler 
with softfloat ? 
Do I have the compile linking full static? 

I am not sure if this is the best place to ask these questions, so I'm 
sorry if this forum is not the right place.

Lucas.

On Monday, July 3, 2017 at 9:58:38 AM UTC-3, Lucas Wiechmann wrote:
>
> Sorry for not replying sooner. 
>
> Building with CGO_ENABLED=1 GOARCH=mips GOOS=linux go build hello.go
> I got an Illegal Instruction running on my mips board. 
>
> I used a debugger to find out what was going on but it did not gave better 
> answers why the illegal instruction was occuring.
>
> I was able to run it by recompiling the kernel with floating point 
> emulation activated.
>
> Thanks,
> Lucas.
>
> On Thursday, June 22, 2017 at 6:36:37 PM UTC-3, kty...@gmail.com wrote:
>>
>> This can be related to issue #18162
>> If you compile a normal go program for mips32 with the current compiler 
>> and run it on hardware without FPU, this is the error message you see.
>> The preferred solution is for the compiler to emmit soft float code. It 
>> has been implemented but did not make it into go-1.9.
>> As a work around, if you can recompile the kernel, you can add floating 
>> point emulation to the kernel.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to