* [gentoo-dev] CFLAGS paragraph submission for the GWN
@ 2006-10-09 0:42 Lionel Bouton
2006-10-09 1:30 ` Dice R. Random
2006-10-14 8:49 ` Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN] Sebastian Bergmann
0 siblings, 2 replies; 12+ messages in thread
From: Lionel Bouton @ 2006-10-09 0:42 UTC (permalink / raw
To: gwn-feedback; +Cc: gentoo-dev
Here's a draft of a paragraph discussing CFLAGS-related problems. This
is the result of a discussion I started on gentoo-dev. Thanks to all
devs who gave feedback this should bring some food for thought to GWN
readers.
--- Draft BEGIN ---
<section>
<title>CFLAGS</title>
<body>
<p>
Being able to tune CFLAGS is part of the user control and extreme
configurability that are hallmarks of the <uri
link=http://www.gentoo.org/main/en/about.xml> Gentoo experience</uri>.
Being in control brings both benefits and problems. CFLAGS tuning is not
an exception.
</p>
<warn>
We would like to remind you that using anything beyond <c>-O2
-fomit-frame-pointer -march/-mcpu/-mtune</c> in CFLAGS or CXXFLAGS (and
<c>-mieee, -mabi</c> etc. on selected archs that tell you to do this),
and using anything at all in LDFLAGS or ASFLAGS, is usually not worth it
for most users. There's usually very little benefit, high risks and much
time spent on frustating tuning that could be enjoyed doing far more
interesting things.
</warn>
<p>
The recent upgrade to gcc-4.1.1 for x86 and amd64 users changed the
CFLAGS landscape. Users that spent some time tuning their CFLAGS with
gcc-3.4.6 might find out that an upgrade to gcc-4.1.1 leaves them with
an unstable system.
</p>
<p>Example of this are :</p>
<ul>
<li>nss_ldap stopped working with <c>-ffast-math</c> (<c>-ffast-math</c>
is often misused and must be considered a dangerous flag)</li>
<li><c>-fvisibility-inlines-hidden</c> still breaks some code</li>
<li><c>-ftree-loop-linear</c> now breaks in gcc-4.1 (at least with
mesa)</li>
<li><c>-ftree-vectorize</c> is known to be broken in gcc-4.1 (at least
for x86 and ppc, there are fewer problems reported by amd64 users but no
guarantees)</li>
<li><c>-fforce-addr</c> and <c>-fweb</c> break regularly on x86 with
video libraries or graphic processing apps which use hand-optimised ASM.
<c>-fweb</c> may be safe on amd64 but like above no guarantees</li>
</ul>
<p>There are known-to-be-broken flags for all GCC versions that you want
to check for too:</p>
<ul>
<li>-fvisibility=hidden</li>
<li>-frename-registers (may be safe on amd64, at your own risks)</li>
<li>-ftracer</li>
<li>-D_FILE_OFFSET_BITS=64</li>
<li>-msse -mmmx -m3dnow (no need for them on amd64, there are wrapped up
by -march=k8/nocona/... and safely used there)</li>
<li>-W</li>
<li>-mfpmath=sse,387</li>
<li>-malign-double</li>
</ul>
<p>
Users with unsupported CFLAGS might want to return to safe CFLAGS (see
warning above) if recent updates caused them stability problems. On the
other hand, more adventurous users might want to experiment with CFLAGS
that didn't work properly with gcc-3.4.6... As always, the user is in
control (and the gun pointed to their feet is in his/her hand).
</p>
<p>Final notes:</p>
<ul>
<li>The gcc man page contains warnings for some unsafe optimization
options. You should read it carefully when you experiment with CFLAGS or
upgrade GCC on a CFLAGS-customized Gentoo.</li>
<li>Some options that are unsafe in the system-wide CFLAGS might be
added automatically in some ebuilds if the developper deems them safe
(by redefining CFLAGS or using append-flags of the flag-o-matic eclass).
For example <c>-ffast-math</c> is added by the xmame/xmess ebuilds on
most architectures even tho you SHOULD NOT put it in your CFLAGS.</li>
<li>You might get an idea of the stability issues of a specific
optimization option by running: <c>find /usr/portage -name '*.ebuild'|
xargs grep -- '-<your-risky-optimization-option>'</c>. It takes quite
some time, but might be enlightening: look for the
'<c>filter-flags</c>'.</li>
</ul>
</body>
</section>
--- Draft END ---
Lionel
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-dev] CFLAGS paragraph submission for the GWN
2006-10-09 0:42 [gentoo-dev] CFLAGS paragraph submission for the GWN Lionel Bouton
@ 2006-10-09 1:30 ` Dice R. Random
2006-10-09 10:51 ` [gentoo-dev] " Duncan
2006-10-14 8:49 ` Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN] Sebastian Bergmann
1 sibling, 1 reply; 12+ messages in thread
From: Dice R. Random @ 2006-10-09 1:30 UTC (permalink / raw
To: gentoo-dev
On 10/8/06, Lionel Bouton <lionel-dev@bouton.name> wrote:
> Here's a draft of a paragraph discussing CFLAGS-related problems. This
> is the result of a discussion I started on gentoo-dev. Thanks to all
> devs who gave feedback this should bring some food for thought to GWN
> readers.
Hi Lionel,
Thanks for writing this up, great job. Nitpicking spelling and
grammar points to follow ;)
> configurability that are hallmarks of the <uri
> link=http://www.gentoo.org/main/en/about.xml> Gentoo experience</uri>.
Extra space before "Gentoo" here.
> for most users. There's usually very little benefit, high risks and much
> time spent on frustating tuning that could be enjoyed doing far more
> interesting things.
> </warn>
"frustating" should be "frustrating"
> <p>Example of this are :</p>
Should be plural: "Examples"
> <li><c>-fforce-addr</c> and <c>-fweb</c> break regularly on x86 with
> video libraries or graphic processing apps which use hand-optimised ASM.
> <c>-fweb</c> may be safe on amd64 but like above no guarantees</li>
"optimised" should be "optimized"
> For example <c>-ffast-math</c> is added by the xmame/xmess ebuilds on
> most architectures even tho you SHOULD NOT put it in your CFLAGS.</li>
"tho" should be "though"
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 12+ messages in thread
* [gentoo-dev] Re: CFLAGS paragraph submission for the GWN
2006-10-09 1:30 ` Dice R. Random
@ 2006-10-09 10:51 ` Duncan
2006-10-09 13:51 ` Lionel Bouton
0 siblings, 1 reply; 12+ messages in thread
From: Duncan @ 2006-10-09 10:51 UTC (permalink / raw
To: gentoo-dev
"Dice R. Random" <dicerandom@gmail.com> posted
d9b9989b0610081830y67d1f18eua69de58ecc12675e@mail.gmail.com, excerpted
below, on Sun, 08 Oct 2006 18:30:56 -0700:
>> For example <c>-ffast-math</c> is added by the xmame/xmess ebuilds on
>> most architectures even tho you SHOULD NOT put it in your CFLAGS.</li>
>
> "tho" should be "though"
FWIW, that addition was at my suggestion, and I used the informal list
spelling I always do. I didn't expect it to make it literally into the
proposed paragraph, but it must have slipped by him when he took my
suggestion.
Lionel: No further suggestions here. Good work, honestly better than
I'd have the patience to try, and I'll be looking forward to seeing it in
GWN. =8^)
--
Duncan - List replies preferred. No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master." Richard Stallman
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-dev] Re: CFLAGS paragraph submission for the GWN
2006-10-09 10:51 ` [gentoo-dev] " Duncan
@ 2006-10-09 13:51 ` Lionel Bouton
2006-10-09 14:12 ` Duncan
0 siblings, 1 reply; 12+ messages in thread
From: Lionel Bouton @ 2006-10-09 13:51 UTC (permalink / raw
To: gentoo-dev; +Cc: gwn-feedback
Duncan wrote the following on 09.10.2006 12:51 :
> "Dice R. Random" <dicerandom@gmail.com> posted
> d9b9989b0610081830y67d1f18eua69de58ecc12675e@mail.gmail.com, excerpted
> below, on Sun, 08 Oct 2006 18:30:56 -0700:
>
>
>>> For example <c>-ffast-math</c> is added by the xmame/xmess ebuilds on
>>> most architectures even tho you SHOULD NOT put it in your CFLAGS.</li>
>>>
>> "tho" should be "though"
>>
>
> FWIW, that addition was at my suggestion, and I used the informal list
> spelling I always do. I didn't expect it to make it literally into the
> proposed paragraph, but it must have slipped by him when he took my
> suggestion.
>
>
I did hesitate :-) But as english isn't my native language, I chose to
belive that 'tho' was now acceptable.
I cc: gwn-feedback so that they are aware of the corrections.
Here are Dice's corrections:
1/ Extra space before "Gentoo" in:
link=http://www.gentoo.org/main/en/about.xml> Gentoo experience</uri>
in the first paragraph.
2/ s/frustating/frustrating/
3/ Example should be plural in <p>Example of this are :</p>
4/ s/optimised/optimized/
5/ s/tho/though
Lionel.
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 12+ messages in thread
* [gentoo-dev] Re: CFLAGS paragraph submission for the GWN
2006-10-09 13:51 ` Lionel Bouton
@ 2006-10-09 14:12 ` Duncan
0 siblings, 0 replies; 12+ messages in thread
From: Duncan @ 2006-10-09 14:12 UTC (permalink / raw
To: gentoo-dev
Lionel Bouton <lionel-dev@bouton.name> posted
452A53E4.4000804@bouton.name, excerpted below, on Mon, 09 Oct 2006
15:51:32 +0200:
> I did hesitate :-) But as english isn't my native language, I chose to
> belive that 'tho' was now acceptable.
Well, I'd say it is in informal usage, email, IM and the like. Certainly
I'd argue so as I use it there. However, for something more formal like
GWN, it wouldn't be considered acceptable, and that's not likely to change
for another generation at least.
--
Duncan - List replies preferred. No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master." Richard Stallman
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN]
2006-10-09 0:42 [gentoo-dev] CFLAGS paragraph submission for the GWN Lionel Bouton
2006-10-09 1:30 ` Dice R. Random
@ 2006-10-14 8:49 ` Sebastian Bergmann
2006-10-14 9:16 ` Mike Frysinger
1 sibling, 1 reply; 12+ messages in thread
From: Sebastian Bergmann @ 2006-10-14 8:49 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1045 bytes --]
Lionel Bouton wrote:
> <warn>
> We would like to remind you that using anything beyond <c>-O2
> -fomit-frame-pointer -march/-mcpu/-mtune</c> in CFLAGS or CXXFLAGS (and
> <c>-mieee, -mabi</c> etc. on selected archs that tell you to do this),
> and using anything at all in LDFLAGS or ASFLAGS, is usually not worth it
> for most users.
Do we have an official list of recommended -march settings somewhere?
I, for one, still do not know what the right CFLAGS for my ThinkPad X60s
with its Intel Core Duo CPU are. At the moment I am using
CFLAGS="-march=pentium-m -O2 -pipe"
while http://gentoo-wiki.com/Safe_Cflags suggests either
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
or
CFLAGS="-march=pentium-m -msse3 -O2 -pipe -fomit-frame-pointer"
A tool that suggests CFLAGS based on /proc/cpuinfo and/or x86info would
be nice, too.
--
Sebastian Bergmann http://sebastian-bergmann.de/
GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN]
2006-10-14 8:49 ` Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN] Sebastian Bergmann
@ 2006-10-14 9:16 ` Mike Frysinger
2006-10-14 9:46 ` Wernfried Haas
2006-10-15 5:45 ` [gentoo-dev] Re: Recommended -march settings [was: " Ryan Hill
0 siblings, 2 replies; 12+ messages in thread
From: Mike Frysinger @ 2006-10-14 9:16 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1188 bytes --]
On Saturday 14 October 2006 04:49, Sebastian Bergmann wrote:
> Do we have an official list of recommended -march settings somewhere?
>
> I, for one, still do not know what the right CFLAGS for my ThinkPad X60s
> with its Intel Core Duo CPU are.
but what you actually want is a list that tells you what cpu value to pass
to -march/-mtune based upon the product name of the processor you're running
wikipedia.org is a good resource to find out the capabilities of your cpu ...
or you could simply compare `man gcc` to /proc/cpuinfo
> CFLAGS="-march=pentium-m -O2 -pipe"
should work fine
> while http://gentoo-wiki.com/Safe_Cflags suggests either
>
> CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
here's a good reason why gentoo-wiki is not official ... this is wrong. the
duo cpu's are not based on the pentium4 which is what the prescott is
> CFLAGS="-march=pentium-m -msse3 -O2 -pipe -fomit-frame-pointer"
there is no gcc flag at the moment for duo's which means the pentium-m
+ -msse3 is your best bet ... the base pentium-m did not include SSE3 support
so by simply using that -march, you do not have SSE3 enabled
-mike
[-- Attachment #2: Type: application/pgp-signature, Size: 827 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN]
2006-10-14 9:16 ` Mike Frysinger
@ 2006-10-14 9:46 ` Wernfried Haas
2006-10-14 10:48 ` Simon Stelling
` (2 more replies)
2006-10-15 5:45 ` [gentoo-dev] Re: Recommended -march settings [was: " Ryan Hill
1 sibling, 3 replies; 12+ messages in thread
From: Wernfried Haas @ 2006-10-14 9:46 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 995 bytes --]
On Sat, Oct 14, 2006 at 05:16:29AM -0400, Mike Frysinger wrote:
> On Saturday 14 October 2006 04:49, Sebastian Bergmann wrote:
> > Do we have an official list of recommended -march settings somewhere?
> [..]
> but what you actually want is a list that tells you what cpu value to pass
> to -march/-mtune based upon the product name of the processor you're running
What about creating an official document for both -march/mtune and
CFLAGS settings for different CPUs? If some other people like the idea
and no one else volunteers i can go poke the different arch teams,
toolchain folks and whoever else may be involved about it and compile
a list based on their input.
I wouldn't try to make it a ricer issue but rather a list of flags
that are known to be sane and supported by Gentoo.
cheers,
Wernfried
--
Wernfried Haas (amne) - amne at gentoo dot org
Gentoo Forums: http://forums.gentoo.org
IRC: #gentoo-forums on freenode - email: forum-mods at gentoo dot org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN]
2006-10-14 9:46 ` Wernfried Haas
@ 2006-10-14 10:48 ` Simon Stelling
2006-10-14 11:11 ` Christian Heim
2006-10-14 18:46 ` Mike Frysinger
2 siblings, 0 replies; 12+ messages in thread
From: Simon Stelling @ 2006-10-14 10:48 UTC (permalink / raw
To: gentoo-dev
Wernfried Haas wrote:
> What about creating an official document for both -march/mtune and
> CFLAGS settings for different CPUs? If some other people like the idea
> and no one else volunteers i can go poke the different arch teams,
> toolchain folks and whoever else may be involved about it and compile
> a list based on their input.
Check out these packages [1] before doing that, they will probably
supply all you need.
[1] http://packages.gentoo.org/search/?sstring=cpuinfo
--
Kind Regards,
Simon Stelling
Gentoo/AMD64 developer
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN]
2006-10-14 9:46 ` Wernfried Haas
2006-10-14 10:48 ` Simon Stelling
@ 2006-10-14 11:11 ` Christian Heim
2006-10-14 18:46 ` Mike Frysinger
2 siblings, 0 replies; 12+ messages in thread
From: Christian Heim @ 2006-10-14 11:11 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]
On Saturday, 14. October. 2006 11:46, Wernfried Haas wrote:
> On Sat, Oct 14, 2006 at 05:16:29AM -0400, Mike Frysinger wrote:
> > On Saturday 14 October 2006 04:49, Sebastian Bergmann wrote:
> > > Do we have an official list of recommended -march settings somewhere?
> >
> > [..]
> > but what you actually want is a list that tells you what cpu value to
> > pass to -march/-mtune based upon the product name of the processor you're
> > running
>
> What about creating an official document for both -march/mtune and
> CFLAGS settings for different CPUs? If some other people like the idea
> and no one else volunteers i can go poke the different arch teams,
> toolchain folks and whoever else may be involved about it and compile
> a list based on their input.
I would really like that, I've searched for such a list some times in the past
and the closest I could come up with is freehackers.org¹ and the cflags.sh
script in the forums.
TIA, Christian
[1] http://www.freehackers.org/gentoo/gccflags/
--
Christian Heim <phreak at gentoo.org>
GPG key ID: 9A9F68E6
Fingerprint: AEC4 87B8 32B8 4922 B3A9 DF79 CAE3 556F 9A9F 68E6
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN]
2006-10-14 9:46 ` Wernfried Haas
2006-10-14 10:48 ` Simon Stelling
2006-10-14 11:11 ` Christian Heim
@ 2006-10-14 18:46 ` Mike Frysinger
2 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2006-10-14 18:46 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
On Saturday 14 October 2006 05:46, Wernfried Haas wrote:
> What about creating an official document for both -march/mtune and
> CFLAGS settings for different CPUs?
last i checked they're all supported
-mike
[-- Attachment #2: Type: application/pgp-signature, Size: 827 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [gentoo-dev] Re: Recommended -march settings [was: Re: CFLAGS paragraph submission for the GWN]
2006-10-14 9:16 ` Mike Frysinger
2006-10-14 9:46 ` Wernfried Haas
@ 2006-10-15 5:45 ` Ryan Hill
1 sibling, 0 replies; 12+ messages in thread
From: Ryan Hill @ 2006-10-15 5:45 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1815 bytes --]
Mike Frysinger wrote:
> On Saturday 14 October 2006 04:49, Sebastian Bergmann wrote:
>> CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
> here's a good reason why gentoo-wiki is not official ... this is wrong. the
> duo cpu's are not based on the pentium4 which is what the prescott is
That was put there by me. The thing is, while the Core CPUs have more
in common with the Pentium-M micro-architecture, -march=pentium-m highly
favors generating x87 over SSE/SSE2 instructions, since on a Pentium-M
doing SSE/SSE2 was somewhere in the neighbourhood of 30% slower. Core
chips have improved decoding and use micro-op fusion to combine up to
four SSE instructions. Also, with code doing fp to int conversion or
single precision division, SSE scalar ops are the win on Core (though
not as big as Netburst) since x87 instructions have to write data to
memory and read it again to reduce precision.
Based on that I've been doing benchmarks with GCC 4.1 and trunk and I
usually find '-march=prescott -mfpmath=sse' to do a bit better than
'-march=pentium-m -mfpmath=sse -msse3', and just plain '-march=prescott'
to be near identical to plain '-march=pentium-m' (for those ebuilds that
call strip-flags ;), though the latter is on average <=1% faster.
'-march=pentium-m -msse3' has actually been the worst performer, though
I have no idea why it's slower than just '-march=pentium-m'. To be
honest I don't really trust GCC's SSE3 support in it's current state.
I've looked hard and long for an official answer to this but no one
seems to be able to give a concrete reason why one is better than the
other, other than "it's based on the Pentium-M". It _is_, but it's
still a very different animal. Until I got one I thought it'd be best
to document both.
--de.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2006-10-15 5:49 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-09 0:42 [gentoo-dev] CFLAGS paragraph submission for the GWN Lionel Bouton
2006-10-09 1:30 ` Dice R. Random
2006-10-09 10:51 ` [gentoo-dev] " Duncan
2006-10-09 13:51 ` Lionel Bouton
2006-10-09 14:12 ` Duncan
2006-10-14 8:49 ` Recommended -march settings [was: Re: [gentoo-dev] CFLAGS paragraph submission for the GWN] Sebastian Bergmann
2006-10-14 9:16 ` Mike Frysinger
2006-10-14 9:46 ` Wernfried Haas
2006-10-14 10:48 ` Simon Stelling
2006-10-14 11:11 ` Christian Heim
2006-10-14 18:46 ` Mike Frysinger
2006-10-15 5:45 ` [gentoo-dev] Re: Recommended -march settings [was: " Ryan Hill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox