Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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](golang#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