This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc 3.4.1 and CPU optimization


On 1 Dec 2004, Zbigniew mused:
> The renaming gcc by aliasing it is necessary. Since someone told me 
> about ./configure CFLAGS="option" I was manually editing houndreds of config 
> lines (many programs were compiled) to have good optimization. If you 
> recompile many programs to speed up system a little you will understand what 
> I am talking about.

This is what site-config files are for.

e.g.

CONFIG_SITE="/some/shell/script"

where /some/shell/script contains e.g.

[ "x$CFLAGS" = "x" ] && CFLAGS="-O2 -march=athlon-4"
[ "x$CXXFLAGS" = "x" ] && CXXFLAGS="-O2 -fpermissive -march=athlon-4"

site-config scripts are run before the configure script proper runs, so
all you have to deal with is configure scripts which *override* the
user's choice of CFLAGS. Such are, as I said, comparatively rare.


The major advantage of this approach over a config file is that the
site-config script can be arbitrarily complicated. Mine's been growing
for a decade and now puts together a set of optimization flags and the
names of compilers taking into account per-application configuration
files, possible cross-compilation, and much else.

Plus, a site-config script can turn on and off other configure flags,
too, if it's sufficiently evil. There's no way you can do *that* even
with a script wrapping config files.

With a bit of effort you can make this apply to programs that don't use
Autoconf-based configure scripts, too: I use a makefile fragment that
executes the same low-level code that the site-config script executes to
determine compilation flags, then translates it into Makefile rules,
redirects that to a file and includes the file: a two-line addition to
most makefiles will make that `site-config makefile fragment' apply to
them.


The upshot is that it is already easy to set site policy regarding
configuration flags, there are multiple possible mechanisms, most of
which have a full programming language available to compose command
lines. There's no need to put this stuff into GCC.

-- 
`The sword we forged has turned upon us
 Only now, at the end of all things do we see
 The lamp-bearer dies; only the lamp burns on.'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]