-funsafe-math-optimizations effect on linking mkl
Segher Boessenkool
segher@kernel.crashing.org
Thu Jun 5 22:21:24 GMT 2025
On Thu, Jun 05, 2025 at 11:29:27PM +0200, Marc Glisse via Gcc-help wrote:
> On Thu, 5 Jun 2025, Nicola Giuliani via Gcc-help wrote:
>
> >What do you think of this particular problem? Does it make any sense to
> >you? Can you tell me how to recover the same behavior at linking time
> >without turning on the unsafe math optimizations?
>
> To understand what is going on, add -v to the compile line. This will show
> you how the linker (possibly called collect2 or ld) is invoked. Do it once
> with -funsafe-math-optimizations and once without. Look at the diff.
> Notice the addition of crtfastmath.o.
> (if motivated, look at the source
> https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/config/i386/crtfastmath.c;hb=HEAD
> )
The -ffast-math stuff is needed, because this compiler behaviour is
simply incorrect without that: by default we want the compiler to
generate code that does follow all relevant standards!
Segher
More information about the Gcc-help
mailing list