svn commit: r316132 - head/sys/boot/i386/boot2

Bruce Evans brde at optusnet.com.au
Thu Mar 30 07:37:18 UTC 2017


On Thu, 30 Mar 2017, Warner Losh wrote:

> On Thu, Mar 30, 2017 at 12:23 AM, Bruce Evans <brde at optusnet.com.au> wrote:
>> I doubt that gcc-6.3 is very broken.  Did its CFLAGS even have -Os?
>
> Yes. boot2 doesn't use the kernel CFLAGS.

I know.  I even understand most of the magic.

My point was that with all the ifdef obfuscations, the flags might not even
have -Os.  The bug report didn't say.  It showed a large set of CFLAGS with
-O2 for an unrelated part of the build.

>> Kernel CFLAGS are still broken even for gcc-4.2, by sprinkling inline
>> parameter magic that was more needed for gcc-3.3.  The magic isn't
>> really right for gcc-4.2, and breaks -Os for kernels.
>
> There is different magic for boot2.

I know that even better.  boot2 is better tuned to save space since this
is necessary and possible, but to tune it has to use even more specific
flags which are more likely to break.

>> The magic might
>> be wronger for gcc-6.3, though it would be a compiler bug to not
>> just ignore it if it is nonsense.  clang doesn't provide any control
>> over inlining AFAIK, but ignores gcc directive to limit it and does
>> too much.
>
> Yes. It does. Hence my glowing review of 6.3 :) But you are right. I'm
> likely being overly harsh without commanding enough facts to get past
> my preconceived notions... I don't know if this is a simple compiler
> bug, lack of proper options, or a need to do things differently.
> Latter day versions of gcc have many more knobs to turn here. I don't
> know yet if turning any of them will be helpful. I'm looking to

But -Os should just work to save maximal space.  For inlining, this
usually means not doing it.  But always inline if the result is smaller.
boot2 has some manual inlining (static inline...) which might be a
(small) problem.  It is meant to save space, but might do the opposite.

> automate the knob turning so that we can at least see which optimizer
> options have an effect on the size. I doubt more than half a dozen
> have any useful effect on the size, and finding the right combination
> likely will suffice. Or we wait for gcc 7 and hope for the best...

I tried changing all of -fomit-frame-pointer, -mrtd and -mregparam a
few years ago.  They all help a little.  -mrtd and -mregparam are then
main things that boot2 uses that biosboot did't.

I still use biosboot, updated for elf and EDD and with many fixes.
The only special CFLAGS that it needs are -Os -fomit-frame-pointer.
This works for both gcc-3.3 and gcc-4.2.1, with the latter producing
a result 16 bytes smaller.

Bruce


More information about the svn-src-head mailing list