$summary from build log: /tmp/portage/x11-libs/wxGTK-2.8.11.0/work/wxPython-src-2.8.11.0/wxgtk_build/bk-deps x86_64-pc-linux-gnu-g++ -c -o coredll_treebase.o -I./.pch/wxprec_coredll -D__WXGTK__ -DWXBUILDING -I/tmp/portage/x11-libs/wxGTK-2.8.11.0/work/wxPython-src-2.8.11.0/src/regex -DWXUSINGDLL -DWXMAKINGDLL_CORE -DwxUSE_BASE=0 -fPIC -DPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_IODBC_ -I/tmp/portage/x11-libs/wxGTK-2.8.11.0/work/wxPython-src-2.8.11.0/wxgtk_build/lib/wx/include/gtk2-unicode-release-2.8 -I/tmp/portage/x11-libs/wxGTK-2.8.11.0/work/wxPython-src-2.8.11.0/include -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng14 -I/usr/include/libdrm -pthread -DORBIT2=1 -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -DWX_PRECOMP -pthread -Wall -Wundef -Wno-ctor-dtor-privacy -O2 -fno-strict-aliasing -pthread -I/usr/include/libgnomeprintui-2.2 -I/usr/include/libgnomeprint-2.2 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/libart-2.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/gail-1.0 -I/usr/include/gtk-2.0 -I/usr/include/freetype2 -I/usr/include/atk-1.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pixman-1 -I/usr/include/libpng14 -I/usr/include/libdrm -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -march=native -O2 -g0 -fno-strict-aliasing /tmp/portage/x11-libs/wxGTK-2.8.11.0/work/wxPython-src-2.8.11.0/src/common/treebase.cpp so, there isn't problem, but CFLAGS="" emerge wxGTK produces: /tmp/portage/x11-libs/wxGTK-2.8.11.0/work/wxPython-src-2.8.11.0/wxgtk_build/bk-deps x86_64-pc-linux-gnu-gcc -c -o wxregex_regexec.o -D__WXGTK__ -fPIC -DPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_IODBC_ -I/tmp/portage/x11-libs/wxGTK-2.8.11.0/work/wxPython-src-2.8.11.0/wxgtk_build/lib/wx/include/gtk2-unicode-release-2.8 -I/tmp/portage/x11-libs/wxGTK-2.8.11.0/work/wxPython-src-2.8.11.0/include -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng14 -I/usr/include/libdrm -pthread -DORBIT2=1 -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -pthread -Wall -Wundef -O2 -fno-strict-aliasing -pthread -I/usr/include/libgnomeprintui-2.2 -I/usr/include/libgnomeprint-2.2 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/libart-2.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/gail-1.0 -I/usr/include/gtk-2.0 -I/usr/include/freetype2 -I/usr/include/atk-1.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pixman-1 -I/usr/include/libpng14 -I/usr/include/libdrm -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -fno-strict-aliasing /tmp/portage/x11-libs/wxGTK-2.8.11.0/work/wxPython-src-2.8.11.0/src/regex/regexec.c and -O2 is added. Simple sed fix this issue and works for me: sed -i 's/-O2//g' configure
If you don't set CFLAGS then the package is free to set them itself. It's only a bug if it overwrites them.
is not invalid for me. Why if i set cflags to ="" it should be compiled with -O2 ?
Packages need to respect user CFLAGS, but if you don't give any then it should use sane defaults. A lot of software won't build with -O0.