https://gitlab.winehq.org/wine/wine/-/merge_requests/7748#note_105461
huge thanks to @bernhardu for narrowing it down. does this work for you?
From: Daniel Lehman dlehman25@gmail.com
--- libs/musl/src/math/rint.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/libs/musl/src/math/rint.c b/libs/musl/src/math/rint.c index ad35201b266..4c5c011fd17 100644 --- a/libs/musl/src/math/rint.c +++ b/libs/musl/src/math/rint.c @@ -12,6 +12,9 @@ static const double_t toint = 1/EPS;
double __cdecl rint(double x) { +#if defined(__GNUC__) && defined(__i386__) + return __builtin_rint(x); +#endif union {double f; uint64_t i;} u = {x}; int e = u.i>>52 & 0x7ff; int s = u.i>>63;
huge thanks to @bernhardu for narrowing it down. does this work for you?
Hello, I checked to receive this failure with my development tree **without** your patch (gcc-mingw-oldwow64 32-bit) ``` wine dlls/d3dcompiler_42/tests/i386-windows/d3dcompiler_42_test.exe hlsl_d3d9 ... hlsl_d3d9.c:713: Test failed: Test 24: Got {0.00000000e+000, 5.00000000e-001, 0.00000000e+000, 0.00000000e+000}, expected {-1.54972076e-006, 4.99991417e-001, 0.00000000e+000, 0.00000000e+000}. ``` And after applying your patch the failure vanished. So yes, **with** your patch it works for me, thanks.
It will not work with other compilers as well. I would try doing something like: ```c if ((_control87(0, 0) & _MCW_PC) == _PC_24) toint = 1 / FLT_EPSILON; else toint = 1 / DBL_EPSILON; ``` It's not tested. If it doesn't work with 64-bit precision we will probably need to implement it without floating point operations (or set/restore precision around the function).
It will not work with other compilers as well
not sure what you mean. the failure is specific to 32-bit gcc - should the fix be free of #ifdef's?
I would try doing something like... It's not tested
will give that a try
or set/restore precision around the function
had tried something like that, based on MSVCRT_rint, that also works: https://gitlab.winehq.org/dlehman25/wine/-/commits/rint-cp would that be ok? (full build fails, but works if i rebuild musl + msvcrt + d3dcompiler_4*)
On Tue Jun 10 12:19:17 2025 +0000, Daniel Lehman wrote:
It will not work with other compilers as well
not sure what you mean. the failure is specific to 32-bit gcc - should the fix be free of #ifdef's?
I would try doing something like... It's not tested
will give that a try
or set/restore precision around the function
had tried something like that, based on MSVCRT_rint, that also works: https://gitlab.winehq.org/dlehman25/wine/-/commits/rint-cp would that be ok? (full build fails, but works if i rebuild musl + msvcrt + d3dcompiler_4*)
The code is not working if floating point operations are done with non 53-bit precision. Any compiler that uses x87 instructions will be affected.