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
Closed

runtime: mips32 soft float point support #18162

juliandroid opened this issue Dec 2, 2016 · 61 comments

Comments

@juliandroid
Copy link

@juliandroid juliandroid 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
Copy link
Contributor

@bradfitz bradfitz commented Dec 2, 2016

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Dec 2, 2016

see also #14635.

@cherrymui
Copy link
Contributor

@cherrymui cherrymui 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
Copy link
Member

@vstefanovic vstefanovic 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
Copy link
Author

@juliandroid juliandroid 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
Copy link
Member

@vstefanovic vstefanovic commented Dec 2, 2016

@juliandroid
Sure, I'll add a link.

@minux
Copy link
Member

@minux minux commented Dec 9, 2016

@minux minux added this to the Go1.9 milestone Dec 9, 2016
@minux minux removed this from the Unplanned milestone Dec 9, 2016
@petar-jovanovic
Copy link

@petar-jovanovic petar-jovanovic 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
Copy link

@aep aep commented Jan 6, 2017

@vstefanovic any progress? need any help with this?

@vstefanovic
Copy link
Member

@vstefanovic vstefanovic 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
Copy link
Contributor

@elimisteve elimisteve 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
Copy link
Member

@vstefanovic vstefanovic 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
Copy link
Author

@juliandroid juliandroid commented Feb 14, 2017

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

@krasin
Copy link

@krasin krasin 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
Copy link
Member

@vstefanovic vstefanovic commented Mar 3, 2017

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

@krasin
Copy link

@krasin krasin 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
Copy link

@gopherbot gopherbot commented Mar 8, 2017

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

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 8, 2017

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

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 8, 2017

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

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 8, 2017

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

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 8, 2017

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

@pqyptixa
Copy link

@pqyptixa pqyptixa 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
Copy link
Member

@vstefanovic vstefanovic 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
Copy link

@pqyptixa pqyptixa commented Mar 18, 2017

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

@petar-jovanovic
Copy link

@petar-jovanovic petar-jovanovic 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
Copy link
Member

@ALTree ALTree 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 removed this from the Go1.10 milestone Nov 22, 2017
@rsc rsc added this to the Go1.11 milestone Nov 22, 2017
@bradfitz bradfitz removed this from the Go1.11 milestone Nov 28, 2017
@bradfitz bradfitz added this to the Go1.10 milestone Nov 28, 2017
@bradfitz
Copy link
Contributor

@bradfitz bradfitz 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
Copy link
Author

@juliandroid juliandroid 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
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
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
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
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
Copy link
Member

@aclements aclements commented Dec 1, 2017

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

@dtodor
Copy link

@dtodor dtodor 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
Copy link
Contributor

@davecheney davecheney commented Jan 30, 2018

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

@wengerxin
Copy link

@wengerxin wengerxin commented Feb 12, 2018

Is soft point support for mips64 ready?

@ALTree
Copy link
Member

@ALTree ALTree commented Feb 12, 2018

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

@cherrymui
Copy link
Contributor

@cherrymui cherrymui 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
Copy link

@wengerxin wengerxin 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
Copy link
Contributor

@milanknezevic milanknezevic 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
Copy link

@wengerxin wengerxin 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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet