From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1GWjGS-00055y-9R for garchives@archives.gentoo.org; Mon, 09 Oct 2006 00:45:04 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.8/8.13.6) with SMTP id k990iA4Y032440; Mon, 9 Oct 2006 00:44:10 GMT Received: from mail.bouton.name (ns.bouton.name [70.85.16.101]) by robin.gentoo.org (8.13.8/8.13.6) with ESMTP id k990g7kJ016581 for ; Mon, 9 Oct 2006 00:42:07 GMT Received: from [192.168.55.3] (adsl.bouton.name [82.227.97.166]) by mail.bouton.name (Postfix) with ESMTP id E7550BA63; Mon, 9 Oct 2006 02:42:05 +0200 (CEST) Message-ID: <45299ADD.1010903@bouton.name> Date: Mon, 09 Oct 2006 02:42:05 +0200 From: Lionel Bouton User-Agent: Thunderbird 1.5.0.5 (X11/20060920) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 To: gwn-feedback@gentoo.org CC: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] CFLAGS paragraph submission for the GWN Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Archives-Salt: a1577ecc-f86e-4241-b4f8-ff0b59c29f09 X-Archives-Hash: 88086b10b2374a9e289d2f24dfd365b7 Here's a draft of a paragraph discussing CFLAGS-related problems. This is the result of a discussion I started on gentoo-dev. Thanks to all devs who gave feedback this should bring some food for thought to GWN readers. --- Draft BEGIN ---
CFLAGS

Being able to tune CFLAGS is part of the user control and extreme configurability that are hallmarks of the Gentoo experience. Being in control brings both benefits and problems. CFLAGS tuning is not an exception.

We would like to remind you that using anything beyond -O2 -fomit-frame-pointer -march/-mcpu/-mtune in CFLAGS or CXXFLAGS (and -mieee, -mabi etc. on selected archs that tell you to do this), and using anything at all in LDFLAGS or ASFLAGS, is usually not worth it for most users. There's usually very little benefit, high risks and much time spent on frustating tuning that could be enjoyed doing far more interesting things.

The recent upgrade to gcc-4.1.1 for x86 and amd64 users changed the CFLAGS landscape. Users that spent some time tuning their CFLAGS with gcc-3.4.6 might find out that an upgrade to gcc-4.1.1 leaves them with an unstable system.

Example of this are :

  • nss_ldap stopped working with -ffast-math (-ffast-math is often misused and must be considered a dangerous flag)
  • -fvisibility-inlines-hidden still breaks some code
  • -ftree-loop-linear now breaks in gcc-4.1 (at least with mesa)
  • -ftree-vectorize is known to be broken in gcc-4.1 (at least for x86 and ppc, there are fewer problems reported by amd64 users but no guarantees)
  • -fforce-addr and -fweb break regularly on x86 with video libraries or graphic processing apps which use hand-optimised ASM. -fweb may be safe on amd64 but like above no guarantees

There are known-to-be-broken flags for all GCC versions that you want to check for too:

  • -fvisibility=hidden
  • -frename-registers (may be safe on amd64, at your own risks)
  • -ftracer
  • -D_FILE_OFFSET_BITS=64
  • -msse -mmmx -m3dnow (no need for them on amd64, there are wrapped up by -march=k8/nocona/... and safely used there)
  • -W
  • -mfpmath=sse,387
  • -malign-double

Users with unsupported CFLAGS might want to return to safe CFLAGS (see warning above) if recent updates caused them stability problems. On the other hand, more adventurous users might want to experiment with CFLAGS that didn't work properly with gcc-3.4.6... As always, the user is in control (and the gun pointed to their feet is in his/her hand).

Final notes:

  • The gcc man page contains warnings for some unsafe optimization options. You should read it carefully when you experiment with CFLAGS or upgrade GCC on a CFLAGS-customized Gentoo.
  • Some options that are unsafe in the system-wide CFLAGS might be added automatically in some ebuilds if the developper deems them safe (by redefining CFLAGS or using append-flags of the flag-o-matic eclass). For example -ffast-math is added by the xmame/xmess ebuilds on most architectures even tho you SHOULD NOT put it in your CFLAGS.
  • You might get an idea of the stability issues of a specific optimization option by running: find /usr/portage -name '*.ebuild'| xargs grep -- '-'. It takes quite some time, but might be enlightening: look for the 'filter-flags'.
--- Draft END --- Lionel -- gentoo-dev@gentoo.org mailing list