1 |
Here's a draft of a paragraph discussing CFLAGS-related problems. This |
2 |
is the result of a discussion I started on gentoo-dev. Thanks to all |
3 |
devs who gave feedback this should bring some food for thought to GWN |
4 |
readers. |
5 |
|
6 |
--- Draft BEGIN --- |
7 |
<section> |
8 |
<title>CFLAGS</title> |
9 |
<body> |
10 |
|
11 |
<p> |
12 |
Being able to tune CFLAGS is part of the user control and extreme |
13 |
configurability that are hallmarks of the <uri |
14 |
link=http://www.gentoo.org/main/en/about.xml> Gentoo experience</uri>. |
15 |
Being in control brings both benefits and problems. CFLAGS tuning is not |
16 |
an exception. |
17 |
</p> |
18 |
|
19 |
<warn> |
20 |
We would like to remind you that using anything beyond <c>-O2 |
21 |
-fomit-frame-pointer -march/-mcpu/-mtune</c> in CFLAGS or CXXFLAGS (and |
22 |
<c>-mieee, -mabi</c> etc. on selected archs that tell you to do this), |
23 |
and using anything at all in LDFLAGS or ASFLAGS, is usually not worth it |
24 |
for most users. There's usually very little benefit, high risks and much |
25 |
time spent on frustating tuning that could be enjoyed doing far more |
26 |
interesting things. |
27 |
</warn> |
28 |
|
29 |
<p> |
30 |
The recent upgrade to gcc-4.1.1 for x86 and amd64 users changed the |
31 |
CFLAGS landscape. Users that spent some time tuning their CFLAGS with |
32 |
gcc-3.4.6 might find out that an upgrade to gcc-4.1.1 leaves them with |
33 |
an unstable system. |
34 |
</p> |
35 |
<p>Example of this are :</p> |
36 |
<ul> |
37 |
<li>nss_ldap stopped working with <c>-ffast-math</c> (<c>-ffast-math</c> |
38 |
is often misused and must be considered a dangerous flag)</li> |
39 |
<li><c>-fvisibility-inlines-hidden</c> still breaks some code</li> |
40 |
<li><c>-ftree-loop-linear</c> now breaks in gcc-4.1 (at least with |
41 |
mesa)</li> |
42 |
<li><c>-ftree-vectorize</c> is known to be broken in gcc-4.1 (at least |
43 |
for x86 and ppc, there are fewer problems reported by amd64 users but no |
44 |
guarantees)</li> |
45 |
<li><c>-fforce-addr</c> and <c>-fweb</c> break regularly on x86 with |
46 |
video libraries or graphic processing apps which use hand-optimised ASM. |
47 |
<c>-fweb</c> may be safe on amd64 but like above no guarantees</li> |
48 |
</ul> |
49 |
|
50 |
<p>There are known-to-be-broken flags for all GCC versions that you want |
51 |
to check for too:</p> |
52 |
<ul> |
53 |
<li>-fvisibility=hidden</li> |
54 |
<li>-frename-registers (may be safe on amd64, at your own risks)</li> |
55 |
<li>-ftracer</li> |
56 |
<li>-D_FILE_OFFSET_BITS=64</li> |
57 |
<li>-msse -mmmx -m3dnow (no need for them on amd64, there are wrapped up |
58 |
by -march=k8/nocona/... and safely used there)</li> |
59 |
<li>-W</li> |
60 |
<li>-mfpmath=sse,387</li> |
61 |
<li>-malign-double</li> |
62 |
</ul> |
63 |
|
64 |
<p> |
65 |
Users with unsupported CFLAGS might want to return to safe CFLAGS (see |
66 |
warning above) if recent updates caused them stability problems. On the |
67 |
other hand, more adventurous users might want to experiment with CFLAGS |
68 |
that didn't work properly with gcc-3.4.6... As always, the user is in |
69 |
control (and the gun pointed to their feet is in his/her hand). |
70 |
</p> |
71 |
|
72 |
<p>Final notes:</p> |
73 |
<ul> |
74 |
<li>The gcc man page contains warnings for some unsafe optimization |
75 |
options. You should read it carefully when you experiment with CFLAGS or |
76 |
upgrade GCC on a CFLAGS-customized Gentoo.</li> |
77 |
<li>Some options that are unsafe in the system-wide CFLAGS might be |
78 |
added automatically in some ebuilds if the developper deems them safe |
79 |
(by redefining CFLAGS or using append-flags of the flag-o-matic eclass). |
80 |
For example <c>-ffast-math</c> is added by the xmame/xmess ebuilds on |
81 |
most architectures even tho you SHOULD NOT put it in your CFLAGS.</li> |
82 |
<li>You might get an idea of the stability issues of a specific |
83 |
optimization option by running: <c>find /usr/portage -name '*.ebuild'| |
84 |
xargs grep -- '-<your-risky-optimization-option>'</c>. It takes quite |
85 |
some time, but might be enlightening: look for the |
86 |
'<c>filter-flags</c>'.</li> |
87 |
</ul> |
88 |
|
89 |
</body> |
90 |
</section> |
91 |
--- Draft END --- |
92 |
|
93 |
Lionel |
94 |
-- |
95 |
gentoo-dev@g.o mailing list |