Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 142893 - sys-devel/gettext-0.15 fails when CFLAGS contains -ffast-math and LDFLAGS -Wl,--as-needed
Summary: sys-devel/gettext-0.15 fails when CFLAGS contains -ffast-math and LDFLAGS -W...
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
: 148878 189414 (view as bug list)
Depends on:
Blocks: as-needed
  Show dependency tree
 
Reported: 2006-08-05 09:23 UTC by Petteri Räty (RETIRED)
Modified: 2008-10-26 06:11 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to check for "mfpmath" and "ffast-math" and enable "-lm" (gettext-0.15.ebuild.patch,635 bytes, patch)
2006-09-25 00:56 UTC, Mark Dominik Bürkle
Details | Diff
results of all permutations, flag-sorted/uniq (flag-permutations-results.flag-sorted.uniq,8.33 KB, application/octet-stream)
2006-09-27 03:36 UTC, Mark Dominik Bürkle
Details
results of all permutations, stripped "-march=pentium4" and "-pipe", flag-sorted/uniq (flag-permutations-results.no-stdflags.flag-sorted.uniq,5.70 KB, text/plain)
2006-10-11 12:42 UTC, Mark Dominik Bürkle
Details
complete compilation test results -- gzipped. (flag-permutations-results.gz,39.54 KB, application/gzip)
2006-10-11 12:44 UTC, Mark Dominik Bürkle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petteri Räty (RETIRED) gentoo-dev 2006-08-05 09:23:56 UTC
i686-pc-linux-gnu-gcc -O2 -march=pentium4 -pipe -mfpmath=sse -ffast-math -fomit-frame-pointer -Wl,--as-needed -o .libs/msgmerge msgmerge-msgmerge.o msgmerge-msgl-fsearch.o msgmerge-plural-count.o  ./.libs/libgettextsrc.so /var/tmp/portage/gettext-0.15/work/gettext-0.15/gettext-tools/lib/.libs/libgettextlib.so -lc
msgmerge-msgl-fsearch.o: In function `message_fuzzy_index_search':
msgl-fsearch.c:(.text+0x149): undefined reference to `ceil'
collect2: ld returned 1 exit status
make[4]: *** [msgmerge] Error 1
make[4]: Leaving directory `/var/tmp/portage/gettext-0.15/work/gettext-0.15/gettext-tools/src'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/var/tmp/portage/gettext-0.15/work/gettext-0.15/gettext-tools/src'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/var/tmp/portage/gettext-0.15/work/gettext-0.15/gettext-tools'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/var/tmp/portage/gettext-0.15/work/gettext-0.15/gettext-tools'
make: *** [all-recursive] Error 1

!!! ERROR: sys-devel/gettext-0.15 failed.
Call stack:
  ebuild.sh, line 1543:   Called dyn_compile
  ebuild.sh, line 938:   Called src_compile
  gettext-0.15.ebuild, line 68:   Called die

!!! (no error message)
!!! If you need support, post the topmost build error, and the call stack if relevant.

The cause for this is that -lm is not in the arguments. It is detected with the following code in configure.ac:

MSGMERGE_LIBM=?
AC_TRY_LINK([#include <math.h>], [static double x; x = ceil(x); x = sqrt(x);],
  [MSGMERGE_LIBM=])
if test "$MSGMERGE_LIBM" = "?"; then
  save_LIBS="$LIBS"
  LIBS="$LIBS -lm"
  AC_TRY_LINK([#include <math.h>], [static double x; x = ceil(x); x = sqrt(x);],
    [MSGMERGE_LIBM="-lm"])
  LIBS="$save_LIBS"
fi
if test "$MSGMERGE_LIBM" = "?"; then
  MSGMERGE_LIBM=
fi
AC_SUBST([MSGMERGE_LIBM])

The problem here is this code links properly when using -ffast-math without libm.so but when it comes to the actual code, for some reason ceil is not usable there without libm.so and in this -Wl,--as-needed seems to be playing some part because the following worked fine:
LDFLAGS="" CFLAGS="-pipe -ffast-math" ebuild gettext-0.15.ebuild clean install

Maybe someone more familiar with this like flameeyes is able to shed some light on this. Don't know if -ffast-math is really even that useful but is has been in my CFLAGS for ages. 

betelgeuse@pena ~/btdown $ emerge --info
Portage 2.1.1_pre4-r2 (default-linux/x86/2005.1, gcc-4.1.1/vanilla, glibc-2.4-r3, 2.6.17-gentoo-r4 i686)
=================================================================
System uname: 2.6.17-gentoo-r4 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz
Gentoo Base System version 1.12.4
distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.4 [disabled]
app-admin/eselect-compiler: 2.0.0_rc2-r1
dev-lang/python:     2.4.3-r1
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.4-r2
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.17
sys-devel/gcc-config: 2.0.0_rc1
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r5
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=pentium4 -pipe -mfpmath=sse -ffast-math -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/eselect/compiler /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/splash /etc/terminfo"
CXXFLAGS="-O2 -march=pentium4 -pipe -mfpmath=sse -ffast-math -fomit-frame-pointer"
DISTDIR="/var/distfiles"
FEATURES="autoaddcvs autoconfig collision-protect cvs distlocks fixpackages parallel-fetch sandbox sfperms sign strict stricter userpriv usersandbox verify-rdepend"
GENTOO_MIRRORS=" http://trumpetti.atm.tut.fi/gentoo  http://lame.lut.fi/linux/gentoo "
LANG="en_US.utf8"
LC_ALL="en_US.utf8"
LDFLAGS="-Wl,--as-needed"
LINGUAS="fi"
MAKEOPTS="-j2 -s"
PKGDIR="/home/pkg/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/mnt/checkouts/overlays/betelgeuse"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 aac acl acpi alsa apm arts audiofile avi bash-completion berkdb bitmap-fonts bluetooth bzip2 bzlib cairo cdb cddb cdparanoia cli crypt cups dbus divx4linux dlloader dri dts dvd dvdr dvdread emboss esd ffmpeg firefox foomaticdb freetype gif gstreamer gtk2 hal isdnlog java jpeg kde kdeenablefinal kdehiddenvisibility libg++ libwww logitech-mouse mad makecheck mikmod mjpeg mmx mmx2 mp3 mpeg ncurses network nptl nptlonly nsplugin nvidia offensive ogg oggvorbis opengl pam pcre pdflib png pppd qt qt3 quicktime readline real reflection rtc samba session spell spl sse sse2 ssl subversion svg symlink tcpd theora threads truetype truetype-fonts type1-fonts udev unicode usb userlocales vorbis win32codecs xcomposite xml xml2 xorg xv xvid zlib elibc_glibc input_devices_mouse input_devices_keyboard kernel_linux linguas_fi userland_GNU video_cards_none video_cards_nvidia"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 SpanKY gentoo-dev 2006-08-05 15:50:37 UTC
-ffast-math on x86 provides inlined versions for a bunch of math functions

in this case, i'm unable to reproduce the issue ... building gettext-tools with -ffasth-math -Wl,--as-needed works fine

not that -Wl,--as-needed should have anything to do with it as msgl-fsearch.c is compiled with a reference to ceil

on my machine:
$ readelf -s gettext-tools/src/msgmerge-msgl-fsearch.o | grep ceil
Comment 2 Petteri Räty (RETIRED) gentoo-dev 2006-08-06 04:07:17 UTC
(In reply to comment #1)
> 
> on my machine:
> $ readelf -s gettext-tools/src/msgmerge-msgl-fsearch.o | grep ceil
> 

pena gettext-0.15 # find -name "msgmerge-msgl-fsearch.o" | xargs readelf -s | grep ceil
    15: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND ceil

pena gettext-0.15 # emerge -pv gettext

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] sys-devel/gettext-0.15  USE="-doc -emacs -nls -nocxx" 0 kB
Comment 3 SpanKY gentoo-dev 2006-08-06 09:02:34 UTC
then make sure the file was compiled with your CFLAGS
Comment 4 Joe Kappus 2006-08-19 22:16:04 UTC
confirming -ffast-math broke it for me as well in the same way.  LDFLAGS had no effect.

Portage 2.1.1_pre5-r2 (default-linux/x86/2006.0, gcc-4.1.1, glibc-2.4-r3, 2.6.17-no5 i686)
=================================================================
System uname: 2.6.17-no5 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz
Gentoo Base System version 1.12.4
Last Sync: Sun, 20 Aug 2006 03:30:07 +0000
ccache version 2.4 [disabled]
app-admin/eselect-compiler: [Not Present]
dev-lang/python:     2.4.3-r1
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.4-r2
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.17
sys-devel/gcc-config: 1.3.13-r3
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -O2 -mfpmath=sse -ffast-math -ftracer -fomit-frame-pointer -fweb -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/lib/X11/xkb /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/eselect/compiler /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-march=pentium4 -O2 -mfpmath=sse -ffast-math -ftracer -fomit-frame-pointer -fweb -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LDFLAGS="-Wl,-O1 -Wl,--sort-common"
LINGUAS="en"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage /usr/local/trunk"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 X a52 aac alsa amr avi bitmap-fonts bmpx bzip2 cairo cdparanoia cdr chroot cli crypt css cups curl dbus dlloader dri dts dvd dvdr elibc_glibc emboss encode fbcon ffmpeg flac foomaticdb fortran gdbm gif glibc-omitfp glitz gpm gstreamer gtk gtk2 imlib input_devices_keyboard input_devices_mouse irssi isdnlog ithreads jack java javascript jpeg kde kdeenablefinal kernel_linux libwww linguas_en mad maildir matroska mmx motif mozilla mozinterfaceinfo mozp3p mozsvg mp3 mpeg mplayer ncurses no-old-linux nptl nptlonly nsplugin nvidia ogg opengl pam pdf pdflib perl pic png ppds pppd python qt3 qt4 quicktime readline real reflection rtc sdl session spell spl sse sse2 ssl theora threads tiff truetype truetype-fonts type1-fonts udev usb userland_GNU userlocales video_cards_nv video_cards_vesa visualization vorbis x264 xchat xine xml xorg xscreensaver xv xvid xvmc zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_RSYNC_EXTRA_OPTS
Comment 5 Maxime G. 2006-09-02 16:56:51 UTC
Here: 
with -mfpmath=sse: compile fine
with -ffast-math: compile fine
with -mfpmath=sse -ffast-math: wont compile

emerge --info:
Portage 2.1.1_rc1-r2 (default-linux/x86/2006.0, gcc-4.1.1, glibc-2.4-r3, 2.6.17-gentoo-r7 i686)
=================================================================
System uname: 2.6.17-gentoo-r7 i686 Intel(R) Pentium(R) 4 CPU 2.20GHz
Gentoo Base System version 1.12.4
Last Sync: Thu, 31 Aug 2006 10:50:01 +0000
app-admin/eselect-compiler: [Not Present]
dev-lang/python:     2.4.3-r3
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.17
sys-devel/gcc-config: 1.3.13-r3
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O3 -march=pentium4 -mtune=pentium4 -ftracer -fomit-frame-pointer -ffast-math -mfpmath=sse -ftree-vectorize -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/splash /etc/terminfo /etc/texmf/web2c"
CXXFLAGS="-O3 -march=pentium4 -mtune=pentium4 -ftracer -fomit-frame-pointer -ffast-math -mfpmath=sse -ftree-vectorize -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/ ftp://ftp.free.fr/mirrors/ftp.gentoo.org/"
LANG="fr"
LC_ALL="fr_FR.utf8"
LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -s"
LINGUAS="fr"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.belnet.be/gentoo-portage/"
USE="x86 X a52 aac alsa apache2 arts asf avi bash-completion berkdb bitmap-fonts bzip2 cjk cli crypt css cups curl dbus dlloader dvd dvdr dvdread eds elibc_glibc emboss encode exif fam ffmpeg flac foomaticdb fortran gdbm gif glitz gphoto2 hal imagemagick imlib input_devices_keyboard input_devices_mouse isdnlog java jpeg kde kdeenablefinal kdehiddenvisibility kernel_linux libg++ libwww linguas_fr mad matroska mikmod mmx mmxext motif mp3 mp4 mpeg musepack musicbrainz ncurses nls nptl nptlonly ntpl nvidia offensive ogg openal opengl pam pcre pdflib perl png pppd python qt3 quicktime readline real reflection sdl session spell spl sqlite sse sse2 ssl svg tcpd tetex theora truetype truetype-fonts type1-fonts udev unicode usb userland_GNU userlocales video_cards_nv video_cards_nvidia vorbis win32codecs x264 xcomposite xine xml xorg xsl xv xvid zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_RSYNC_EXTRA_OPTS
 
Comment 6 David Li 2006-09-12 15:09:36 UTC
I confirm comment #5, it's a combination of -mfpmath=sse and -ffast-math that causes the problem.
Comment 7 Jakub Moc (RETIRED) gentoo-dev 2006-09-24 00:16:44 UTC
*** Bug 148878 has been marked as a duplicate of this bug. ***
Comment 8 Mark Dominik Bürkle 2006-09-25 00:56:31 UTC
Created attachment 97998 [details, diff]
patch to check for "mfpmath" and "ffast-math" and enable "-lm"

# diff -wu /usr/portage/sys-devel/gettext/gettext-0.15.ebuild /usr/local/portage/sys-devel/gettext/gettext-0.15.ebuild
--- /usr/portage/sys-devel/gettext/gettext-0.15.ebuild  2006-09-23 19:06:27.000000000 +0200
+++ /usr/local/portage/sys-devel/gettext/gettext-0.15.ebuild    2006-09-25 09:34:20.000000000 +0200
@@ -53,9 +53,14 @@
        if use elibc_glibc ; then
                myconf="${myconf} --without-included-gettext $(use_enable nls)"
        else
-               myconf="${myconf} --with-included-gettext --enable-nls"
+               myconf="${myconf} --with-included-gettext $(use_enable nls)"
        fi
        use nocxx && export CXX=$(tc-getCC)
+
+       if [[ -n $(get-flag mfpmath) && -n $(get-flag ffast-math) ]] ; then
+        append-ldflags -lm
+       fi
+
        econf \
                $(use_with emacs) \
                --disable-java \
#
Comment 9 Jakub Moc (RETIRED) gentoo-dev 2006-09-25 01:06:02 UTC
*** Bug 148878 has been marked as a duplicate of this bug. ***
Comment 10 Mark Dominik Bürkle 2006-09-25 01:17:43 UTC
Bug#148878 resolved to test-request with a reference to attachment#97998 [details, diff]
Comment 11 Jakub Moc (RETIRED) gentoo-dev 2006-09-25 01:48:09 UTC
*** Bug 148878 has been marked as a duplicate of this bug. ***
Comment 12 SpanKY gentoo-dev 2006-09-25 06:37:46 UTC
Comment on attachment 97998 [details, diff]
patch to check for "mfpmath" and "ffast-math" and enable "-lm"

find & fix the root cause
Comment 13 Mark Dominik Bürkle 2006-09-25 08:29:49 UTC
The root cause?

One cause might be found in the configure-Skripts (ie. autoconf) as it is not detecting that "-lm" is needed.

Another cause might be found in gcc-4.1.1 not providing an inline for ceil()...
Comment 14 Mark Dominik Bürkle 2006-09-26 04:18:27 UTC
$ cat test-ceil.c                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         #include <stdio.h>                                                                                                                                                                                                                                                                                                                                                                                                                   #include <stdlib.h>
#include <math.h>                                                                                                                                                                                                                                                                                                                                                                                                                    

int main( int argc, char** argv ) {

  float fval = 1.5;
  double dval = 2.5;
  long double lval = 3.5;

  switch(argc){
  case 3:
      lval = atof( argv[3] );
  case 2:
      dval = atof( argv[2] );
  case 1:
      fval = atof( argv[1] );
  case 0:
      break;
  default:
      lval = atof( argv[3] );
      dval = atof( argv[2] );
      fval = atof( argv[1] );
  }

  fval = ceil( fval );
  dval = ceil( dval );
  lval = ceil( lval );

  return ( printf( "float: %3.1f double: %3.1lf longdouble: %3.1Lf\n", fval, dval, lval ) == 0);

}
$ rm -f test-ceil; CC="/usr/i686-pc-linux-gnu/gcc-bin/3.4.6/gcc" CFLAGS="-march=pentium4 -mmmx -msse -msse2 -mfpmath=sse -O3 -fomit-frame-pointer -ffast-math -pipe" make test-ceil && ./test-ceil 1.1 4.5 7.9 || echo $?
/usr/i686-pc-linux-gnu/gcc-bin/3.4.6/gcc -march=pentium4 -mmmx -msse -msse2 -mfpmath=sse -O3 -fomit-frame-pointer -ffast-math -pipe    test-ceil.c   -o test-ceil
float: 2.0 double: 5.0 longdouble: 8.0
$ rm -f test-ceil; CC="/usr/i686-pc-linux-gnu/gcc-bin/4.1.1/gcc" CFLAGS="-march=pentium4 -mmmx -msse -msse2 -mfpmath=sse -O3 -fomit-frame-pointer -ffast-math -pipe" make test-ceil && ./test-ceil 1.1 4.5 7.9 || echo $?
/usr/i686-pc-linux-gnu/gcc-bin/4.1.1/gcc -march=pentium4 -mmmx -msse -msse2 -mfpmath=sse -O3 -fomit-frame-pointer -ffast-math -pipe    test-ceil.c   -o test-ceil
/tmp/cc2rAdwa.o: In function `main':
test-ceil.c:(.text+0xf1): undefined reference to `ceilf'
collect2: ld returned 1 exit status
make: *** [test-ceil] Error 1
2
$

So, basically, the ebuild could check for the compiler-version and add "-lm". :-)

But lets try to further drill down to cure the cause and not - the symptoms!

Just to make sure:
simple permutations of my CFLAGS (keeping -march= and -pipe) are about 5.000, all permutations (more or less flags) are about 13.000, which I'm currently testing:

#!/usr/bin/perl -w
  use strict;
  use List::Permutor;
  my $perm = new List::Permutor qw/ -mmmx -msse -msse2 -mfpmath=sse -O3 -fomit-frame-pointer -ffast-math /;
  my @list;
  while (my @set = $perm->next) {
    push( @list, join( " ", @set ) );
  };
  my @prevwords = ( "", "", "", "", "", "", "" );
  foreach my $line (sort( @list )) {
    my @words = split( " ", $line );
    for my $i (1 .. scalar( @words )) {
      $i -= 1;
      if (@prevwords[$i] ne @words[$i]) {
        print join( " ", @words[0 .. $i] ) . "\n";
        @prevwords[$i] = @words[$i];
        @prevwords[$i+1 .. scalar( @prevwords )] = ( "", "", "", "", "", "", "" )[1 .. scalar( @prevwords ) - $i];
      }
    }
  }
> /tmp/flag-permutations
baseflags="-march=pentium4 -pipe"; while read flags; do rm -f test-ceil; flags="$baseflags $flags"; echo -n "$flags: "; CC="/usr/i686-pc-linux-gnu/gcc-bin/4.1.1/gcc" CFLAGS="$flags" make test-ceil &>/dev/null && echo "OK" || echo "FAILURE"; done < /tmp/flag-permutations  > /tmp/flag-permutations-results &

My first impression is that "-mfpmath=sse" is the bad thing - not "-ffast-math".
Comment 15 Mark Dominik Bürkle 2006-09-27 03:36:45 UTC
Created attachment 98210 [details]
results of all permutations, flag-sorted/uniq

Full results on request (I don't expect anyone to be interested in that).

All flag combinations that resulted in successful compilation contained ffast-math.

From the ggc-docs:
>>>
-ffast-math
    Sets -fno-math-errno, -funsafe-math-optimizations,
    -fno-trapping-math, -ffinite-math-only, -fno-rounding-math, -fno-signaling-nans and fcx-limited-range.
<<<
 I started reading the doc for those flags, yesterday, but I see no reason why any other than fno-rounding-math would help in compiling ceil() code correctly.
 ffast-math is not that bad, but I think I'll replace it by some choice of other flags, once my "emerge -e world" completed.

The results are still not clear to me (see following attachment), except that:

 - none of the ok-results contains mfpmath=sse
 - any of march=pentium4, mfpmath=sse, mmmx, msse, msse2 without ffast-math make the compilation fail
 - fails with ffast-math and any two of mmmx, msse, msse2

I have to check out what -march=pentium4 (=> +mmmx +msse +msse2, iirc) enables. About mpfmath=sse from gcc docs:
>>>
For the i386 compiler, you need to use -march=cpu-type, -msse or -msse2 switches to enable SSE extensions and make this option effective. For the x86-64 compiler, these extensions are enabled by default.
<<<
=> either this problem does not exist in the x86-64 compiler (I currently have no machine to check this out, no time to set up cross-compiling) or it will hit x86-64 users.
Comment 16 Sheldon Hearn 2006-10-08 10:37:18 UTC
So in the meantime, perhaps gettext-0.15 should be marked ~x86 again?  This is breaking "emerge -Du world" for some x86 users, since the following are not uncommon optimisations:

-march=pentium4m -mfpmath=sse -ffast-math
Comment 17 SpanKY gentoo-dev 2006-10-08 11:23:02 UTC
not a chance

if you're using -ffast-math in global CFLAGS then it's your own fault
Comment 18 Mark Dominik Bürkle 2006-10-11 12:40:46 UTC
Hi SpanKY,

I fully endorse Your repudiation of -ffast-math.

I've put it into my CFLAGS a long time ago. I was following the advise of a respective collegue who is a good coder and also a Gentoo dev - and he was using Gentoo a long time before I started
Of course I took the freedom and chose to modify USE, CFLAGS and FEATURES from the very first bootstrap on - made some nice experiences and finally got it to work. ;-) Though I enjoy experimenting, even if it hurts, a certain degree of persuasion was necessary to make me include "-ffast-math".


I didn't (and probably won't) have the time to check what

 -O3
 -march=pentium4

really do.
Does "O3" include "ffast-math"?
"march=pentium4" enables at least some of "msse", "msse2" and "mmmx".

Please note that the following (IMHO quite simple) flag combinations were enough to kill the build of my test program when using gcc-4.1.1:

      1 -O3 -march=pentium4 -pipe
      1 -fomit-frame-pointer -march=pentium4 -pipe
      1 -march=pentium4 -mfpmath=sse -pipe
      1 -march=pentium4 -mmmx -pipe
      1 -march=pentium4 -msse -pipe
      1 -march=pentium4 -msse2 -pipe
      2 -march=pentium4 -mfpmath=sse -mmmx -pipe
      2 -march=pentium4 -mfpmath=sse -msse -pipe
      2 -march=pentium4 -mfpmath=sse -msse2 -pipe
      2 -march=pentium4 -mmmx -msse -pipe
      2 -march=pentium4 -mmmx -msse2 -pipe
      2 -march=pentium4 -msse -msse2 -pipe

while including "ffast-math" seemed at least to help building in some of those cases:

      1 -ffast-math -march=pentium4 -pipe
      2 -O3 -ffast-math -march=pentium4 -pipe
      2 -ffast-math -fomit-frame-pointer -march=pentium4 -pipe
      2 -ffast-math -march=pentium4 -mmmx -pipe
      2 -ffast-math -march=pentium4 -msse -pipe
      2 -ffast-math -march=pentium4 -msse2 -pipe


I don't have time to complete my investigations in this Bug, and I'll attach the complete result list ("to whom it may concern";-) and another "flag-sorted" List of OK/FAILURE results without the always-included "march=pentium4" and "pipe" flags, for better readability.


As "-O3" seems to have a bad influence, at least regarding the compilation tests and my "emerge -e system && emerge -e world" completed, I reduced my CFLAGS to

    CFLAGS="-march=pentium4 -mmmx -msse -msse2 -O2 -mfpmath=sse -fomit-frame-pointer -pipe"

which made no problems at the following "emerge -e system && emerge -e world" - even OO compiled without problems (IIRC;-).

Kind regards,
Dominik
Comment 19 Mark Dominik Bürkle 2006-10-11 12:42:37 UTC
Created attachment 99382 [details]
results of all permutations, stripped "-march=pentium4" and "-pipe", flag-sorted/uniq

for the interested reader. ;-)
Comment 20 Mark Dominik Bürkle 2006-10-11 12:44:29 UTC
Created attachment 99383 [details]
complete compilation test results -- gzipped.
Comment 21 SpanKY gentoo-dev 2006-10-12 15:20:37 UTC
> I didn't (and probably won't) have the time to check what

read `man gcc`, it'll tell you
Comment 22 Nickolas Grigoriadis 2006-11-08 05:16:12 UTC
-mno-ieee-fp

Also causes the exact same issue (I don't have -ffast-math or -mfpmasth=sse, but do specify -march=pentium-m )

Removing said flag gettext builds fine
Comment 23 Michael Kefeder 2007-01-14 00:24:52 UTC
I too confirm this bug. took me quite a while to find this bugzilla entry, because i never thought about looking at here ;) not finding "ceil" made me think about -lm missing, glibc beeing messed up and whatnot...

I agree that having -ffast-math in global CFLAGS is maybe too aggressive, but as someone else pointed out, those flags lurk there from the first day of install, in my case 2 years ago and never did any harm. Maybe the ebuild for gettext should simply whipe the whole CFLAGS options and install w/o any user optimisations. rtorrent has a similar issue with gcc 4.1, it builds but it segfaults on loading torrent files when compiled with anything beyond -O0 (-O2 or -O3 would trigger the bug) - and nobody said afterwards remove the -O flag from your make.conf, the ebuild simply overrides the CFLAGS to a useful setting - which, in my opinion, is exactly what the gettext ebuild should do (until the root of this problem is found and fixed).
Comment 24 SpanKY gentoo-dev 2007-01-14 05:16:26 UTC
no, gettext is not going to touch CFLAGS
Comment 25 Michael Kefeder 2007-01-14 10:24:45 UTC
I don't understand why it wont touch cflags, but I guess I have to accept it. 

A fix for people that want to use aggressive global CFLAGS that virtually work for any package but a few that refuse to fiddle with flags should create /etc/portage/env/sys-devel/gettext with following content

CFLAGS="-march=pentium4 -Os"
CXXFLAGS="-march=pentium4 -Os"

or some other conservative CFLAGS. This will overwrite the build environment for specific packages or groups of packages (format: /etc/portage/env/<group>/<package>[-<version>]). You could also set FEATURES and other stuff of make.conf in there. Maybe this env/ dir is common knowledge, but i didn't know it until today, i hope this information helps others with similiar issues.
Comment 26 Roderick van Domburg 2007-04-11 21:50:56 UTC
Issue remains on gettext-0.16.1.

In the entire -ffast-math or not discussion, it's interesting to see that AMD actually recommends that CFLAG in their Compiler Usage Guidelines over at http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/32035.pdf. I was following these recommendations, and I reckon I won't be the only one.
Comment 27 Dawid Węgliński (RETIRED) gentoo-dev 2007-08-18 23:32:40 UTC
*** Bug 189414 has been marked as a duplicate of this bug. ***
Comment 28 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2008-10-14 10:01:49 UTC
vapier: why can't we just have strip-flags -ffast-math -mno-ieee-fp?
Comment 29 SpanKY gentoo-dev 2008-10-26 06:11:54 UTC
a quick scan shows me there's nothing that actually needs to change.  you should never use -ffast-math in global CFLAGS.  if you do, then it's your own fault when things blow up.