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

Joshua Cranmer via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 8 14:44:11 PST 2024


jcranmer-intel 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.

> I'm suggesting that we modify Clang so that -ffast-math doesn't affect denormal-fp-math, by (as I mentioned before) removing the overload [Linux::getDefaultDenormalModeForType](https://github.com/llvm/llvm-project/blob/d4c5acac99e83ffa12d2d720c9e502a181cbd7ea/clang/lib/Driver/ToolChains/Linux.cpp#L838). This makes Clang for Linux X86 and X86-64 work the same as every other OS/CPU combo.

That sounds to me ultimately like it should be a separate PR, although you're suggesting that should happen first?

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


More information about the cfe-commits mailing list