Gentoo Archives: gentoo-user

From: Volker Armin Hemmann <volkerarmin@××××××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] How compatible are the various gcc -O flags?
Date: Fri, 06 Nov 2009 16:10:01
Message-Id: 200911061709.57091.volkerarmin@googlemail.com
In Reply to: [gentoo-user] How compatible are the various gcc -O flags? by felix@crowfix.com
1 On Freitag 06 November 2009, felix@×××××××.com wrote:
2 > How compatible are the various gcc optimization flags? Are they
3 > internal to a single program, do they affect library calls? Can some
4 > packages be made with one flag and still work with other packages made
5 > with other flags?
6 >
7 > Let me make up some completely fake examples. Suppose -Ox unrolls
8 > loops. I can't see how any other code could ever notice, so it would
9 > be perfectly fine to mix and match packages which have and don't have
10 > this optimization.
11 >
12 > Suppose -Oz changes the order of passing parameters on the stack
13 > because someone found a 0.3% speedup if the first parameter was first
14 > instead of last (or vice versa). Quite obviously this would be fatal
15 > for a -Oz package to call a non-Oz package. But suppose this
16 > optimization was only done inside static functions which were not
17 > visible to outside callers -- then it would be ok to mix.
18 >
19 > What brings this up is having changed CFLAGS to -O3 some time ago, I
20 > know not why. I found it by accident when a glib emerge made hald
21 > stop working which prevented X from running. Suppose I want to change
22 > this to -Os, or -O2, or -O1, or any of the other optimization flags,
23 > like -fomit-frame-pointer. What flags are incompatible with others?
24 >
25 > My gut feeling is that there aren't any such flags, otherwise how
26 > could you ever recompile anything except as cross platform? But then,
27 > maybe certain packages are set to filter certain flags, maybe gcc and
28 > the tool chain do this to isolate themselves from dangerous flags.
29 >
30
31 the O levels are compatible. Almost all flags are, except mrec-parm or what it
32 was called. man gcc can answer that for you.