Gentoo Archives: gentoo-user

From: felix@×××××××.com
To: gentoo-user@l.g.o
Subject: [gentoo-user] How compatible are the various gcc -O flags?
Date: Fri, 06 Nov 2009 16:07:54
Message-Id: 20091106160741.GA20905@crowfix.com
1 How compatible are the various gcc optimization flags? Are they
2 internal to a single program, do they affect library calls? Can some
3 packages be made with one flag and still work with other packages made
4 with other flags?
5
6 Let me make up some completely fake examples. Suppose -Ox unrolls
7 loops. I can't see how any other code could ever notice, so it would
8 be perfectly fine to mix and match packages which have and don't have
9 this optimization.
10
11 Suppose -Oz changes the order of passing parameters on the stack
12 because someone found a 0.3% speedup if the first parameter was first
13 instead of last (or vice versa). Quite obviously this would be fatal
14 for a -Oz package to call a non-Oz package. But suppose this
15 optimization was only done inside static functions which were not
16 visible to outside callers -- then it would be ok to mix.
17
18 What brings this up is having changed CFLAGS to -O3 some time ago, I
19 know not why. I found it by accident when a glib emerge made hald
20 stop working which prevented X from running. Suppose I want to change
21 this to -Os, or -O2, or -O1, or any of the other optimization flags,
22 like -fomit-frame-pointer. What flags are incompatible with others?
23
24 My gut feeling is that there aren't any such flags, otherwise how
25 could you ever recompile anything except as cross platform? But then,
26 maybe certain packages are set to filter certain flags, maybe gcc and
27 the tool chain do this to isolate themselves from dangerous flags.
28
29 --
30 ... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
31 Felix Finch: scarecrow repairman & rocket surgeon / felix@×××××××.com
32 GPG = E987 4493 C860 246C 3B1E 6477 7838 76E9 182E 8151 ITAR license #4933
33 I've found a solution to Fermat's Last Theorem but I see I've run out of room o

Replies

Subject Author
Re: [gentoo-user] How compatible are the various gcc -O flags? Volker Armin Hemmann <volkerarmin@××××××××××.com>