If you specify the flags that -march=native represents to make GCC skip its internal checks for optimal compilation flags each time it is invoked and run emerge -l =sys-libs/libstdc++-v3-3.3.6 while the nls USE flag is in use, the package will fail to build, citing issues with the C++ compiler: checking for object suffix... configure: error: installation or configuration problem; compiler does not work Compiling via the following command will work on my system: CFLAGS="-O2 -pipe -march=native" CPPFLAGS="-O2 -pipe -march=native" CXXFLAGS="-O2 -pipe -march=native" emerge -1 =sys-libs/libstdc++-v3-3.3.6 It appears that the -march=native flag is being stripped by the build. Those such as myself that specify the flags that -march=native represents on our systems to avoid having GCC's detection logic run on every invocation have the ebuild fail because the ebuild fails to strip the equivalent CFLAGS, although I do not understand why -march=native must be stripped in the first place (a bug perhaps?). Explicitly using the flags into which -march=native translates is something that yngwin specifically recommended doing on the Gentoo forums: http://forums.gentoo.org/viewtopic-t-821370-start-25.html#6230128 KernelofTruth on the Gentoo Forums encountered this issue when GCC 4.3.0 debuted and reported the issue with the CFLAGS, which allowed me to confirm that the ebuild did dislike the CFLAGS in use on my system. http://forums.gentoo.org/viewtopic-t-523747-postdays-0-postorder-asc-start-0.html#3811164 Reproducible: Always Steps to Reproduce: 1. Execute "gcc -Q -c -v -march=native --help=target" and obtain the options into which -march=native translates on your system, taking only the options that matter in terms of code generation (i.e. -march=prescott --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048) 2. Put them into your CFLAGS in place of -march=native 3. Execute "emerge -l =sys-libs/libstdc++-v3-3.3.6" Actual Results: ... checking for object suffix... configure: error: installation or configuration problem; compiler does not work make: *** [configure-target-libstdc++-v3] Error 1 * ERROR: sys-libs/libstdc++-v3-3.3.6 failed: * (no error message) * * Call stack: * ebuild.sh, line 54: Called src_compile * environment, line 3008: Called die * The specific snippet of code: * emake all-target-libstdc++-v3 || die * * If you need support, post the output of 'emerge --info =sys-libs/libstdc++-v3-3.3.6', * the complete build log and the output of 'emerge -pqv =sys-libs/libstdc++-v3-3.3.6'. * The complete build log is located at '/var/tmp/portage/sys-libs/libstdc++-v3-3.3.6/temp/build.log'. * The ebuild environment file is located at '/var/tmp/portage/sys-libs/libstdc++-v3-3.3.6/temp/environment'. * S: '/var/tmp/portage/sys-libs/libstdc++-v3-3.3.6/work/gcc-3.3.6' >>> Failed to emerge sys-libs/libstdc++-v3-3.3.6, Log file: >>> '/var/tmp/portage/sys-libs/libstdc++-v3-3.3.6/temp/build.log' * Messages for package sys-libs/libstdc++-v3-3.3.6: * ERROR: sys-libs/libstdc++-v3-3.3.6 failed: * (no error message) * * Call stack: * ebuild.sh, line 54: Called src_compile * environment, line 3008: Called die * The specific snippet of code: * emake all-target-libstdc++-v3 || die * * If you need support, post the output of 'emerge --info =sys-libs/libstdc++-v3-3.3.6', * the complete build log and the output of 'emerge -pqv =sys-libs/libstdc++-v3-3.3.6'. * The complete build log is located at '/var/tmp/portage/sys-libs/libstdc++-v3-3.3.6/temp/build.log'. * The ebuild environment file is located at '/var/tmp/portage/sys-libs/libstdc++-v3-3.3.6/temp/environment'. * S: '/var/tmp/portage/sys-libs/libstdc++-v3-3.3.6/work/gcc-3.3.6' Expected Results: The ebuild should work. # emerge --info Portage 2.1.8.3 (default/linux/x86/10.0, gcc-4.4.3, glibc-2.11.1-r0, 2.6.34 i686) ================================================================= System uname: Linux-2.6.34-i686-Genuine_Intel-R-_CPU_T2400_@_1.83GHz-with-gentoo-2.0.1 Timestamp of tree: Sat, 29 May 2010 19:30:13 +0000 ccache version 2.4 [enabled] app-shells/bash: 4.1_p7 dev-java/java-config: 2.1.11 dev-lang/python: 2.6.5-r2, 3.1.2-r3 dev-util/ccache: 2.4-r8 dev-util/cmake: 2.8.1-r2 sys-apps/baselayout: 2.0.1 sys-apps/openrc: 0.6.1-r1 sys-apps/sandbox: 2.2 sys-devel/autoconf: 2.13, 2.65 sys-devel/automake: 1.8.5-r4, 1.9.6-r3, 1.10.3, 1.11.1 sys-devel/binutils: 2.20.1-r1 sys-devel/gcc: 4.4.3-r2 sys-devel/gcc-config: 1.4.1 sys-devel/libtool: 2.2.7b virtual/os-headers: 2.6.33 ACCEPT_KEYWORDS="x86 ~x86" ACCEPT_LICENSE="*" CBUILD="i686-pc-linux-gnu" CFLAGS="-O2 -march=prescott --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -pipe -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/X11/xkb /usr/share/config /var/lib/hsqldb" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CPPFLAGS="-O2 -march=prescott --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -pipe -fomit-frame-pointer" CXXFLAGS="-O2 -march=prescott --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -pipe -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FEATURES="assume-digests buildpkg ccache distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch" FFLAGS="-O2 -march=prescott --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -pipe -fomit-frame-pointer" GENTOO_MIRRORS="http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ http://gentoo.netnitco.net http://distro.ibiblio.org/pub/linux/distributions/gentoo/" LDFLAGS="-Wl,-O1" LINGUAS="en" MAKEOPTS="-j3" PKGDIR="/usr/portage/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/var/lib/layman/sunrise /var/lib/layman/vmware /var/lib/layman/java-overlay /usr/local/portage" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="X acpi alsa apm berkdb bzip2 cdr cli consolekit cracklib crypt cups cxx dbus dri dvd dvdr fftw fortran gd gdbm gif gnutls gpm hal iconv ipv6 java java6 jpeg kde lzma midi mmap mmx mng modules mp3 mudflap ncurses networkmanager nls nptl nptlonly nsplugin opengl openmp pam pcre perl png pppd python qt3 qt3support qt4 readline reflection samba session spl sqlite sse sse2 sse3 ssl svg sysfs tcpd threads tiff unicode vorbis x264 x86 xml xorg xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en" NETBEANS_MODULES="*" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Created attachment 233459 [details] build.log for sys-libs/libstdc++-v3-3.3.6 when certain CFLAGS are used
-march=native is stripped because it didn't exist in 3.3.6. libstdc++-v3 is bootstrapped just like GCC is: it first builds the compiler then builds the library with that compiler. So while you're building the first stage with whatever GCC version you're using, the second stage is built with the just-built GCC 3.3.6 compiler and won't recognize any flags that didn't exist back then. I can't tell without looking at the config.log, but I'm pretty sure the problem is your --param flags. 3.3.6 didn't support the cache size flags. I'd just tell you not use them, but I use them myself. ;) So maybe strip-flags should be stripping --param too.
or rather strip-unsupported-flags() should handle flags with whitespace separated arguments.
By config.log, do you mean the environment file?
No, there should be a file named config.log in the directory configure was running in. It should be in ${PORTDIR}/work/build/i686-pc-linux-gnu/libstdc++-v3.
Created attachment 233509 [details] config.log file from failed run Here it is.
i think ferringb complained about --param handling in the past and i just told him to not use that crap. the common strip funcs dont handle older compiler flags because there's no way of knowing what the target compiler supports. we've been putting common ones in the libstdc++-v3 ebuild itself. anything crazier ive said similar things as i have to ferringb.
(In reply to comment #7) > i think ferringb complained about --param handling in the past and i just told > him to not use that crap. > > the common strip funcs dont handle older compiler flags because there's no way > of knowing what the target compiler supports. we've been putting common ones > in the libstdc++-v3 ebuild itself. anything crazier ive said similar things as > i have to ferringb. > I thought that the target compiler was GCC 3.3.6, which has documentation describing its flags at gcc.gnu.org: http://gcc.gnu.org/onlinedocs/gcc-3.3.6/gcc/Option-Index.html#Option-Index Anyway, there are a few possibilities to handle this that I can see. The first and easiest is to go with a system-cflags USE flag, where the ebuild would use known safe CFLAGS by default and would need to have the system-cflags USE flag specified to override that behavior. Another possibility is to use a force-system-cflags USE flag where the ebuild would examine the system CFLAGS and if it sees any difficult to handle parameters (e.g. --param), the ebuild could fall back to using safe CFLAGS in place of the system CFLAGS, in which case, the user could specify the force-system-cflags USE flag to disable that behavior and have the ebuild use the system CFLAGS regardless of whether or not they might be unsafe. The final possibility would be to do something with lex/flex and yacc/bison, where grammars could be designed around GCC's variable documentation, which would then be fed into lex/flex and yacc/bison to obtain a abstract syntax tree; the abstract syntax tree would basically be a linked list. The the rules along the backbone of the linked list would then correspond to the compiler flags used in the construction of the parse tree, which could then be stripped based on either a white list of safe flags or a black list of unsafe flags specified by the ebuild. After the unsafe flags have been stripped, the modified parse tree would be converted back into its original command line options form, which would then be passed to GCC. This would be a more robust way of doing things, although implementing it would probably be on the level of a Google Summer of Code project.
you missed the point. we absolutely do not want to maintain a list of flags that are specific to a gcc release. versions come and go ... we write code that is as usable across multiple versions as possible.
then the easiest thing to do in this case is add an env file (/etc/portage/env/sys-libs/libstdc++-v3) containing the C*FLAGS that do work (-march=native etc.).
(In reply to comment #10) > then the easiest thing to do in this case is add an env file > (/etc/portage/env/sys-libs/libstdc++-v3) containing the C*FLAGS that do work > (-march=native etc.). > Is there any documentation describing how to do this?
not sure where but it's just a list of variables like make.conf. $ cat /etc/portage/env/sys-libs/libstdc++-v3 CFLAGS="-O2 -pipe -march=native" CXXFLAGS="${CFLAGS}" You can also include a version number in the filename (eg. libstdc++-v3-3.3.6) if you want it to only apply to that version.
i dont have a problem adding *common* CFLAGS to the toolchain.eclass and libstdc++-v3. so filtering "native" is OK. but the rest (like --param) do not fall into this category, so in that regard, i say "you deal with it".
I have my CFLAGS set to "-march=native -mno-avx -O2 -pipe". Nevertheless, I also get a "configure: error: installation or configuration problem: C compiler cannot create executables." when building sys-libs/libstdc++-v3-3.3.6. When I remove the -mno-avx from CFLAGS and CXXFLAGS, the compilation works (but breaks Thunderbird et al). So I guess -mno-avx is the flag (or another flag?) that should be filtered.
Created attachment 291647 [details] Output of emerge --info
Created attachment 291649 [details] Build.log
Created attachment 291651 [details] environment
(In reply to comment #14) > I have my CFLAGS set to "-march=native -mno-avx -O2 -pipe". Nevertheless, I > also get a > "configure: error: installation or configuration problem: C compiler cannot > create executables." > when building sys-libs/libstdc++-v3-3.3.6. > > When I remove the -mno-avx from CFLAGS and CXXFLAGS, the compilation works (but > breaks Thunderbird et al). > > So I guess -mno-avx is the flag (or another flag?) that should be filtered. I am not sure if filtering a flag that disables instructions is a good idea given that only new CPUs have them to disable in the first place. GCC's implementation of -mavx has some issues, so I could see why filtering -mavx would make things better, but I don't see how filtering -mno-avx would make an improvement.
No, strip-flags doesn't filter -mno flags, nor should it. -mno-avx was a problem with 4.4 but now that 4.5 is in stable you shouldn't need that flag anymore. If you do then use an env file like I describe in comment #12.