Shrinking the kernel with gcc
Posted Jan 24, 2004 17:01 UTC (Sat) by
Duncan (guest, #6647)
Parent article:
Shrinking the kernel with gcc
Trying this now.. On a dual Opteron system, thus amd64/x86_64 arch, SMP
kernel, from the Mdk 2.4.22, release 27 package (which includes backporting
of some of the recent security patches, in case anyone is wondering), with
pretty much everything left as modules, except reiserfs, which I build-in since
that's what I run, to avoid having an initrd.
With -Os and -funit-at-a-time, fully bzip2ed size went from 1.16 (base 10)
Megabytes, to 1.05, thus shrinking >100 kb (base 10). Unfortunately, I didn't
think to get the full-size size of the normal -O2 version from /usr/src/linux b4 I
recompiled with the new parameters.
There is, however, an additional complication with -mregparm=3, not
mentioned in the article. Acccording to the GCC manpage, not only must all
modules be built with it (as covered by the article), but so must the main
system libraries, which I take to include glibc, etc. if anything is built with it.
At this point, I'm not going to rebuild them, just to see how much better I can
get it. However, I AM trying the kernel rebuild (as I write), to check size, and
will of course try rebooting to it if the rebuild completes without issue. Maybe
I'm interpreting the library reference incorrectly, and that doesn't apply to the
kernel, only to userspace builds.
We'll see..
Duncan
(
Log in to post comments)