From: "Gavin" <gavin@vess.com>
To: <gentoo-dev@lists.gentoo.org>
Subject: [gentoo-dev] RFC: factoring logic for selection of "safe" gcc -O flags in ebuilds (uclibc users take note)
Date: Thu, 22 Jul 2004 13:42:45 -0700 [thread overview]
Message-ID: <011801c4702d$1c4c2cd0$0500a8c0@EPOX2> (raw)
In-Reply-To: 200407221611.36772.vapier@gentoo.org
Problem
===========
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
====================
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="-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=57223)
replace-with-safe-gcc-o-flag() {
[ -z "${SAFE_GCC_O_FLAG}" ] && SAFE_GCC_O_FLAG="-O2"
CFLAGS="${CFLAGS//-O?/ } ${SAFE_GCC_O_FLAG}"
CXXFLAGS="${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="-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=['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+'="'+portage.settings[x]+'"'
--
gentoo-dev@gentoo.org mailing list
next prev parent reply other threads:[~2004-07-22 20:47 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-16 22:30 [gentoo-dev] Kernel sources thread Joel Konkle-Parker
2004-07-16 23:36 ` Grant Goodyear
2004-07-16 23:45 ` Ciaran McCreesh
2004-07-17 0:06 ` Greg KH
2004-07-17 0:32 ` Ciaran McCreesh
2004-07-18 17:53 ` Dylan Carlson
2004-07-18 18:10 ` Ciaran McCreesh
2004-07-18 19:18 ` Dylan Carlson
2004-07-21 5:32 ` Greg KH
2004-07-18 21:23 ` Georgi Georgiev
2004-07-21 5:38 ` Greg KH
2004-07-21 5:59 ` Georgi Georgiev
2004-07-21 13:29 ` Paul Varner
2004-07-22 6:55 ` Greg KH
2004-07-25 16:14 ` Paul Varner
2004-07-25 16:55 ` Ciaran McCreesh
2004-07-25 17:51 ` Paul Varner
2004-07-26 14:26 ` Chris Gianelloni
2004-07-26 21:25 ` Donnie Berkholz
2004-07-26 23:27 ` Georgi Georgiev
2004-07-27 12:38 ` Chris Gianelloni
2004-07-21 20:29 ` Chris Gianelloni
2004-07-21 5:29 ` Greg KH
2004-07-18 22:53 ` Travis Tilley
2004-07-18 23:22 ` Ciaran McCreesh
2004-07-19 0:00 ` Martin Schlemmer
2004-07-21 5:28 ` Greg KH
2004-07-21 7:24 ` Travis Tilley
2004-07-21 10:34 ` Travis Tilley
2004-07-21 11:04 ` Carsten Lohrke
2004-07-22 7:40 ` [gentoo-dev] " Duncan
2004-07-22 10:44 ` Carsten Lohrke
2004-07-21 14:47 ` [gentoo-dev] " Georgi Georgiev
2004-07-21 18:16 ` Greg KH
2004-07-21 19:46 ` Ciaran McCreesh
2004-07-22 19:05 ` Martin Schlemmer
2004-07-24 4:09 ` Greg KH
2004-07-21 20:40 ` Chris Gianelloni
2004-07-22 19:06 ` Martin Schlemmer
2004-07-22 20:11 ` Mike Frysinger
2004-07-22 20:42 ` Gavin [this message]
2004-07-23 4:51 ` [gentoo-dev] RFC: factoring logic for selection of "safe" gcc -O flags in ebuilds (uclibc users take note) Andrew Ross
2004-07-22 21:44 ` [gentoo-dev] Kernel sources thread Martin Schlemmer
2004-07-23 3:31 ` Georgi Georgiev
2004-07-24 16:27 ` Martin Schlemmer
2004-07-25 1:43 ` Georgi Georgiev
2004-07-25 6:44 ` Norberto Bensa
2004-07-25 17:56 ` Georgi Georgiev
2004-07-21 16:04 ` Norberto Bensa
2004-07-21 18:07 ` Greg KH
2004-07-21 5:42 ` Greg KH
2004-07-17 5:33 ` Wade Nelson
2004-07-17 6:19 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='011801c4702d$1c4c2cd0$0500a8c0@EPOX2' \
--to=gavin@vess.com \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox