From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25503 invoked from network); 22 Jul 2004 20:47:34 +0000 Received: from smtp.gentoo.org (156.56.111.197) by lists.gentoo.org with AES256-SHA encrypted SMTP; 22 Jul 2004 20:47:34 +0000 Received: from lists.gentoo.org ([156.56.111.196] helo=parrot.gentoo.org) by smtp.gentoo.org with esmtp (Exim 4.34) id 1BnkTV-0002pS-O9 for arch-gentoo-dev@lists.gentoo.org; Thu, 22 Jul 2004 20:47:33 +0000 Received: (qmail 24429 invoked by uid 89); 22 Jul 2004 20:47:33 +0000 Mailing-List: contact gentoo-dev-help@gentoo.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Received: (qmail 2609 invoked from network); 22 Jul 2004 20:47:32 +0000 Message-ID: <011801c4702d$1c4c2cd0$0500a8c0@EPOX2> From: "Gavin" To: References: <1090442410.11373.139.camel@localhost> <1090523177.10205.14.camel@nosferatu.lan> <200407221611.36772.vapier@gentoo.org> Date: Thu, 22 Jul 2004 13:42:45 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal Subject: [gentoo-dev] RFC: factoring logic for selection of "safe" gcc -O flags in ebuilds (uclibc users take note) X-Archives-Salt: 625bfdcb-cec3-451c-b1ca-831a0302ae02 X-Archives-Hash: a9c37369d816cf40436f99356a4de9ef Problem =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Many ebuilds force gcc to use "-O2" instead of other, possibly viable = values. For example, "-Os" does work in some circumstances for certain = ebuilds that currently force the use of "-O2". Those using uclibc = and/or CPUs with small caches might prefer "-Os". However, maintaining = a clone of an ebuild in a portage overlay directory for the sole purpose = of changing "replace-flags -O? -O2" to "replace-flags -O? -Os" present = users with an unecessary hassle. Proposed Solution =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Are ebuilds the best place to make the decision regarding which = optimization is "safe" for the target system? Perhaps we can factor and = encapsulate the logic into flag-o-matic? As a first step, what if we add 'SAFE_GCC_O_FLAG=3D"-O2"' to = /etc/make.globals? It might be a long time before we could expect = everyone using new ebuilds to have a make.global with SAFE_GCC_O_FLAG = defined. Ideally, an appropriate default might be automatically = determined, but I want a super simple, first step solution. /usr/portage/eclass/flag-o-matic.eclass: # credits to Martin Schlemmer's input (see = http://bugs.gentoo.org/show_bug.cgi?id=3D57223) replace-with-safe-gcc-o-flag() { [ -z "${SAFE_GCC_O_FLAG}" ] && SAFE_GCC_O_FLAG=3D"-O2" CFLAGS=3D"${CFLAGS//-O?/ } ${SAFE_GCC_O_FLAG}" CXXFLAGS=3D"${CXXFLAGS//-O?/ } ${SAFE_GCC_O_FLAG}" export CFLAGS CXXFLAGS return 0 } Alternative (less efficient, but less code): replace-with-safe-gcc-o-flag() { [ -z "${SAFE_GCC_O_FLAG}" ] && SAFE_GCC_O_FLAG=3D"-O2" replace-flags -O? ${SAFE_GCC_O_FLAG}" return 0 } # appends SAFE_GCC_O_FLAG to "emerge info" results: --- /usr/lib/portage/bin/emerge.orig 2004-07-17 09:13:48.690078831 = -0700 +++ /usr/lib/portage/bin/emerge 2004-07-17 09:14:08.067093698 -0700 @@ -2314,7 +2314,7 @@ myvars=3D['GENTOO_MIRRORS', 'CONFIG_PROTECT', = 'CONFIG_PROTECT_MASK', 'PORTDIR', 'DISTDIR', 'PKGDIR', = 'PORTAGE_TMPDIR', 'PORTDIR_OVERLAY', 'USE', 'COMPILER', 'CHOST', 'CFLAGS', = 'CXXFLAGS','ACCEPT_KEYWORDS', - 'MAKEOPTS', 'AUTOCLEAN', 'SYNC', = 'FEATURES'] + 'MAKEOPTS', 'AUTOCLEAN', 'SYNC', = 'FEATURES', 'SAFE_GCC_O_FLAG'] myvars.sort() for x in myvars: print x+'=3D"'+portage.settings[x]+'"' -- gentoo-dev@gentoo.org mailing list