cmd/go, cmd/cgo: pass -mfp32 and -mhard/soft-float to MIPS GCC
authorYunQiang Su <wzssyqa@gmail.com>
Tue, 9 Jun 2020 04:09:58 +0000 (04:09 +0000)
committerMichael Hudson-Doyle <michael.hudson@ubuntu.com>
Mon, 14 Sep 2020 21:51:42 +0000 (22:51 +0100)
commit07b2abd428be9ac39d74bf4a97381b4d2b0f06d9
tree72ee60de30d735a56d39d999f541137239fb89d4
parentd468d4b3f7fbf7bbcb6cbdb6091aece0f45cf7da
cmd/go, cmd/cgo: pass -mfp32 and -mhard/soft-float to MIPS GCC

For mips32 currently, we are using FP32, while the gcc may be FPXX,
which may generate .MIPS.abiflags and .gnu.attributes section with
value as FPXX. So the kernel will treat the exe as FPXX, and may
choose to use FR=1 FPU mode for it.
Currently, in Go, we use 2 lwc1 to load both half of a double value
to a pair of even-odd FPR. This behavior can only work with FR=0 mode.

In FR=1 mode, all of 32 FPR are 64bit. If we lwc1 the high-half of a double
value to an odd FPR, and try to use the previous even FPR to compute, the
real high-half of even FPR will be unpredicatable.
We set -mfp32 to force the gcc generate FP32 code and section value.

More details about FP32/FPXX/FP64 are explained in:
https://web.archive.org/web/20180828210612/https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking

When GOMIPS/GOMIPS64 is set as softfloat, we should also pass
 -msoft-float to gcc.

Here we also add -mno-odd-spreg option, since Loongson's CPU cannot use
odd-number FR in FR=0 mode.

Fixes #39435

Change-Id: I54026ad416a815fe43a9261ebf6d02e5519c3930

Gbp-Pq: Name 0003-cmd-go-cmd-cgo-pass-mfp32-and-mhard-soft-float-to-MI.patch
src/cmd/cgo/gcc.go
src/cmd/cgo/main.go
src/cmd/go/internal/work/exec.go