Re: [2.6 patch] add a config option for -Os compilation

From: Adrian Bunk
Date: Sat Oct 18 2003 - 05:22:31 EST


On Wed, Oct 15, 2003 at 04:52:05PM -0700, Andrew Morton wrote:
>...
> I really doubt it. Kernel CPU footprint is dominated by dcache misses. If
> -Os reduces icache footprint it may even be a net win; people tend to
> benchmark things in tight loops, which favours fast code over small code.

The main effect of -Os compared to -O2 (besides disabling some
reordering of the code and prefetching) is the disabling of various
alignments. I doubt that's a win on all CPUs.

> > - I've already seen a report for an ICE in gcc 2.95 of a user compiling
> > kernel 2.4 with -Os [1]
>
> Well there's only one way to find out if we'll hit that. How's about you
> cook me a patch which switches to -Os unconditionally and we'll see how it
> goes?

I still dislike it, but the patch is below.

cu
Adrian


--- linux-2.6.0-test5-mm4/arch/arm/Makefile.old 2003-09-25 14:38:18.000000000 +0200
+++ linux-2.6.0-test5-mm4/arch/arm/Makefile 2003-09-25 14:40:47.000000000 +0200
@@ -14,8 +14,6 @@
GZFLAGS :=-9
#CFLAGS +=-pipe

-CFLAGS :=$(CFLAGS:-O2=-Os)
-
ifeq ($(CONFIG_FRAME_POINTER),y)
CFLAGS +=-fno-omit-frame-pointer -mapcs -mno-sched-prolog
endif
--- linux-2.6.0-test5-mm4/arch/h8300/Makefile.old 2003-09-25 14:38:18.000000000 +0200
+++ linux-2.6.0-test5-mm4/arch/h8300/Makefile 2003-09-25 14:38:24.000000000 +0200
@@ -34,7 +34,7 @@
ldflags-$(CONFIG_CPU_H8S) := -mh8300self

CFLAGS += $(cflags-y)
-CFLAGS += -mint32 -fno-builtin -Os
+CFLAGS += -mint32 -fno-builtin
CFLAGS += -g
CFLAGS += -D__linux__
CFLAGS += -DUTS_SYSNAME=\"uClinux\"
--- linux-2.6.0-test8/Makefile.old 2003-10-18 12:15:51.000000000 +0200
+++ linux-2.6.0-test8/Makefile 2003-10-18 12:16:26.000000000 +0200
@@ -275,7 +275,7 @@
CPPFLAGS := -D__KERNEL__ -Iinclude \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include)

-CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
+CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
-fno-strict-aliasing -fno-common
AFLAGS := -D__ASSEMBLY__

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/