Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 May 2011 12:02:43 -0400
From:      Arnaud Lacombe <lacombar@gmail.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-current@freebsd.org, Dimitry Andric <dim@freebsd.org>
Subject:   Re: [PATCH] Fix CFLAGS overwrite by Makefile
Message-ID:  <BANLkTimgSdATAUyMbFyCPNigRF2vP8%2BA-A@mail.gmail.com>
In-Reply-To: <201105250943.15362.jhb@freebsd.org>
References:  <1306267772-31084-1-git-send-email-lacombar@gmail.com> <4DDC17E5.2020700@FreeBSD.org> <BANLkTi=wbrvXHDiKix8DYYi9kjk5N-_vBw@mail.gmail.com> <201105250943.15362.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

On Wed, May 25, 2011 at 9:43 AM, John Baldwin <jhb@freebsd.org> wrote:
> On Tuesday, May 24, 2011 5:30:37 pm Arnaud Lacombe wrote:
>> Hi,
>>
>> On Tue, May 24, 2011 at 4:41 PM, Dimitry Andric <dim@freebsd.org> wrote:
>> > On 2011-05-24 22:09, Arnaud Lacombe wrote:
>> >>
>> >> Many Makefile (espectially under sys/boot/) overwrite the value of
> CFLAGS.
>> >> This is an issue if you want to generate code for a specific CPU as
> before
>> >> the
>> >> Makefile is interpreted, CFLAGS might already have been set with CPU
>> >> specific
>> >> settings by<bsd.cpu.mk>, which is source from sys.mk.
>> >
>> > ...
>> >>
>> >> --- a/sys/boot/i386/boot2/Makefile
>> >> +++ b/sys/boot/i386/boot2/Makefile
>> >
>> > ...
>> >
>> > The problem with this patch is that for some of the things you fixed,
>> > stuff like boot-time programs, you NEVER want any CPU specific setting=
s!
>> > You must use the default, lowest common denominator setting instead, o=
r
>> > there is no guarantee the boot program will be correct.
>> >
>> To use your argument against you: with the default, the boot program
>> is not correct (see below).
>
> Thousands of machines succesfully booting FreeBSD would seem to contradic=
t
> your assertion.
>
my assertion is backed by experiment, so I'm fine with the contradiction.

>> > So that is why these Makefiles purposefully overwrite CFLAGS. it is no=
t
>> > by accident.
>> You just might be right, but unless the code say the overwrite is
>> _on_purpose_, I would not assume the state of mind of the author, one
>> way or another.
>
> The boot code is certainly intended to be something that works across the
> board. =A0Also, I doubt you will see any user-visible performance differe=
nce
> from changing the optimization options for the boot code.
>
Saving a few kilobytes of space might be more important than speed in
some environment.

>> > Besides, for space-constrained things like boot2, you
>> > might not even be able to compile it when using non-standard settings,
>> > since the code might grow too large.
>> >
>> or can shrink by using more optimized instructions.
>
> Well, your test in a later e-mail is a bit flawed. =A0GCC tends to insert
> a lot of padding for newer CPUs to align things on more optimal boundarie=
s.
>
That does not explain at all why the default setting always produces
the worst code, size-wise.

> We run 'sed' over the assembly version of boot2 to strip all that out.
>
... to save 4 bytes.

> However, the more important point for the boot code is that it needs to
> just work.
>
and it does not, because gcc defaults are _bad_.

 - Arnaud



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTimgSdATAUyMbFyCPNigRF2vP8%2BA-A>