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

add build tag math_pure_go #2

Open
wants to merge 1 commit into
base: zkGo
Choose a base branch
from
Open

Conversation

0x1cc
Copy link

@0x1cc 0x1cc commented Sep 28, 2023

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 the math_pure_go build tag to disable the assembly in math package. With the build tag -tags=math_pure_go and -gcflags=all=-d=softfloat, we can support softfloat for all platforms.

go build -gcflags=all=-d=softfloat -tags=math_pure_go

Benefit

  • This enhancement will make the Go math package compatible with softfloat, allowing Go to be used in environments or on architectures where hardware FPU support is not available or desired.
  • Users who require softfloat support will be able to utilize the math package without encountering compatibility issues.
  • The softfloat support is necessary in many scenarios, such as blockchain and cryptographic technologyies.
    • In blockchain technology, where determinism and consistency are critical, using softfloat ensures consistent results across various platforms. This is crucial for achieving consensus among nodes in a decentralized network.
    • Zero-knowledge proofs are cryptographic techniques that rely on precise and consistent mathematical operations. Softfloat support is essential for achieving consistent and predictable results when implementing zero-knowledge proof systems.
  • The proposal aligns with Go's philosophy of providing flexibility and compatibility across various platforms and use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant