Re: loader breaks with -O2 optimizations

From: Josh Carroll <josh.carroll_at_gmail.com>
Date: Wed, 31 Oct 2007 10:02:56 -0400
> Maybe, what happens if you use just -O2 -pipe? -funroll-loops is not an
> appropriate thing to be using globally anyway, unless your intention is
> to randomly make some code slower.

I encountered the same thing in 7.0-BETA1 and resolved it with an edit
to make.conf, specifically:

.if ! ${.CURDIR:M*/boot/i386/boot2*}
CFLAGS+=-O2 -pipe
CXXFLAGS+=-O2 -pipe
.endif

That way, everything else in world is built with -O2 (which I have
never had a problem with, by the way), but loader's CFLAGS are
retained.

The crux of the problem is that gcc takes the LAST -O option as the
effective one. That is:

gcc -Os ... -O2

is the equivalent of:

gcc -O2 ...

Which is exactly what's happening in this case (the loader Makefile
sets CFLAGS to include -Os to optimize for size).

Short of finding a way to prepend to CFLAGS so that a Makefile's
CFLAGS are appended to what is defined in make.conf, I don't see
another way around this. The make.conf hack seems to work, though.

Regards,
Josh
Received on Wed Oct 31 2007 - 13:03:14 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:20 UTC