Commit ffd0cf49 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Add `gcc -Os' config option

From: Adrian Bunk <bunk@fs.tum.de>

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.
parent a93fabd3
...@@ -275,7 +275,7 @@ NOSTDINC_FLAGS = -nostdinc -iwithprefix include ...@@ -275,7 +275,7 @@ NOSTDINC_FLAGS = -nostdinc -iwithprefix include
CPPFLAGS := -D__KERNEL__ -Iinclude \ CPPFLAGS := -D__KERNEL__ -Iinclude \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) $(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 -fno-strict-aliasing -fno-common
AFLAGS := -D__ASSEMBLY__ AFLAGS := -D__ASSEMBLY__
...@@ -431,6 +431,12 @@ libs-y := $(libs-y1) $(libs-y2) ...@@ -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 ifndef CONFIG_FRAME_POINTER
CFLAGS += -fomit-frame-pointer CFLAGS += -fomit-frame-pointer
endif endif
......
...@@ -14,8 +14,6 @@ OBJCOPYFLAGS :=-O binary -R .note -R .comment -S ...@@ -14,8 +14,6 @@ OBJCOPYFLAGS :=-O binary -R .note -R .comment -S
GZFLAGS :=-9 GZFLAGS :=-9
#CFLAGS +=-pipe #CFLAGS +=-pipe
CFLAGS :=$(CFLAGS:-O2=-Os)
ifeq ($(CONFIG_FRAME_POINTER),y) ifeq ($(CONFIG_FRAME_POINTER),y)
CFLAGS +=-fno-omit-frame-pointer -mapcs -mno-sched-prolog CFLAGS +=-fno-omit-frame-pointer -mapcs -mno-sched-prolog
endif endif
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
mainmenu "uClinux/h8300 (w/o MMU) Kernel Configuration" mainmenu "uClinux/h8300 (w/o MMU) Kernel Configuration"
config H8300
bool
default y
config MMU config MMU
bool bool
default n default n
......
...@@ -34,7 +34,7 @@ cflags-$(CONFIG_CPU_H8S) := -ms ...@@ -34,7 +34,7 @@ cflags-$(CONFIG_CPU_H8S) := -ms
ldflags-$(CONFIG_CPU_H8S) := -mh8300self ldflags-$(CONFIG_CPU_H8S) := -mh8300self
CFLAGS += $(cflags-y) CFLAGS += $(cflags-y)
CFLAGS += -mint32 -fno-builtin -Os CFLAGS += -mint32 -fno-builtin
CFLAGS += -g CFLAGS += -g
CFLAGS += -D__linux__ CFLAGS += -D__linux__
CFLAGS += -DUTS_SYSNAME=\"uClinux\" CFLAGS += -DUTS_SYSNAME=\"uClinux\"
......
...@@ -196,6 +196,19 @@ config EPOLL ...@@ -196,6 +196,19 @@ config EPOLL
source "drivers/block/Kconfig.iosched" 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.
WARNING: some versions of gcc may generate incorrect code with this
option. If problems are observed, a gcc upgrade may be needed.
If unsure, say N.
endmenu # General setup endmenu # General setup
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment