Open 0x1cc opened 1 year ago
The implementation for softfloat support in the math package can be found in this pull request: GitHub Pull Request #63271.
What about the existing purego tag? https://github.com/golang/go/issues/23172 cc @dsnet
While this approach offers excellent performance, it creates compatibility issues with softfloat.
We already have GOMIPS=softfloat
, GO386=softfloat
, etc. for specifying the use of softfloat implementations on specific platforms — it seems like a mistake to add yet another (orthogonal) way to specify that.
If softfloat support is really needed on WASM platforms, adding a GOWASM=softfloat
seems like it would be a cleaner approach.
This should be fixable without a proposal by just adding purego
support per #23172. It has other advantages, such as supporting other compilers. TinyGo is currently having to alias symbols in the math package:
Are there still ongoing efforts on this topic? PR #23172 still seems to use the earlier proposed math_pure_go
which is different to pure_go
.
What are the blockers here exactly? I would be glad to assist since I'm working on tinygo as well and would profit from this implementation.
I don't see a problem with using the existing purego
build tag to disable assembler code in the math package. I don't think there any blockers, but somebody has to write and test the patch.
Introduction
In the current Go math package, when the architecture has a Floating-Point Unit (FPU), it accelerates floating-point computations using assembly code tailored to take advantage of the architecture's FPU. While this approach offers excellent performance, it creates compatibility issues with softfloat. To support softfloat, we can use
-gcflags=all=-d=softfloat
, which can convert floating-point calculations to softfloat within the compiler, but it doesn't impact any assembly code in the math package. (The related issue can be found here: [link to GitHub issue #62470].)To address this issue, we propose introducing a new build tag that disables the math package from utilizing FPU-related assembly code for performance optimization, thereby providing support for softfloat.
Proposed Solution
To support softfloat in the Go math package, we propose adding a new build tag, let's call it
math_pure_go
, that users can apply to disable the use of FPU-specific assembly code in the math package. We can use themath_pure_go
build tag to disable the assembly inmath
package. With the build tag-tags=math_pure_go
and-gcflags=all=-d=softfloat
, we can support softfloat for all platforms.Benefit