at the end of setup_flags() in the ebuilds, it says: # Lock glibc at -O2 -- linuxthreads needs it and we want to be # conservative here append-flags -O2 but for unstable users this doesn't work. It seems that the flags get shuffled by glibc's configure script. So if you have CFLAGS="-O3", the configure script logs that CFLAGS=-O3 -freorder-blocks -O2, but then (all?) objects are built with "-O2 -O3 -Wall -Winline -Wstrict-prototypes -Wwrite-strings -freorder-blocks -mpreferred-stack-boundary=2".
Portage 2.0.51-r8 (default-linux/x86/2004.3, gcc-3.4.3, glibc-2.3.4.20040808-r1, 2.6.10-gentoo-r3 i686) ================================================================= System uname: 2.6.10-gentoo-r3 i686 AMD Athlon(tm) XP 2100+ Gentoo Base System version 1.6.8 Python: dev-lang/python-2.3.4 [2.3.4 (#1, Jan 3 2005, 16:13:30)] distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled] ccache version 2.3 [enabled] dev-lang/python: 2.3.4 sys-devel/autoconf: 2.59-r6, 2.13 sys-devel/automake: 1.8.5-r2, 1.5, 1.4_p6, 1.6.3, 1.7.9, 1.9.3 sys-devel/binutils: 2.15.92.0.2-r2 sys-devel/libtool: 1.5.10-r2 virtual/os-headers: 2.6.8.1-r2 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CFLAGS="-march=athlon-xp -O2 -Os -fomit-frame-pointer -pipe" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-march=athlon-xp -O2 -Os -fomit-frame-pointer -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs autoconfig ccache distlocks sandbox sfperms userpriv" GENTOO_MIRRORS="http://mirror.datapipe.net/gentoo http://gentoo.mirrors.pair.com/ http://mirror.datapipe.net/gentoo http://mirrors.tds.net/gentoo http://gentoo.chem.wisc.edu/gentoo/ http://open-systems.ufl.edu/mirrors/gentoo" LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" SYNC="rsync://rsync.us.gentoo.org/gentoo-portage" USE="x86 3dnow X acpi adns alsa apache2 atlas berkdb bitmap-fonts bonobo bzlib crypt directfb dvd f77 fam fbcon fftw fortran gdbm gif gnome gpm gstreamer gtk gtk2 guile imlib java jpeg lesstif libwww maildir mime mmx mozilla moznoirc moznomail mpeg ncurses nptl nptlonly oggvorbis opengl oss pam pdflib perl pic png python quicktime readline real rtc sdl shared spell sse ssl tcpd tetex threads tiff truetype unicode usb userlocales xml xml2 xmms xprint xv zlib video_cards_radeon"
I don't think there is any problem with that. As far as i know, gcc chooses the smallest number of -O of all given numbers, so with -O3 -O2 the choosen number will be -O2, not -O3. You could even remove the append-flags -O2, the configure script would even then probably choose -O2.
Not true. From the gcc man page: "If you use multiple -O options, with or without level numbers, the last such option is the one that is effective."
gcc chooses the one listed last
I can confirm this problem. I have -Os in my CFLAGS and as you can see -O2 is appended but -Os is the optimization actually being used: x86_64-pc-linux-gnu-gcc gconv.c -c -std=gnu99 -O2 -Os -Wall -Winline -Wstrict-prototypes -Wwrite-strings -march=athlon64 -pipe -mpreferred-stack-boundary=2 -I../include -I. -I/var/tmp/portage/glibc-2.3.4.20050125-r1/work/build-x86-x86_64-pc-linux-gnu-nptl/iconv -I.. -I../libio -I../nptl -I/var/tmp/portage/glibc-2.3.4.20050125-r1/work/build-x86-x86_64-pc-linux-gnu-nptl -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../nptl/sysdeps/unix/sysv -I../nptl/sysdeps/unix -I../nptl/sysdeps/i386/i686 -I../nptl/sysdeps/i386 -I../libidn/sysdeps/unix -I../sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../sysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.3/include -isystem /usr/include -D_LIBC_REENTRANT -D_LIBC_REENTRANT -include ../include/libc-symbols.h -o /var/tmp/portage/glibc-2.3.4.20050125-r1/work/build-x86-x86_64-pc-linux-gnu-nptl/iconv/gconv.o -MD -MP -MF /var/tmp/portage/glibc-2.3.4.20050125-r1/work/build-x86-x86_64-pc-linux-gnu-nptl/iconv/gconv.o.dt -MT /var/tmp/portage/glibc-2.3.4.20050125-r1/work/build-x86-x86_64-pc-linux-gnu-nptl/iconv/gconv.o Changing the line "append-flags -O2" to "replace-flags -O* -O2" in the ebuild fixes it.
added 'filter-flags -O?' to the 2.3.5 ebuilds before we append -O2