GCC's -ffast-math behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Hi, all

There is something with -ffast-math I don't understand.

I want to know why gcc don't use other math lib when using -ffast-math.

    Take the test.c for example,

       gcc -O3 -c test.c -o test1.o
       nm test1.o  shows:
------------------------
00000000 b .bss
00000000 d .data
00000000 i .drectve
00000000 r .eh_frame
00000000 r .rdata
00000000 t .text
00000000 t .text.startup
         U ___main
         U _exp
00000000 D _in
00000000 T _main
00000080 C _out
         U _printf
------------------------

       gcc -O3 -ffast-math -c test.c -o test2.o
       nm test.2.o shows:
------------------------
00000000 b .bss
00000000 d .data
00000000 i .drectve
00000000 r .eh_frame
00000000 r .rdata
00000000 t .text
00000000 t .text.startup
         U ___main
00000000 D _in
00000000 T _main
00000080 C _out
         U _printf
------------------------

When using -ffast-math, gcc don't generate the math function symbol: U _exp

That causes the problem: if I have other optimization math lib (such as Intel Math Lib), gcc can't link the obj with the lib, but when no using -ffast-math, the lib can be linked with.

So I want to know: are there some methods when using -ffast-math, I also can link it with the optimization math lib?

             Many thanks.

--
Best Regards,
xunxun

#include <math.h>
#include <stdio.h>

#define N 16

double in[N] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0,
11.0, 12.0, 13.0, 14.0, 15.0, 16.0 };
double out[N];

int main ()
{
  int i;

  for (i = 0; i < N; i++)
    out[i] = exp (in[i]);

  for (i = 0; i < N; i++)
    printf ("%f\n", out[i]);

  return 0;
} 

[Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

Add to Google