Skip to content

build: use SSE math on 32-bit x86 also when the tarball name is given - #63350

Merged
maleadt merged 1 commit into
masterfrom
tb/i686-sse-math
Sep 25, 2026
Merged

maleadt merged 1 commit into
masterfrom
tb/i686-sse-math

Conversation

@maleadt

@maleadt maleadt commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

#43978 added -mfpmath=sse to JCFLAGS on 32-bit x86, so that Julia's C runtime does
not use 80-bit x87 math. It went inside the ifeq ($(JULIA_BINARYDIST_FILENAME),)
block that computes the binary-dist tarball name, so the flag is dropped whenever
that variable is already set. CI sets it: julia-buildkite's build_envs.sh exports
it. The i686 Linux and Windows CI builds and nightlies have therefore compiled
src/*.c with x87 math all along (make ARCH=i686 print-JCFLAGS includes
-mfpmath=sse, and JULIA_BINARYDIST_FILENAME=x make ARCH=i686 print-JCFLAGS does
not).

The x87 build now fails a test once Windows i686 is built with GCC 15.2 and
BinaryBuilder's MinGW headers (the planned CI toolchain, matching
CompilerSupportLibraries). Base.fma_float at runtime, which on Windows uses the
emulated julia_fma in runtime_intrinsics.c, returns NaN for
fma(floatmax(), 2.0, -floatmax()) and similar inputs (test/math.jl:1551-1567).
Those headers classify floats with an out-of-line __fpclassify, which sees the
rounded double, while the rest of the function computes in x87 extended precision.
The mingw-builds GCC 12 used so far inlined an fxam on the unrounded value
instead, which matched. With -mfpmath=sse the results are correct either way;
without it, a standalone copy of the function gives nan with
-D__CRT__NO_INLINE.

This moves the flag out of that block, so it always applies on 32-bit x86.

Assisted by: Opus 5.5

The -mfpmath=sse from #43978 was added inside the block that computes
JULIA_BINARYDIST_FILENAME, so it did not apply when that variable is set,
as it is in CI (julia-buildkite exports it). Julia's C runtime was
therefore built with x87 math on i686 there.
@maleadt maleadt added building Build system, or building Julia or its dependencies system:windows Affects only Windows labels Sep 25, 2026
@vtjnash vtjnash added the merge me PR is reviewed. When all tests are passing merge, making sure commit message is good. label Sep 25, 2026
@maleadt

maleadt commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

Merging early, as this is Windows-only and mingw23-build and -test passed CI.

@maleadt
maleadt merged commit df598f4 into master Sep 25, 2026
11 of 14 checks passed
@maleadt
maleadt deleted the tb/i686-sse-math branch September 25, 2026 15:08
@IanButterworth IanButterworth removed the merge me PR is reviewed. When all tests are passing merge, making sure commit message is good. label Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

building Build system, or building Julia or its dependencies system:windows Affects only Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants