Even More -messy -foptimizations

So, now there’s bug 90663 which shows a user clearly using compilation flags gleaned from some 1337 ch4nn31 on some freaky irc network somewhere. People, if you’re going to be filing bugs, please at least tone down your cflags before you do. Bug reports like this are a waste of:

  • Gentoo developers’ time
  • Your own time

It’s a small enough list that you can probably memorise it. Please pay close attention to the first item there.

This entry was posted in Gentoo. Bookmark the permalink.

5 Responses to Even More -messy -foptimizations

  1. Simon Farnsworth says:

    Just looking at his CFLAGS shows that he’s not bothered to read and comprehend the GCC manual. I’m going to go through them, reducing them down to the bare minimum that works the same way, and mark the remaining flags that GCC devs say are dangerous unless you know what you’re doing.
    -march=athlon64 implies:

    • -mtune=athlon64
    • -msse
    • -msse2
    • -mmmx
    • -m3dnow
    • -mfpmath=sse

    -O3 implies

    • -foptimize-sibling-calls
    • -funit-at-a-time
    • -fstrength-reduce
    • -fmerge-constants
    • -fomit-frame-pointer
    • -fprefetch-loop-arrays
    • -frename-registers
    • -fforce-mem
    • -frerun-cse-after-loop
    • -frerun-loop-opt
    • -falign-functions (with a machine-dependent default, chosen for performance).

    This leaves the following

    • -pipe, which does make sense.
    • -maccumulate-outgoing-args, which trades off code size for speed, and is probably beneficial if his L2 cache is large enough.
    • -fforce-addr, which may sometimes produce better code, but which usually just increases compile time.
    • -fmove-all-movables, which is largely about dealing with a FORTRAN idiom well, and doesn’t help most C code.
    • -funroll-loops, which usually has no effect, and is only likely to help when there’s profile-driven feedback to use.
    • -falign-functions=4, which may be right by chance for Athlon64. If not, it’s degrading performance, as it’s implied by -O3, with a machine suitable default.
    • -fmerge-all-constants, which breaks the C and C++ standards, and can induce bugs in code. You’re only supposed to use this one if you know that the code in question doesn’t depend on the required invariant that for two pointers, a and b, a == b => *a is the same object as *b. Given the rest of his CFLAGS, what’s the betting that this loon has actually done so?
    • -ffast-math, which tells GCC to trade off FP correctness (accuracy, error handling et al) in favour of speed. Don’t turn this one on unless you know the code can cope; silly things like 0/0 can turn from an error to -1 on some systems, for example.

    Looking at CFLAGS like that tempts me to write a bit of Python that takes in CFLAGS, spits out the smallest equivalent CFLAGS, and warns you of stupid flags. The two things that put me off are the need for maintenance (the CFLAGS equivalences change from GCC version to GCC version), and the fact that it probably won’t convince the sort of person who uses silly CFLAGS without reading the GCC manual to think about what they’re doing.

  2. Thanks for that Simon — I’ll be linking to your comment back from all the bugs. As more bugs come in with -my-gentoo-is -fucking-leet flags, I’ll add them to my blog. We might just get a top 10 of 2005 list going.

  3. lisa says:

    We need a check in Portage:

    if [ "$(wc -l ${CFLAGS})" -gt 7 ];
    then
    echo “What the HELL is wrong with your CFLAGS?!?
    fi

    /reading old entries

  4. gentree says:

    fair comment.

    maybe a link to the gcc doc would help these loons talk sense. Or at least remove the last excuse for not knowing what they mean:
    http://gcc.gnu.org/onlinedocs/gcc-3.4.1/gcc/Optimize-Options.html