On 10/21/26 23:09, Peter Damianov wrote:
From: Peter Damianov <[email protected]>On other x86 targets, -mpc32, -mpc64 and -mpc80 link crtprec32.o, crtprec64.o or crtprec80.o, whose constructor sets the x87 precision control. The mingw-w64 targets accept the options but link nothing for them, so the options have no effect. The mingw-w64 runtime already chooses the x87 precision at link time. Program startup and fesetenv (FE_DFL_ENV) call _fpreset, and the _fpreset that is linked decides the precision: CRT_fp4.o sets 24 bits, CRT_fp8.o 53 bits and CRT_fp10.o 64 bits. CRT_fp10.o is also in libmingw32.a, so it is the default. Link CRT_fp4.o, CRT_fp8.o or CRT_fp10.o for -mpc32, -mpc64 or -mpc80. They go in STARTFILE_SPEC so that they come before libmingw32.a. A DLL does not call _fpreset when it is loaded, so loading a DLL built with these options does not change the precision. Only fesetenv (FE_DFL_ENV) called from the DLL uses it. Unlike on Linux, a new thread on Windows does not inherit the x87 control word of the thread that created it. Threads created with pthread_create still get the setting, because winpthreads passes the creating thread's floating-point environment to new threads. Threads created with CreateThread or _beginthreadex start with the Windows default of 53-bit precision, as with MSVC. Document this. gcc/ChangeLog: * config/i386/mingw-w64.h (STARTFILE_SPEC): Link CRT_fp4.o, CRT_fp8.o or CRT_fp10.o for -mpc32, -mpc64 or -mpc80. * doc/invoke.texi (x86 Options): Describe -mpc32, -mpc64 and -mpc80 on MinGW targets. Signed-off-by: Peter Damianov <[email protected]>
Thanks, pushed to master branch.
