Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: mips32 soft float point support #18162

Closed
juliandroid opened this issue Dec 2, 2016 · 61 comments

Comments

@juliandroid
Copy link

commented Dec 2, 2016

I have built Golang by using the master branch and I have realized that there is no soft point support for the new mips32 target. That means the core like MIPS32 74Kc is not supported due to lack of FPU.

I have wrote an email to Vladimir Stefanovic, asking him to confirm the soft-float point support issue and his response was that in the near future there are no plans soft-point support to be implemented, but that might change later.

It would be great to have a ticket here to keep track the development of the issue and hopefully one day this issue to be resolved.

@bradfitz bradfitz changed the title mips32 soft float point support runtime: mips32 soft float point support Dec 2, 2016

@bradfitz bradfitz added this to the Unplanned milestone Dec 2, 2016

@bradfitz

This comment has been minimized.

Copy link
Member

commented Dec 2, 2016

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Dec 2, 2016

see also #14635.

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Dec 2, 2016

There are softfloat code for ARM that we can reuse. What still need to be done is MIPS instruction decoding.

@vstefanovic

This comment has been minimized.

Copy link
Member

commented Dec 2, 2016

@juliandroid
Yes, and after you quite a few other people asked about soft float support, so looks like the future has almost arrived.
If the code wasn't in feature freeze state, the patch would be submitted relatively soon.

@juliandroid

This comment has been minimized.

Copy link
Author

commented Dec 2, 2016

@vstefanovic
That was fast, the issue comes with twist :) Thanks for working on it!
Can you please leave the commit id (gerrit) here, once you complete the soft-float support? I'm willing to try it even before the merge in the master.

@vstefanovic

This comment has been minimized.

Copy link
Member

commented Dec 2, 2016

@juliandroid
Sure, I'll add a link.

@minux

This comment has been minimized.

Copy link
Member

commented Dec 9, 2016

@minux minux modified the milestones: Go1.9, Unplanned Dec 9, 2016

@petar-jovanovic

This comment has been minimized.

Copy link

commented Dec 9, 2016

The rationale is that most MIPS machines do not have an
FPU

I have to disagree. Majority of modern MIPS boards do have FP
unit. There is a long list of legacy boards that indeed lack FPU
support, but relatively modern MIPS boards all have it.
$GOMIPS is important also to make a distinction between MIPS32r1/r2/r6 and
MIPS64r2/r6 (and MIPS3 as a legacy) that we plan to support through Go.

@aep

This comment has been minimized.

Copy link

commented Jan 6, 2017

@vstefanovic any progress? need any help with this?

@vstefanovic

This comment has been minimized.

Copy link
Member

commented Jan 9, 2017

@aep
Thanks, this will be submitted after go 1.8 is released, since it was too late for 1.8.

@elimisteve

This comment has been minimized.

Copy link
Contributor

commented Feb 11, 2017

@vstefanovic I just heard of this via https://groups.google.com/forum/#!topic/golang-nuts/DT_P9UPKHgI . Adding soft floating point support for MIPS(32) would be fantastic! As soon as a patch or release is ready, I'm excited to use it. Think that might be soon?

@vstefanovic

This comment has been minimized.

Copy link
Member

commented Feb 14, 2017

@elimisteve great to hear that. I'd like to prepare docker diffs first, then get back to the soft-float with a rebase and some double-checking; presumably it'll be uploaded in a few weeks.

@juliandroid

This comment has been minimized.

Copy link
Author

commented Feb 14, 2017

I'm watching the calendar on the wall patiently too 👍

@krasin

This comment has been minimized.

Copy link

commented Mar 2, 2017

@vstefanovic any updates? I would be willing to be a guinea pig for any work-in-progress patch you might have. The device I would like to run Go binaries on is based on MT7628AN, mips32 little endian, if that matters.

@vstefanovic

This comment has been minimized.

Copy link
Member

commented Mar 3, 2017

Hi @krasin, give me a few more days, then I'll upload the code to gerrit.

@krasin

This comment has been minimized.

Copy link

commented Mar 3, 2017

