[clang] Disable FTZ/DAZ when compiling shared libraries by default. (PR #80475)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 8 15:12:58 PST 2024


andykaylor wrote:

> > I'd like to see this change land, but with the "-mdaz-ftz" option removed (because I don't think it's useful). That would fix the critical problem of fast-math infecting shared libraries with the ftz setting, and we could straighten out the other problems, which are relatively minor, afterwards.
> 
> There is, without this change, no way to control whether or not `crtfastmath.o` is linked independent of all of the other fast-math options. The `-mdaz-ftz` option would at least add a flag to explicitly control the parameter (for the people who care), and we can then have discussions about different ways to effect setting DAZ/FTZ bits or what options imply `-mdaz-ftz` in future PRs. That alone makes it a worthy addition IMHO; the compatibility with gcc is another nice feature.

You can always link crtfastmath.o directly, of course. Ultimately, I don't think the compiler should ever be adding the crtfastmath.o file. I would prefer to insert code directly into the entry function as @arsenm indicated the AMDGPU backend does for kernels. That would then be controlled by the -fdenormal-fp-math option or something more explicitly linked to the entry function.

I don't want to add -mdaz-ftz because once we do we're kind of stuck with it. If you don't add it here, we'd continue the current behavior of linking with crtfastmath.o normally but we'd stop infecting shared libraries with it.

https://github.com/llvm/llvm-project/pull/80475


More information about the cfe-commits mailing list