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)
committerShengjing Zhu <zhsj@debian.org>
Tue, 13 Jul 2021 05:55:42 +0000 (06:55 +0100)
commit9a2743bed824e8eb81475907118b5158659a0fbe
tree9286eb69885d21a4d7c2a8e8daee37ff992beee8
parentd7b8b7e0d59fabecc57bc036802207f632c934b5
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