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
Labels
early-in-cycle A change that should be done early in the 3 month dev cycle. FrozenDueToAge
Milestone

Comments

@juliandroid
Copy link

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 commented Dec 2, 2016

/cc @vstefanovic @cherrymui

@cherrymui
Copy link
Member

see also #14635.

@cherrymui
Copy link
Member

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

@vstefanovic
Copy link
Member

@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

@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

@juliandroid
Sure, I'll add a link.

@minux
Copy link
Member

minux commented Dec 9, 2016 via email

@minux minux modified the milestones: Go1.9, Unplanned Dec 9, 2016
@petar-jovanovic
Copy link

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 commented Jan 6, 2017

@vstefanovic any progress? need any help with this?

@vstefanovic
Copy link
Member

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

@elimisteve
Copy link
Contributor

@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

@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

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

@krasin
Copy link

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

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

@krasin
Copy link

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
Contributor

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

@gopherbot
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

@pqyptixa
Copy link

@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

@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

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

@ALTree
Copy link
Member

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 modified the milestones: Go1.10, Go1.11 Nov 22, 2017
@bradfitz bradfitz modified the milestones: Go1.11, Go1.10 Nov 28, 2017
@bradfitz
Copy link
Contributor

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

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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Russ Cox <[email protected]>
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Cherry Zhang <[email protected]>
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Cherry Zhang <[email protected]>
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Cherry Zhang <[email protected]>
@aclements
Copy link
Member

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

@dtodor
Copy link

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

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

@wengerxin
Copy link

Is soft point support for mips64 ready?

@ALTree
Copy link
Member

ALTree commented Feb 12, 2018

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

@cherrymui
Copy link
Member

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

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 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

@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.
Labels
early-in-cycle A change that should be done early in the 3 month dev cycle. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests