status of gcc4 -ffast-math

View: New views
6 Messages — Rating Filter:   Alert me  

status of gcc4 -ffast-math

by Hans Horn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Folks,

what is the current status of -ffast-math for gcc4 under cygwin.

I tried to use it for some numerical C code and get the following link
errors:

eval.o:eval.c:(.text+0x79c): undefined reference to `_f_pow'
eval.o:eval.c:(.text+0x7d8): undefined reference to `_f_log'
eval.o:eval.c:(.text+0x7f0): undefined reference to `_f_exp'


Was not able to find the library where theses thingies live!

Thx.,
H.

P.S. before I forget:

$ gcc --version
gcc (GCC) 4.3.4 20090804 (release) 1

$ uname -a
CYGWIN_NT-5.1 HansHorn 1.7.0(0.217/5/3) 2009-11-03 15:06 i686 Cygwin


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: status of gcc4 -ffast-math

by Dave Korn-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hans Horn wrote:

> Folks,
>
> what is the current status of -ffast-math for gcc4 under cygwin.
>
> I tried to use it for some numerical C code and get the following link
> errors:
>
> eval.o:eval.c:(.text+0x79c): undefined reference to `_f_pow'
> eval.o:eval.c:(.text+0x7d8): undefined reference to `_f_log'
> eval.o:eval.c:(.text+0x7f0): undefined reference to `_f_exp'

  WJFFM:

> $ cat math.c
>
> #include <math.h>
>
> int main (int argc, const char **argv)
> {
>
>   float f = atof (argv[1]);
>   double d = log (f);
>   return exp (f);
> }
>
>
> admin@ubik /tmp/math
> $ gcc-4 math.c -o math
>
> admin@ubik /tmp/math
> $ gcc-4 math.c -o math -ffast-math
>
> admin@ubik /tmp/math
> $ gcc-4 math.c -o math -ffast-math -O2
>
> admin@ubik /tmp/math
> $ gcc-4 math.c -o math -ffast-math -O3
>
> admin@ubik /tmp/math
> $

  Perhaps a few more details about what you're doing, a simple reproducible
testcase, what kind of command-lines you're using, etc. etc... might help.

    cheers,
      DaveK


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: status of gcc4 -ffast-math

by Hans Horn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dave Korn wrote:

> Hans Horn wrote:
>> Folks,
>>
>> what is the current status of -ffast-math for gcc4 under cygwin.
>>
>> I tried to use it for some numerical C code and get the following link
>> errors:
>>
>> eval.o:eval.c:(.text+0x79c): undefined reference to `_f_pow'
>> eval.o:eval.c:(.text+0x7d8): undefined reference to `_f_log'
>> eval.o:eval.c:(.text+0x7f0): undefined reference to `_f_exp'
>
>   WJFFM:
>
>> $ cat math.c
>>
>> #include <math.h>
>>
>> int main (int argc, const char **argv)
>> {
>>
>>   float f = atof (argv[1]);
>>   double d = log (f);
>>   return exp (f);
>> }
>>
>>
>> admin@ubik /tmp/math
>> $ gcc-4 math.c -o math
>>
>> admin@ubik /tmp/math
>> $ gcc-4 math.c -o math -ffast-math
>>
>> admin@ubik /tmp/math
>> $ gcc-4 math.c -o math -ffast-math -O2
>>
>> admin@ubik /tmp/math
>> $ gcc-4 math.c -o math -ffast-math -O3
>>
>> admin@ubik /tmp/math
>> $
>
>   Perhaps a few more details about what you're doing, a simple reproducible
> testcase, what kind of command-lines you're using, etc. etc... might help.
>
>     cheers,
>       DaveK

Dave,

I was just shooting into the dark expecting more like a yes/no wrt use
of -ffast-math. Thx for responding!

I'm linking with gfortran (v4.5 or v4.3.4) (because the C code calls a
lot of fortran under the hood).

This is how I compile & link:

gcc-4 -c -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE -D_POSIX_SOURCE \
-std=c99 -Wall -Wshadow -Wreturn-type -Wunused \
-Wuninitialized -Wformat -Wunused-function -Wunused-macros
-Wunused-label -Wredundant-decls -fno-leading-underscore -O3 \
-fno-strict-aliasing -Winline -fexpensive-optimizations \
-finline-functions -finline-limit=500000 -fstrength-reduce -fgcse \
-fgcse-lm -fgcse-sm -funroll-loops -fforce-addr -fomit-frame-pointer \
-ftree-vectorize -mfpmath=sse -msse3 -ffast-math \
-march=pentium4 -pipe -fbounds-check -Wextra -Winit-self  \
-DYY_NO_UNISTD_H -o math.o math.c

gfortran -O3 -fno-strict-aliasing -Winline -fexpensive-optimizations \
-finline-functions -finline-limit=500000 \
-fstrength-reduce -fgcse -fgcse-lm -fgcse-sm -funroll-loops -fforce-addr
-fomit-frame-pointer -ftree-vectorize -mfpmath=sse \
-msse3 -ffast-math -march=pentium4 -pipe -L. -o math.exe math.o -Xlinker
-\( -O3 -fno-strict-aliasing -Winline -fexpensive-optimizations \
  -finline-functions -finline-limit=500000 -fstrength-reduce -fgcse
-fgcse-lm -fgcse-sm -funroll-loops -fforce-addr -fomit-frame-pointer \
  -ftree-vectorize -mfpmath=sse -msse3 -ffast-math -march=pentium4 -pipe
-lm -lgsl -ly -lfl --enable-auto-import -Xlinker -\)

Compiling/linking your example gives:

math.c: In function ‘main’:
math.c:4: warning: implicit declaration of function ‘atof’
math.c:5: warning: unused variable ‘d’
math.c:3: warning: unused parameter ‘argc’
math.o:math.c:(.text+0x30): undefined reference to `_f_exp'
collect2: ld returned 1 exit status