@vstefanovic sure thing. As a workaround, I have compiled my kernel with FPU emulation flag, but that does not feel like the way to go, so a proper soft float support is highly appreciated.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 8, 2017

CL https://golang.org/cl/37954 mentions this issue.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 8, 2017

CL https://golang.org/cl/37955 mentions this issue.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 8, 2017

CL https://golang.org/cl/37958 mentions this issue.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 8, 2017

CL https://golang.org/cl/37956 mentions this issue.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 8, 2017

CL https://golang.org/cl/37957 mentions this issue.

@pqyptixa

This comment has been minimized.

Copy link

commented Mar 17, 2017

@vstefanovic
I cloned Go master and merged your patches, but still wasn't able to run the binary:

$ echo -e 'package main\nfunc main(){\n\tprintln("hello world!")\n}' > hello.go
$ env GOOS=linux GOARCH=mips GOMIPS=soft-float,mips32r2 ~/go-mips32-soft-float/bin/go build hello.go
scp hello my@mips:/tmp/

At mips system (openwrt):

# /tmp/hello 
Illegal instruction
# gdb /tmp/hello
[...]
(gdb) x/i $pc 
=> 0x4732c <runtime.check+48>:  mtc1    zero,$f0

Compiling with/without GOMIPS=soft-float,mips32r2 doesn't seem to make any difference:

$ env GOOS=linux GOARCH=mips GOMIPS=soft-float,mips32r2 ~/go-mips32-soft-float/bin/go build hello.go
dacf38f5eb593a1e145f47de0da08c4e  hello
$ rm hello
$ env GOOS=linux GOARCH=mips ~/go-mips32-soft-float/bin/go build hello.go
$ md5sum hello
dacf38f5eb593a1e145f47de0da08c4e  hello
$ file hello
hello: ELF 32-bit MSB executable, MIPS, MIPS32 version 1 (SYSV), statically linked, not stripped

However, the go compiler is parsing the GOMIPS env var:

$ env GOOS=linux GOARCH=mips GOMIPS=blah ~/go-mips32-soft-float/bin/go build hello.go
# command-line-arguments
[...] Invalid GOMIPS value. Valid values are: soft-float/hard-float, mips32/mips32r2.
If more than one, separate them with comma. E.g. GOMIPS=soft-float,mips32.

Am I doing something wrong, or missing something? Are these patches not yet complete?

BTW, thanks a lot for your work!

@vstefanovic

This comment has been minimized.

Copy link
Member

commented Mar 17, 2017

@pqyptixa
The patches are complete. Maybe you're missing '-a', ie. 'go build -a', if you have previously built something as hard-float.
The build system doesn't do clean build when you change GOMIPS (or GOARM, GO386) value, we might want to improve that, but at the moment 'go build -a' is the safe way.

@pqyptixa

This comment has been minimized.

Copy link

commented Mar 18, 2017

@vstefanovic
That was it, I needed to use -a ! :D
Thank you!

@petar-jovanovic

This comment has been minimized.

Copy link

commented Nov 17, 2017

This has been planned for 1.10, since it missed 1.9 for some reasons. The issue had Go1.10Early milestone.
Any update on including this @cherrymui @bradfitz ?

@ALTree

This comment has been minimized.

Copy link
Member

commented Nov 17, 2017

@petar-jovanovic I pinged them yesterday asking for an update about the CLs and Cherry said they were all reviewed except this one: https://go-review.googlesource.com/c/go/+/37954. So as soon as that one is also +2ed reviewers will decide if they can be all merged to be included in 1.10.

@rsc rsc modified the milestones: Go1.10, Go1.11 Nov 22, 2017

@bradfitz bradfitz modified the milestones: Go1.11, Go1.10 Nov 28, 2017

@bradfitz

This comment has been minimized.

Copy link
Member

commented Nov 28, 2017

I'm bumping this back to Go 1.10 because it might've been moved to Go1.11 along with a bunch of other bugs en masse.

I'd prefer this go into Go 1.10 if @rsc doesn't find it too invasive.

@juliandroid

This comment has been minimized.

Copy link
Author

commented Nov 28, 2017

I would greatly appreciate if this ends up in Go 1.10 as @aclements pledged to try his best last time :)

@bradfitz Thanks for pushing this into 1.10 👍

gopherbot pushed a commit that referenced this issue Nov 30, 2017

cmd/go, cmd/dist: introduce GOMIPS environment variable
GOMIPS is a GOARCH=mips{,le} specific option, for a choice between
hard-float and soft-float. Valid values are 'hardfloat' (default) and
'softfloat'. It is passed to the assembler as
'GOMIPS_{hardfloat,softfloat}'.

Note: GOMIPS will later also be used for a choice of MIPS instruction
set (mips32/mips32r2).

Updates #18162

Change-Id: I35417db8625695f09d6ccc3042431dd2eaa756a6
Reviewed-on: https://go-review.googlesource.com/37954
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>

gopherbot pushed a commit that referenced this issue Nov 30, 2017

runtime: implement some soft-float routines (used by GOMIPS=softfloat)
Updates #18162

Change-Id: Iee854f48b2d1432955fdb462f2073ebbe76c34f8
Reviewed-on: https://go-review.googlesource.com/37957
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>

gopherbot pushed a commit that referenced this issue Nov 30, 2017

runtime/cgo, math: don't use FP instructions for soft-float mips{,le}
Updates #18162

Change-Id: I591fcf71a02678a99a56a6487da9689d3c9b1bb6
Reviewed-on: https://go-review.googlesource.com/37955
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>

gopherbot pushed a commit that referenced this issue Nov 30, 2017

cmd/compile: use soft-float routines for soft-float targets
Updates #18162 (mostly fixes)

Change-Id: I35bcb8a688bdaa432adb0ddbb73a2f7adda47b9e
Reviewed-on: https://go-review.googlesource.com/37958
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
@aclements

This comment has been minimized.

Copy link
Member

commented Dec 1, 2017

This is fixed as of 6be1c09. Thanks! I opened #22966 for creating a builder to test this configuration.

@dtodor

This comment has been minimized.

Copy link

commented Jan 30, 2018

We have a problem with the Go compiler on a MIPS target without the CONFIG_MIPS_FPU_EMULATOR being enabled. I thought in such case the soft-float support in go1.10RC1 would be sufficient but unfortunately be cannot build any runnable Go programs. The FPU configuration of the target is:
CONFIG_MIPS_FPU_EMULATOR=n
CONFIG_CPU_R4K_FPU=y

Any ideas?

@davecheney

This comment has been minimized.

Copy link
Contributor

commented Jan 30, 2018

@dtodor. Please open a new issue including how you built Go or the target binary.

@wengerxin

This comment has been minimized.

Copy link

commented Feb 12, 2018

Is soft point support for mips64 ready?

@ALTree

This comment has been minimized.

Copy link
Member

commented Feb 12, 2018

@wengerxin No, apparently. Softfloat for mips64 is issue #14635, which is still open.

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Feb 12, 2018

@wengerxin Soft float on MIPS64 are not officially supported. However, the functionality are all there. You are welcomed to try it, by setting GO_GCFLAGS="-d softfloat" on bootstrap and setting -gcflags=all="-d softfloat" on go build. (Note: this is not tested though, and assembly code, if any, are not covered.)

@wengerxin

This comment has been minimized.

Copy link

commented Mar 1, 2018

I consulted the mips32 modification and modified the flowing files to shield the float instructions:
src/runtime/cgo/asm_mips64x.s
/src/runtime/cgo/gcc_mips64x.S

0001-add-mips64-soft-float.zip
Modifications are in the attached file, but I don't know whether these modifications are right?

@milanknezevic

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2018

@wengerxin These modifications are needed only if you need CGO (you can disable it with CGO_ENABLED=0). But if you need it, you are on the right track. Are you planning to send the patch for review?
Just to mention, in a week or two we plan to do modifications which will enable softfloat on MIPS64.

@wengerxin

This comment has been minimized.

Copy link

commented Mar 2, 2018

@milanknezevic , Thank you for your answer. Yes, I need CGO to compile docker.
I'm not planning to send the patch for review, I would wait for official merge and then try again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.