Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Oct 2007 10:02:56 -0400
From:      "Josh Carroll" <josh.carroll@gmail.com>
To:        "Kris Kennaway" <kris@freebsd.org>
Cc:        freebsd-current@freebsd.org, "Stephan F. Yaraghchi" <stephan@yaraghchi.org>
Subject:   Re: loader breaks with -O2 optimizations
Message-ID:  <8cb6106e0710310702w774c3c39sdcc9bf4fcf87d043@mail.gmail.com>
In-Reply-To: <47284E4F.5030008@FreeBSD.org>
References:  <25f52a3d0710300732x425f0c45vde1a29361096c018@mail.gmail.com> <47284E4F.5030008@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8cb6106e0710310702w774c3c39sdcc9bf4fcf87d043>