[TWEAK] - gcc defaults

Greg Schafer gschafer at zip.com.au
Tue Jul 15 03:04:00 PDT 2003


Sorry for being a little OT but this is so nifty I just have to share it :-)

I backported this patch from the gcc CVS HEAD (aka 3.4). With it, you can
set defaults for gcc for -march and -mcpu and so forth. Unlike previous
incarnations of default arch hacks, this implementation is clean and

Want your gcc to emit pentium4 code by default (same as if -march=pentium4
was passed on the gcc command line) without futzing around with CFLAGS?
Easy, just add this to your gcc configure arguments when building gcc:-


A more conservative use could be something like... if for instance you
have an athlon-xp but your platform gets reported as i686-pc-linux-gnu:-

--with-arch=i386 --with-cpu=athlon-xp

then gcc will emit code by default as if -march=i386 and -mcpu=athlon-xp
instead of the current -march=i386 and -mcpu=i686

You can check gcc's output by using "-fverbose-asm" in combo with "-S" or
"-save-temps" as per usual. Or you can inspect the generated assembly by
hand if that's what floats your boat.

Just so it's clear, this changes only the DEFAULTS. i.e. specifying -march
and -mcpu on the gcc commandline still works exactly like before.

This is against gcc-3.3.1-cvs but should apply against 3.3. More details in
the patch itself. Note especially the comment about testsuite regressions.
Usual disclaimers apply, blah..


-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-3.3.1-cvs.with_defaults.patch.gz
Type: application/x-gunzip
Size: 6119 bytes
Desc: not available
URL: <http://lists.linuxfromscratch.org/pipermail/lfs-dev/attachments/20030715/c781e319/attachment.bin>

More information about the lfs-dev mailing list