From: Adrian Bunk Allow the kernel to be built with `-Os'. It requires CONFIG_EMBEDDED. This is to make it "hard to get at" because one gcc version (3.2.x I think) from RH9 generates crashy kernels with this option set. Makefile | 8 +++++++- arch/arm/Makefile | 2 -- arch/h8300/Kconfig | 4 ++++ arch/h8300/Makefile | 2 +- init/Kconfig | 10 ++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff -puN arch/arm/Makefile~gcc-Os-if-embedded arch/arm/Makefile --- 25/arch/arm/Makefile~gcc-Os-if-embedded 2003-10-26 16:51:55.000000000 -0800 +++ 25-akpm/arch/arm/Makefile 2003-10-26 16:51:55.000000000 -0800 @@ -14,8 +14,6 @@ OBJCOPYFLAGS :=-O binary -R .note -R .co GZFLAGS :=-9 #CFLAGS +=-pipe -CFLAGS :=$(CFLAGS:-O2=-Os) - ifeq ($(CONFIG_FRAME_POINTER),y) CFLAGS +=-fno-omit-frame-pointer -mapcs -mno-sched-prolog endif diff -puN arch/h8300/Kconfig~gcc-Os-if-embedded arch/h8300/Kconfig --- 25/arch/h8300/Kconfig~gcc-Os-if-embedded 2003-10-26 16:51:55.000000000 -0800 +++ 25-akpm/arch/h8300/Kconfig 2003-10-26 16:51:55.000000000 -0800 @@ -5,6 +5,10 @@ mainmenu "uClinux/h8300 (w/o MMU) Kernel Configuration" +config H8300 + bool + default y + config MMU bool default n diff -puN arch/h8300/Makefile~gcc-Os-if-embedded arch/h8300/Makefile --- 25/arch/h8300/Makefile~gcc-Os-if-embedded 2003-10-26 16:51:55.000000000 -0800 +++ 25-akpm/arch/h8300/Makefile 2003-10-26 16:51:55.000000000 -0800 @@ -34,7 +34,7 @@ cflags-$(CONFIG_CPU_H8S) := -ms 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\" diff -puN init/Kconfig~gcc-Os-if-embedded init/Kconfig --- 25/init/Kconfig~gcc-Os-if-embedded 2003-10-26 16:51:55.000000000 -0800 +++ 25-akpm/init/Kconfig 2003-10-26 16:51:55.000000000 -0800 @@ -196,6 +196,16 @@ config EPOLL source "drivers/block/Kconfig.iosched" +config CC_OPTIMIZE_FOR_SIZE + bool "Optimize for size" if EMBEDDED + default y if ARM || H8300 + default n + help + Enabling this option will pass "-Os" instead of "-O2" to gcc + resulting in a smaller kernel. + + If unsure, say N. + endmenu # General setup diff -puN Makefile~gcc-Os-if-embedded Makefile --- 25/Makefile~gcc-Os-if-embedded 2003-10-26 16:51:55.000000000 -0800 +++ 25-akpm/Makefile 2003-10-26 16:51:55.000000000 -0800 @@ -275,7 +275,7 @@ NOSTDINC_FLAGS = -nostdinc -iwithprefix CPPFLAGS := -D__KERNEL__ -Iinclude \ $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \ +CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common AFLAGS := -D__ASSEMBLY__ @@ -431,6 +431,12 @@ libs-y := $(libs-y1) $(libs-y2) # --------------------------------------------------------------------------- +ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE +CFLAGS += -Os +else +CFLAGS += -O2 +endif + ifndef CONFIG_FRAME_POINTER CFLAGS += -fomit-frame-pointer endif _