PDA

View Full Version : -O vs -O2: Opinions Please


ter2007
January 11th, 2009, 08:12
I have always used CFLAGS= -O.

I read somewhere that the FBSD team thinks there might be possible problems in floating point if -O2 is used, and that is why I have always used -O (and -pipe). Stability is much more important to me that anything else.

Do you other FreeBSD people use -O2 without any problems. I have read that you do not want to do this on the kernel, and I am pretty sure it defaults to that, but what about the ports?

Now, I am doing this on a pentium4 which means the compiler might be more mature??????????

I would really appreciate your opinions on this. I'm compiling the 7-1 kernel as I type this and might try -O2 for the ports.

Andrius
January 11th, 2009, 09:28
.if defined(%POSIX)
CC ?= c89
CFLAGS ?= -O
.else
CC ?= cc
.if ${MACHINE_ARCH} == "arm"
CFLAGS ?= -O -fno-strict-aliasing -pipe
.else
CFLAGS ?= -O2 -fno-strict-aliasing -pipe
.endif
.endif

Those are the defaults, so even kernel will most likely use "-O2 -fno-strict-aliasing -pipe" if you don't change them. Looks safe enough if FreeBSD uses them by default, doesn't it?

graudeejs
January 11th, 2009, 09:54
Stick to the defaults
Otherwise use search to find out public opinion on changing defaults cflags in FreeBSD!!!


all you want to change is
CPUTYPE?=
flag

for pentium4 it might be pentium4, pentium4e or prescott
pentium4 is safe

ter2007
January 11th, 2009, 10:05
Those are the defaults, so even kernel will most likely use "-O2 -fno-strict-aliasing -pipe" if you don't change them. Looks safe enough if FreeBSD uses them by default, doesn't it?



Thank you. I did not know that.

ter2007
January 11th, 2009, 10:10
Stick to the faults
Otherwise use search to find out public opinion on changing defaults cflags in FreeBSD!!!


all you want to change is
CPUTYPE?=
flag

for pentium4 it might be pentium4, pentium4e or prescott
pentium4 is safe


Hmmmmm. So don't even set CFLAGS unless you have a reason to. Dang. All my old packages are CFLAGS= -O -pipe.

I have read public opinion; lots of it. I don't know' it is said that the difference between -O and -O2 is negligiable.

I'm not even going to set CFLAGS anymore unless I have a good reason. Thanks.

kamikaze
January 12th, 2009, 09:00
I experimented A LOT with CFLAGS. I dug really deep into the gcc documentation and tried and benchmarked a lot.

After all this testing it is my solemn conviction that the defaults are just fine and deviating from them is not worth the trouble.

ephemera
January 12th, 2009, 16:49
I experimented A LOT with CFLAGS. I dug really deep into the gcc documentation and tried and benchmarked a lot.

After all this testing it is my solemn conviction that the defaults are just fine and deviating from them is not worth the trouble.Same here. -O2 is definately where the sweet spot is. -O3 tends to somewhat faster depending on the kind of program and programmer ;) OTH, -O is noticbly slower than -O2 in many cases.