Do you where this gobble stuff ‘ comes from, btw?

H.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: status of gcc4 -ffast-math

by Hans Horn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hans Horn wrote:

> Dave Korn wrote:
>> Hans Horn wrote:
>>> Folks,
>>>
>>> what is the current status of -ffast-math for gcc4 under cygwin.
>>>
>>> I tried to use it for some numerical C code and get the following link
>>> errors:
>>>
>>> eval.o:eval.c:(.text+0x79c): undefined reference to `_f_pow'
>>> eval.o:eval.c:(.text+0x7d8): undefined reference to `_f_log'
>>> eval.o:eval.c:(.text+0x7f0): undefined reference to `_f_exp'
>>
>>   WJFFM:
>>
>>> $ cat math.c
>>>
>>> #include <math.h>
>>>
>>> int main (int argc, const char **argv)
>>> {
>>>
>>>   float f = atof (argv[1]);
>>>   double d = log (f);
>>>   return exp (f);
>>> }
>>>
>>>
>>> admin@ubik /tmp/math
>>> $ gcc-4 math.c -o math
>>>
>>> admin@ubik /tmp/math
>>> $ gcc-4 math.c -o math -ffast-math
>>>
>>> admin@ubik /tmp/math
>>> $ gcc-4 math.c -o math -ffast-math -O2
>>>
>>> admin@ubik /tmp/math
>>> $ gcc-4 math.c -o math -ffast-math -O3
>>>
>>> admin@ubik /tmp/math
>>> $
>>
>>   Perhaps a few more details about what you're doing, a simple
>> reproducible
>> testcase, what kind of command-lines you're using, etc. etc... might
>> help.
>>
>>     cheers,
>>       DaveK
>
> Dave,
>
> I was just shooting into the dark expecting more like a yes/no wrt use
> of -ffast-math. Thx for responding!
>
> I'm linking with gfortran (v4.5 or v4.3.4) (because the C code calls a
> lot of fortran under the hood).
>
> This is how I compile & link:
>
> gcc-4 -c -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE -D_POSIX_SOURCE \
> -std=c99 -Wall -Wshadow -Wreturn-type -Wunused \
> -Wuninitialized -Wformat -Wunused-function -Wunused-macros
> -Wunused-label -Wredundant-decls -fno-leading-underscore -O3 \
> -fno-strict-aliasing -Winline -fexpensive-optimizations \
> -finline-functions -finline-limit=500000 -fstrength-reduce -fgcse \
> -fgcse-lm -fgcse-sm -funroll-loops -fforce-addr -fomit-frame-pointer \
> -ftree-vectorize -mfpmath=sse -msse3 -ffast-math \
> -march=pentium4 -pipe -fbounds-check -Wextra -Winit-self  \
> -DYY_NO_UNISTD_H -o math.o math.c
>
> gfortran -O3 -fno-strict-aliasing -Winline -fexpensive-optimizations \
> -finline-functions -finline-limit=500000 \
> -fstrength-reduce -fgcse -fgcse-lm -fgcse-sm -funroll-loops -fforce-addr
> -fomit-frame-pointer -ftree-vectorize -mfpmath=sse \
> -msse3 -ffast-math -march=pentium4 -pipe -L. -o math.exe math.o -Xlinker
> -\( -O3 -fno-strict-aliasing -Winline -fexpensive-optimizations \
>  -finline-functions -finline-limit=500000 -fstrength-reduce -fgcse
> -fgcse-lm -fgcse-sm -funroll-loops -fforce-addr -fomit-frame-pointer \
>  -ftree-vectorize -mfpmath=sse -msse3 -ffast-math -march=pentium4 -pipe
> -lm -lgsl -ly -lfl --enable-auto-import -Xlinker -\)
>
> Compiling/linking your example gives:
>
> math.c: In function ‘main’:
> math.c:4: warning: implicit declaration of function ‘atof’
> math.c:5: warning: unused variable ‘d’
> math.c:3: warning: unused parameter ‘argc’
> math.o:math.c:(.text+0x30): undefined reference to `_f_exp'
> collect2: ld returned 1 exit status
>
> Do you where this gobble stuff ‘ comes from, btw?
>
> H.
>
>
Dave,

I just found the culprit!
It's -fno-leading-underscore.
Have to see whether I can live without it!

Thx. again


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: status of gcc4 -ffast-math

by Dave Korn-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hans Horn wrote:

>>
>> Do you where this gobble stuff ‘ comes from, btw?

  GCC is trying to use the appropriate set of internationalized opening and
closing single-quote marks.  If you "export LC_LANG=C.ASCII", you'll get
regular apostrophes.

> It's -fno-leading-underscore.
> Have to see whether I can live without it!

  You can't live *with* it.  Seriously, if you're using it in the first place,
you are doing something very very wrong indeed (like trying to link to
pre-compiled linux binaries) that you should not be doing, because neither it
nor anything else will work.  You will break every library and just
everything.  Sorry about that, but the decision to prefix symbols with an
underscore or not is part of the win32 ABI, not open to changing according to
a user's preferences, and frankly I don't think this option serves any useful
purpose except to break things and confuse people by giving them hope that
things might work that can in fact never succeed.

    cheers,
      DaveK


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: status of gcc4 -ffast-math

by Hans Horn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dave Korn wrote:

> Hans Horn wrote:
>
>>> Do you where this gobble stuff ‘ comes from, btw?
>
>   GCC is trying to use the appropriate set of internationalized opening and
> closing single-quote marks.  If you "export LC_LANG=C.ASCII", you'll get
> regular apostrophes.
>
>> It's -fno-leading-underscore.
>> Have to see whether I can live without it!
>
>   You can't live *with* it.  Seriously, if you're using it in the first place,
> you are doing something very very wrong indeed (like trying to link to
> pre-compiled linux binaries) that you should not be doing, because neither it
> nor anything else will work.  You will break every library and just
> everything.  Sorry about that, but the decision to prefix symbols with an
> underscore or not is part of the win32 ABI, not open to changing according to
> a user's preferences, and frankly I don't think this option serves any useful
> purpose except to break things and confuse people by giving them hope that
> things might work that can in fact never succeed.
>
>     cheers,
>       DaveK

Dave,

thx. for the clarification about the apostrophes!

As to -fno-leading-underscore: I had this in my cygwin gcc3.* makefiles
now for a couple of years (dunno where it originated).

Compiles & links fine without! It's gone down the crapper for good...
Now I'm one happy gcc4/gfortran guy!

Thanks again for your knowlegdable help!

H.






--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple