From: Andi Kleen The upcomming gcc 3.4 has a new compilation mode called unit-at-a-time. What it does is to first load the whole file into memory and then generate the output. This allows it to use a better inlining strategy, drop unused static functions and use -mregparm automatically for static functions. It does not seem to compile significantly slower. This is also available in some of the 3.3 based "hammer branch" compilers used in distributions (at least in SuSE and Mandrake) Some tests show impressive .text shrinkage from unit-at-a-time. e.g. here is the same kernel compiled with -fno-unit-at-a-time and -funit-at-a-time with a gcc 3.4 snapshot. The gains are really impressive: text data bss dec hex filename 4129346 708629 207240 5045215 4cfbdf vmlinux-nounitatatime 3999250 674853 207208 4881311 4a7b9f vmlinux-unitatatime .text shrinks by over 130KB!. And .data shrinks too. At first look the numbers look nearly too good to be true, but they have been verified with several configurations and seem to be real. It looks like we have a lot of stupid inlines or dead functions. I'm really not sure why it is that much better. But it's hard to argue with hard numbers. [A bloat-o-meter comparision between the two vmlinuxes can be found in http://www.firstfloor.org/~andi/unit-vs-no-unit.gz . It doesn't show any obvious candidates unfortunately, just lots of small changes] With the gcc 3.3-hammer from SuSE 9.0 the gains are a bit smaller, but still noticeable (>100KB on .text) This patch enables -funit-at-a-time on ia32 if the compiler is gcc-3.4 or later. We had several reports of gcc-3.3 producing very early lockups. --- 25-akpm/arch/i386/Makefile | 4 ++++ 25-akpm/arch/x86_64/Makefile | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff -puN arch/i386/Makefile~use-funit-at-a-time arch/i386/Makefile --- 25/arch/i386/Makefile~use-funit-at-a-time Tue Jan 27 15:40:09 2004 +++ 25-akpm/arch/i386/Makefile Tue Jan 27 15:42:26 2004 @@ -73,6 +73,10 @@ cflags-$(CONFIG_X86_ELAN) := -march=i486 GCC_VERSION := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) cflags-$(CONFIG_REGPARM) += $(shell if [ $(GCC_VERSION) -ge 0300 ] ; then echo "-mregparm=3"; fi ;) +# Enable unit-at-a-time mode when possible. It shrinks the +# kernel considerably. +CFLAGS += $(call check_gcc,-funit-at-a-time,) + CFLAGS += $(cflags-y) # Default subarch .c files diff -puN arch/x86_64/Makefile~use-funit-at-a-time arch/x86_64/Makefile --- 25/arch/x86_64/Makefile~use-funit-at-a-time Tue Jan 27 15:42:34 2004 +++ 25-akpm/arch/x86_64/Makefile Tue Jan 27 15:44:44 2004 @@ -52,7 +52,10 @@ CFLAGS += -Wno-sign-compare ifneq ($(CONFIG_DEBUG_INFO),y) CFLAGS += -fno-asynchronous-unwind-tables endif -#CFLAGS += $(call check_gcc,-funit-at-a-time,) + +# Enable unit-at-a-time mode when possible. It shrinks the +# kernel considerably. +CFLAGS += $(call check_gcc,-funit-at-a-time,) head-y := arch/x86_64/kernel/head.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o _