On Tuesday 20 October 2026 01:50:34 Peter Damianov wrote: > > Hello, I have few points for this change. > > > > - I'm not sure if it is a good idea to have different behavior for > > 32-bit and 64-bit x86 platforms. Would not it be better to have > > unified behavior across x86 and hence without that TLS callback? > > Yeah, that's reasonable, I guess. i686 is niche and this hack isn't really > worth it if we can't implement it properly on anything else.
Anyway, this would not be even very useful for older 32-bit only Windows platforms. Because for example Win9x do not implement PE TLS callbacks at all, these systems silently ignores them. > I'll drop it from v2. > > > > > - Functions CreateThread, _beginthread and _beginthreadex are defined by > > MS and Windows applications are mostly expecting how they are behaving > > when compiling by msvc. If some gcc switch changes them behavior, it > > is not something which Windows applications would expect. So in my > > opinion changing the behavior of floating point precision for newly > > spawned thread by those 3 MS functions should not be touched. > > I fully agree that fixing this for pthreads makes sense and should be > > done. > > That's a better argument than anything I can come up with for keeping it. > > > > > - The above TLS registration would not work when compiling with > > -Wl,--gc-sections (GNU LD will garbage collect above code). > > FYI I tried this and it doesn't seem to be true. The method seems to work. > I think it's because the default linker script wraps TLS callbacks > in `KEEP (*(SORT(.CRT$XL*)))` It is already fixed in binutils. But older binutils versions do not have this and is garbage collecting them. mingw-w64 recently got workaround for that. > > - mingw-w64 already provides object files fp8.o and fp10.o, like msvc > > compiler (which has fp10.obj), which are used for changing the x87 > > precision of exe applications. In mingw-w64 those object files > > provides the _fpreset function (which sets the precision based on > > chosen object file), which is begin called from mingw-w64 exe entry > > point. Also this _fpreset per MS documentation should be called from > > the SIGFPE signal handler (if being used for recovery). Also this > > function can be called manually. mingw-w64 chooses and links the > > fp10.o into every exe by default. > > > > That seems like it could work. I wasn't aware of them. Looks like this is > code inherited from the OG mingw. I wrote one mistake, those object files are called CRT_fp8.o and CRT_fp10.o. Obviously this was inherited from msvc itself which has fp10.obj file. > > - So this new crtprecXX.o objects files would mostly not work correctly > > and are in fight with mingw-w64 fp8.o/fp10.o object files. I would > > suggest to not compile and include gcc crtprecXX.o at all, and instead > > define that gcc's -mpc64/-mpc80 would link the mingw-w64 fp8.o/fp10.o > > object files. Maybe we can provide also fp4.o for -mpc32 completeness. > > That's fair. I suppose adding those would also work with clang which never > implemented these options. I think that manually specifying CRT_fp8.o or CRT_fp10.o should work also with clang. Just it would be needed to specify full path to those object files.
