lkml.org 
[lkml]   [2003]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [2.6 patch] add a config option for -Os compilation
On Sun, Sep 14, 2003 at 03:52:45PM +0100, Russell King wrote:
>
> But it doesn't make sense - you include a generic configuration option
> which people will see, yet it makes no effect on ARM - seems to be rather
> silly putting it there in the first place.
>
> Also, do users particularly care what -Os and -O2 mean?

The "If unsure, say N." should take care of it. People who really need
small kernels usually know what -Os means.

> Maybe you need to change init/Kconfig to be something like the following,
> and reinstate the change to the ARM makefile:
>
> config OPTIMIZE_FOR_SIZE
> bool "Optimize for size" if EXPERIMENTAL
> default n if !ARM
> default y if ARM

That's a good idea.

The patch below does this for ARM and H8300.
Since there was no H8300 symbol, I added it to arch/h8300/Kconfig
similar to the symbols on other architectures.

> help
> Enabling this option will cause the compiler to reduce the code
> size of the kernel by disabling certain optimisations. However,
> the resulting kernel may run faster due to more efficient
> cache utilisation.
>...

I don't like this part, it would cause confusion. -O2 is more widely
tested, and though if there might be small improvements on some CPUs
with some compiler versions, it's untested whether -Os might cause worse
performance of some fast path code in any area of the kernel.
OPTIMIZE_FOR_SIZE should, although of low risk, be an "only use it if
you know what you are doing" option.


diffstat output for the patch below:

Makefile | 8 +++++++-
arch/arm/Makefile | 2 --
arch/h8300/Kconfig | 4 ++++
arch/h8300/Makefile | 2 +-
init/Kconfig | 10 ++++++++++
5 files changed, 22 insertions(+), 4 deletions(-)


cu
Adrian

--- linux-2.6.0-test5-mm4/init/Kconfig.old 2003-09-25 14:38:18.000000000 +0200
+++ linux-2.6.0-test5-mm4/init/Kconfig 2003-09-25 14:47:12.000000000 +0200
@@ -65,6 +65,16 @@

menu "General setup"

+config OPTIMIZE_FOR_SIZE
+ bool "Optimize for size" if EXPERIMENTAL
+ 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.
+
config SWAP
bool "Support for paging of anonymous memory"
depends on MMU
--- linux-2.6.0-test5-mm4/Makefile.old 2003-09-25 14:38:18.000000000 +0200
+++ linux-2.6.0-test5-mm4/Makefile 2003-09-25 14:40:26.000000000 +0200
@@ -274,7 +274,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 \
-fno-strict-aliasing -fno-common
AFLAGS := -D__ASSEMBLY__

@@ -421,6 +421,12 @@
# ---------------------------------------------------------------------------


+ifdef CONFIG_OPTIMIZE_FOR_SIZE
+CFLAGS += -Os
+else
+CFLAGS += -O2
+endif
+
ifndef CONFIG_FRAME_POINTER
CFLAGS += -fomit-frame-pointer
endif
--- 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/Kconfig.old 2003-09-25 14:43:27.000000000 +0200
+++ linux-2.6.0-test5-mm4/arch/h8300/Kconfig 2003-09-25 14:43:44.000000000 +0200
@@ -5,6 +5,10 @@

mainmenu "uClinux/h8300 (w/o MMU) Kernel Configuration"

+config H8300
+ bool
+ default y
+
config MMU
bool
default n
--- 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\"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.115 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site