You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
compress/flate: EstimatedBits output depends on CPU architecture ["fused multiply and add" (FMA)] #81589
The Go spec allows this to be replaced with a "fused multiply and add" (FMA), which changes how the result is rounded. FMA is used with GOARCH=aarch64, but not with GOARCH=amd64 GOAMD64=v1.
I understand that the behaviour (and expected output) of the compression changed with Go 1.27 (https://go-review.googlesource.com/c/go/+/707355) and users shouldn't depend on the exact bytes of the output.
However, I would expect that the same version of Go has a deterministic implementation of gzip (even across CPU architectures).
This is not true in my tests.
changed the title [-]compress/flate: mFastLog2 output depends on CPU architecture ["fused multiply and add" (FMA)][/-][+]compress/flate: EstimatedBits output depends on CPU architecture ["fused multiply and add" (FMA)][/+]on Sep 18, 2026
I think this is actually pretty critical to fix, because the linker does DWARF compression and therefore binaries may not be reproducible depending on the FMA behavior of the system.
(Generally to me this means that implicit FMA should be outright banned in cmd/compile and cmd/link, maybe more, but that's a more drastic opinion.)
Gentle ping on this. The same fix was already merged in klauspost/compress.
Given the statement from @jakebailey above, I think we may even want to backport this to Go 1.27:
I think this is actually pretty critical to fix, because the linker does DWARF compression and therefore binaries may not be reproducible depending on the FMA behavior of the system.
I might be wrong about it; when I looked and tried to reproduce a bug, the FMA code wasn't actually hit because the DWARF compression level used by the linker is not actually high enough. Still, bad bug!
Activity
gabyhelp commentedon Sep 18, 2026
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
compress/flate: avoid FMA in mFastLog2 for portable rounding
gopherbot commentedon Sep 18, 2026
Change https://go.dev/cl/834885 mentions this issue:
compress/flate: avoid FMA in mFastLog2 for portable rounding[-]compress/flate: mFastLog2 output depends on CPU architecture ["fused multiply and add" (FMA)][/-][+]compress/flate: EstimatedBits output depends on CPU architecture ["fused multiply and add" (FMA)][/+]flate: avoid FMA in EstimatedBits for portable rounding
jakebailey commentedon Sep 18, 2026
I think this is actually pretty critical to fix, because the linker does DWARF compression and therefore binaries may not be reproducible depending on the FMA behavior of the system.
(Generally to me this means that implicit FMA should be outright banned in cmd/compile and cmd/link, maybe more, but that's a more drastic opinion.)
thepudds commentedon Sep 18, 2026
This might also be affected by
GOAMD64=v1versusGOAMD64=v3?malt3 commentedon Sep 18, 2026
@thepudds yes. See the godbolt link above. It shows that the issue also exists on GOAMD64=v3: https://godbolt.org/z/dTzxMb8a6
cherrymui commentedon Sep 18, 2026
cc @klauspost @dsnet
flate: avoid FMA in EstimatedBits for portable rounding
flate: avoid FMA in EstimatedBits for portable rounding
malt3 commentedon Sep 30, 2026
Gentle ping on this. The same fix was already merged in klauspost/compress.
Given the statement from @jakebailey above, I think we may even want to backport this to Go 1.27:
jakebailey commentedon Sep 30, 2026
I might be wrong about it; when I looked and tried to reproduce a bug, the FMA code wasn't actually hit because the DWARF compression level used by the linker is not actually high enough. Still, bad bug!