optimize with -O2 or -O?

Simon Barner barner at in.tum.de
Tue Nov 4 00:59:10 PST 2003

> I read the gcc man page. It is not clear what -O implys. Is -O equal to 
> -O1 or -O2? If I wish to optimize making does it make sense to add 
> CFLAGS=-O2 in the make.conf(5)?


-O == -O1 (see `info gcc' -> Invoking GCC -> Optimize Options)

It is recommended not to use anything higher than -O since GCC is known to
procduce broken code on higher optimization levels.

Depending on what gcc version you are using, also specifing CPUTYPE=...
in /etc/make.conf might bring you troubles (for certain CPUs, e.g. 
athlon IIRC).

Post the output of `gcc --version' and people will be able to tell you.

What you could try is to use -O2 for some selected ports, but the question
is whether you will see a measurable performance gain.

Some ports that are known to build alright at -O2 (e.g. mplayer) have

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: Digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20031104/9b8fd0d8/attachment.bin

More information about the freebsd-questions mailing list