Results 1 to 3 of 3

Thread: PET: GCC compile flag fun (draft)

  1. #1

    PET: GCC compile flag fun (draft)

    I've been using compile from scratch distros for a while and that has taught me quite a few things about how to get that extra performance out of the code without compromising stability - so here goes:

    Basicly what you want to do is to export CFLAGS and CXXFLAGS with some interesting flags.

    The complete list for GCC3.1 is here

    I use GCC3.1 as the exsample, mostly because that the version I use, and because most major distros are switching to it as we speak.

    Here goes the most interesting flags:

    -march=cputype {i386,i486,i586,i686,k6-2,k6-3,athlon,athlon-mp,athlon-tbird,athlon-xp,pentium4}

    Enables architecture specific compilation, makes code speedy

    Is it safe?
    This is generally considered safe'ish - my personal experince tells me that I have yet to see problems regarding -march, but if an application refuses to compile you can use step down to a lower cputype like i386.


    Disables the frame-pointer which normally occupices a register, this is used for debugging, and since you are mostly likely not to debug, you might as well use the extra register to gain some speed (also known as "the magic flag" do to the impressive speed gain)

    Is it safe?
    This is considered safe'ish - personal experience tells me that this is fairly safe - I have yet to see any problem and the smoothness my system gets with it is well worth the risk.

    -O2 (note capital letter o, not zero)

    please refer to the documentation as this is rather complex. instead let's debate the use of -O2 vs -O3. If you read the manual you will see that -O3 is simply stated as "optimize even more - plus turns on -finline-functions" - now why don't we use -O3 then.
    We don't do this because -O3 does in fact produce faster code, but the binary it produces will be much larger, and that will make loading slower. Thus -O2 will feel faster. Also any good programmer will manually inline important functions, so instead of letting GCC inline the entire thing (as it tends to) let's rely on the ability of clever coders.

    is this safe?
    -O2 is generally considered safer than -O3 - as -O2 generally is the default let's label this as safe - Personal experience tells me that -O2 feels faster than -O3, and it poses less problems.

    -frerun-cse-after-loop and -frerun-loop-opt

    These flags will optimize loops, will result in faster running code.

    Is this safe?
    Safe'ish - Personal experience: I've never experienced any problems with these flags


    Performs a number of minor optimizations that are relatively expensive.

    Is this safe?
    safe'ish : personal experience : Personal experience: I have yet to see any problems with this.


    Aligns the start of functions to the next power-of-two greater than n, skipping up to n bytes, should affect load time of the functions.

    is this safe?
    Safe'ish - Personal experience: I have yet to see any problems with this, and combined with loop optimizing this to some degree speeds up loading. - for me n=4 seems good.


    I have my entire Gentoo Linux system running with these flags, and while I don't experience any problems with this you might and if this leads to crashing, then step optimizations down and don't blame me. and remember that optimizing binutils, GCC and glibc is considered unsafe.

  2. #2
    Good Guru
    Schotty's Avatar
    Join Date
    Jul 2001
    Milwaukee, WI

    Re:PET: GCC compile flag fun (draft)

    Thanks for the tips.

  3. #3

    Re:PET: GCC compile flag fun (draft)

    [quote author=Schotty link=board=23;threadid=3921;start=0#39184 date=1025013071]
    Thanks for the tips.

    I have way to much time on my hands...

Similar Threads

  1. TCP packet with RST flag not carrying DSCP
    By Solace in forum Linux - Hardware, Networking & Security
    Replies: 0
    Last Post: 10-08-2009, 05:17 PM
  2. HELP!!! can't boot: inode x has image flag set
    By Blaqb0x in forum Linux - General Topics
    Replies: 3
    Last Post: 03-01-2003, 09:42 PM
  3. Tweaking nVidia cards PET part one - draft
    By in forum Linux - General Topics
    Replies: 1
    Last Post: 06-25-2002, 04:00 AM
  4. Anyone compile KDE 3.0?
    By t048 in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 05-30-2002, 02:58 PM
  5. TCP flag values
    By elovkoff in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 03-01-2002, 10:41 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts