Talk:Safe Cflags
From Gentoo Linux Wiki
[edit] What's wrong with -Os?
Greetings, I'd like someone to explain why this switch is not recommended. I understand gcc's documentation as stating that -Os, -O1 and -O2 do only safe optimizations, without doing anything that would compromise the correctness of the resulting executable (as does happen with -O3 and above).
I was one of those crazy guys who'd been using -O3 in an effort to get more speed, until I read an article explaining how for most modern processors -Os actually gives you faster code for it's much more cache-friendly, whilst -O3 isn't plus you're more constrained by the hard disk as its binaries are way bigger.
Since then, I've been using -Os with no problems on a Sempron 3200+ - and I do perceive my system to be more responsive. I know that just 'cause something works for me it cannot be assumed it will for everyone, though I'd like to know the rationale for this not-recommended status.
Thanks in advance!
- There's nothing "wrong" with it. The article just follows the official recommendations. /Ni1s 19:58, 5 November 2009 (GMT)
- In certain cases, -Os is a faster optimization level than -O2 or -O3. Older processors, such as the Pentium II, will actually perform better overall because the whole system is slow when compared to modern systems. So, steps to reduce the size of the binary, and also the length of time to compile the binary, are worthwhile. (Note: I have never had a problem using -Os, your mileage may vary.) On faster systems, -O2 is far better than -Os, and -- in certain cases -- -O3 is better than -O2. In my opinion, -O3 should be used only for specific packages where there is a tangible benefit. --Titan 06:12, 7 November 2009 (GMT)