- To: gcc-help@xxxxxxxxxxx
- Subject: GCC's -ffast-math behavior
- From: xunxun <xunxun1982@xxxxxxxxx>
- Date: Thu, 09 Feb 2012 16:33:17 +0800
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1329381228; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=EuyU53/ M/nkEFkI+9BCFDX8xyYk=; b=QVUVpB3pbghPtN2wv7mU41X6FHwG3FQPGE62sxF pilNd+URi5ntKF7gyAKxXERe5Aw8/lCm6nLLbR18qdy5g0guhQsFnuWmZ9t8K1/1 4ufDzhHYm7rbyOCWC9097+1ncXH2wQW00dDaDV6qSJiVLPP0B8tnwFiY744XZWk+ BIpw=
- User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20120129 Thunderbird/10.0
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]