loader breaks with -O2 optimizations

Oliver Fromme olli at lurza.secnetix.de
Mon Nov 12 10:16:02 PST 2007

Stephan F. Yaraghchi wrote:
 > Oliver Fromme wrote:
 > > Stephan F. Yaraghchi wrote:
 > > > After making world on a freshly installed 7.0-BETA1
 > > > the system does not boot anymore due to a broken loader:
 > > > [...]
 > > > I found out that the following line in my make.conf causes
 > > > the problem:
 > > > 
 > > > CFLAGS= -O2 -funroll-loops -pipe
 > > > 
 > > > After changing down to -O1 and making /usr/src/sys/boot again
 > > > the systems behaves properly at boot.
 > > 
 > > Have you tried with the default flags?  i.e. simply remove
 > > the CFLAGS line from your make.conf.  Does the loader still
 > > break?
 > > 
 > > Best regards
 > >    Oliver
 > > 
 > > PS:  The default flags are:  -O2 -fno-strict-aliasing -pipe
 > > (see /usr/share/mk/sys.mk)
 > Hi Oliver,
 > I added -O2 -fno-strict-aliasing -pipe to the make.conf and it worked too!

Nice to hear that it works, but ...  Actually my point was
that you should _remove_ the "CFLAGS=" line entirely from
your make.conf, instead of replacing a bogus set of flags
with a different set of flags that happens to work in this
particular case.

Even if the flags you inserted are the normal default flags,
some piece of software might want to use different flags for
certain reasons.  Your "CFLAGS=" line might break those, as
others have already explained in this thread.

A general rule of thumb is to never touch CFLAGS globally,
but only for specific software, if you're sure that it
actually benefits from your modified flags.  For example,
some ports offer options to enable optimized CFLAGS, for
that particular port only.


Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"anyone new to programming should be kept as far from C++ as
possible;  actually showing the stuff should be considered a
criminal offence" -- Jacek Generowicz

More information about the freebsd-current mailing list