kernel: only optimized for size if small_flash
authorMathias Kresin <dev@kresin.me>
Mon, 9 Jul 2018 18:48:56 +0000 (20:48 +0200)
committerMathias Kresin <dev@kresin.me>
Thu, 12 Jul 2018 16:15:32 +0000 (18:15 +0200)
Add a new config option to allow to select the default compile
optimization level for the kernel.

Select the optimization for size by default if the small_flash feature is
set. Otherwise "Optimize for performance" is set.

Add the small_flash feature flag to all (sub)targets which had the
optimization for size in their default kernel config.

Remove CC_OPTIMIZE_FOR_* symbols from all kernel configs to apply the new
setting.

Exceptions to the above are:

  - lantiq, where the optimization for size is only required for the
    xway_legacy subtarget but was set for the whole target
  - mediatek, ramips/mt7620 & ramips/mt76x8 where boards should have
    plenty of space and an optimization for size doesn't make much sense
  - rb532, which has 128MByte flash

Signed-off-by: Mathias Kresin <dev@kresin.me>
29 files changed:
config/Config-kernel.in
target/linux/adm5120/Makefile
target/linux/adm5120/config-3.18
target/linux/at91/config-4.9
target/linux/ath79/tiny/config-default
target/linux/au1000/Makefile
target/linux/au1000/config-3.18
target/linux/generic/config-3.18
target/linux/generic/config-4.14
target/linux/generic/config-4.9
target/linux/lantiq/config-4.14
target/linux/layerscape/armv8_32b/config-4.9
target/linux/layerscape/armv8_64b/config-4.9
target/linux/mcs814x/Makefile
target/linux/mcs814x/config-3.18
target/linux/mediatek/mt7622/config-4.14
target/linux/ppc40x/Makefile
target/linux/ppc40x/config-3.18
target/linux/ppc44x/Makefile
target/linux/ppc44x/config-3.18
target/linux/ramips/mt7620/config-4.14
target/linux/ramips/mt76x8/config-4.14
target/linux/ramips/rt288x/config-4.14
target/linux/ramips/rt288x/target.mk
target/linux/ramips/rt305x/config-4.14
target/linux/ramips/rt305x/target.mk
target/linux/ramips/rt3883/config-4.14
target/linux/ramips/rt3883/target.mk
target/linux/rb532/config-4.9

index d2d1909..58f7d60 100644 (file)
@@ -806,3 +806,25 @@ config KERNEL_DEVKMEM
          Say Y here if you want to support the /dev/kmem device. The
          /dev/kmem device is rarely used, but can be used for certain
          kind of kernel debugging operations.
+
+#
+# compile optimiziation setting
+#
+choice
+       prompt "Compiler optimization level"
+       default KERNEL_CC_OPTIMIZE_FOR_SIZE if SMALL_FLASH
+
+config KERNEL_CC_OPTIMIZE_FOR_PERFORMANCE
+       bool "Optimize for performance"
+       help
+         This is the default optimization level for the kernel, building
+         with the "-O2" compiler flag for best performance and most
+         helpful compile-time warnings.
+
+config KERNEL_CC_OPTIMIZE_FOR_SIZE
+       bool "Optimize for size"
+       help
+         Enabling this option will pass "-Os" instead of "-O2" to
+         your compiler resulting in a smaller kernel.
+
+endchoice
index 56916bd..fbfaf6d 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 BOARD:=adm5120
 BOARDNAME:=Infineon/ADMtek ADM5120
-FEATURES:=low_mem source-only
+FEATURES:=low_mem small_flash source-only
 SUBTARGETS:=router_le router_be rb1xx
 INITRAMFS_EXTRA_FILES:=
 
index 000424c..231877e 100644 (file)
@@ -45,7 +45,6 @@ CONFIG_ARCH_SUSPEND_POSSIBLE=y
 CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
 CONFIG_ARM_AMBA=y
 CONFIG_BUILD_BIN2C=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CEVT_R4K=y
 CONFIG_CLONE_BACKWARDS=y
 CONFIG_CMDLINE="console=ttyAM0,115200 rootfstype=squashfs,jffs2"
index 6ccc34b..a44d3ac 100644 (file)
@@ -58,8 +58,6 @@ CONFIG_BLK_DEV_SD=y
 # CONFIG_BPF_SYSCALL is not set
 # CONFIG_BRIDGE is not set
 CONFIG_CACHE_L2X0=y
-CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_CLKDEV_LOOKUP=y
 CONFIG_CLKSRC_OF=y
 CONFIG_CLKSRC_PROBE=y
index f5a485d..01af544 100644 (file)
@@ -1,5 +1,3 @@
-# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_BLK_MQ_PCI=y
 CONFIG_LEDS_RESET=y
 CONFIG_OF_ADDRESS_PCI=y
index ddc28d0..3a79b4c 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 ARCH:=mipsel
 BOARD:=au1000
 BOARDNAME:=RMI/AMD AU1x00
-FEATURES:=squashfs usb pci source-only
+FEATURES:=squashfs usb pci small_flash source-only
 SUBTARGETS:=au1500 au1550
 MAINTAINER:=Florian Fainelli <florian@openwrt.org>
 
index cb2eee2..abce20a 100644 (file)
@@ -11,7 +11,6 @@ CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
 CONFIG_ARCH_REQUIRE_GPIOLIB=y
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
 CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CEVT_R4K=y
 CONFIG_CLONE_BACKWARDS=y
 CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock0 rootfstype=squashfs,jffs2"
index 0f66960..0eec5c6 100644 (file)
@@ -580,7 +580,6 @@ CONFIG_CAVIUM_OCTEON_HELPER=y
 # CONFIG_CAVIUM_OCTEON_SIMULATOR is not set
 # CONFIG_CAVIUM_OCTEON_SOC is not set
 # CONFIG_CB710_CORE is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 # CONFIG_CC_STACKPROTECTOR is not set
 CONFIG_CC_STACKPROTECTOR_NONE=y
 # CONFIG_CC_STACKPROTECTOR_REGULAR is not set
index 3ed2fed..e7304b4 100644 (file)
@@ -717,8 +717,6 @@ CONFIG_CARDBUS=y
 # CONFIG_CB710_CORE is not set
 # CONFIG_CC10001_ADC is not set
 # CONFIG_CCS811 is not set
-CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 # CONFIG_CC_STACKPROTECTOR is not set
 CONFIG_CC_STACKPROTECTOR_NONE=y
 # CONFIG_CC_STACKPROTECTOR_REGULAR is not set
index 83abfdc..011172b 100644 (file)
@@ -680,8 +680,6 @@ CONFIG_CARDBUS=y
 # CONFIG_CAVIUM_OCTEON_SOC is not set
 # CONFIG_CB710_CORE is not set
 # CONFIG_CC10001_ADC is not set
-# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 # CONFIG_CC_STACKPROTECTOR is not set
 CONFIG_CC_STACKPROTECTOR_NONE=y
 # CONFIG_CC_STACKPROTECTOR_REGULAR is not set
index 1226441..aec0efa 100644 (file)
@@ -20,8 +20,6 @@ CONFIG_ARCH_USE_BUILTIN_BSWAP=y
 CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
 CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
 CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
-# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CEVT_R4K=y
 CONFIG_CLKDEV_LOOKUP=y
 CONFIG_CLONE_BACKWARDS=y
index 6f8ef62..b769589 100644 (file)
@@ -145,8 +145,6 @@ CONFIG_CAN_RAW=y
 # CONFIG_CAN_SJA1000 is not set
 # CONFIG_CAN_SOFTING is not set
 # CONFIG_CAN_TI_HECC is not set
-CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 # CONFIG_CFS_BANDWIDTH is not set
 CONFIG_CGROUPS=y
 CONFIG_CGROUP_CPUACCT=y
index 0873b2a..06a6305 100644 (file)
@@ -156,8 +156,6 @@ CONFIG_CAVIUM_ERRATUM_22375=y
 CONFIG_CAVIUM_ERRATUM_23144=y
 CONFIG_CAVIUM_ERRATUM_23154=y
 CONFIG_CAVIUM_ERRATUM_27456=y
-CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_CEPH_LIB=y
 # CONFIG_CEPH_LIB_PRETTYDEBUG is not set
 # CONFIG_CEPH_LIB_USE_DNS_RESOLVER is not set
index 0f69bbe..f507842 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 ARCH:=arm
 BOARD:=mcs814x
 BOARDNAME:=Moschip MCS814x
-FEATURES:=usb squashfs low_mem source-only
+FEATURES:=usb squashfs low_mem small_flash source-only
 CPU_TYPE:=arm926ej-s
 MAINTAINER:=Florian Fainelli <florian@openwrt.org>
 
index 7f1c570..0b74cd6 100644 (file)
@@ -26,7 +26,6 @@ CONFIG_ARM_L1_CACHE_SHIFT=5
 # CONFIG_ARM_THUMB is not set
 CONFIG_BINFMT_MISC=y
 # CONFIG_CACHE_L2X0 is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CLKDEV_LOOKUP=y
 CONFIG_CLONE_BACKWARDS=y
 CONFIG_CMDLINE="earlyprintk"
index ce705e5..15cd47a 100644 (file)
@@ -88,8 +88,6 @@ CONFIG_BT_HCIUART=y
 CONFIG_BT_HCIUART_SERDEV=y
 CONFIG_BT_HCIVHCI=y
 CONFIG_BUILD_BIN2C=y
-# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CLKDEV_LOOKUP=y
 CONFIG_CLKSRC_MMIO=y
 CONFIG_CLOCK_THERMAL=y
index 3529bb3..ebe0998 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 ARCH:=powerpc
 BOARD:=ppc40x
 BOARDNAME:=AMCC/IBM PPC40x
-FEATURES:=squashfs broken
+FEATURES:=squashfs small_flash broken
 CPU_TYPE:=405
 MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>
 
index 85bbe0c..fc53dde 100644 (file)
@@ -27,7 +27,6 @@ CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
 CONFIG_AUDIT_ARCH=y
 CONFIG_BOOKE_WDT=y
 CONFIG_BOUNCE=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CLONE_BACKWARDS=y
 CONFIG_CMDLINE="console=ttyS0,115200 rootfstype=squashfs,jffs2 noinitrd"
 CONFIG_CMDLINE_BOOL=y
index 07404d5..52772e4 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 ARCH:=powerpc
 BOARD:=ppc44x
 BOARDNAME:=AMCC/IBM PPC44x
-FEATURES:=squashfs broken
+FEATURES:=squashfs small_flash broken
 CPU_TYPE:=440
 MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>
 
index 842d898..48880b6 100644 (file)
@@ -34,7 +34,6 @@ CONFIG_BOOKE=y
 CONFIG_BOOKE_WDT=y
 CONFIG_BOUNCE=y
 CONFIG_CANYONLANDS=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CLONE_BACKWARDS=y
 CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock1 rootfstype=squashfs,jffs2 noinitrd"
 CONFIG_CMDLINE_BOOL=y
index d60696b..89de071 100644 (file)
@@ -22,8 +22,6 @@ CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
 CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
 CONFIG_AT803X_PHY=y
 CONFIG_BLK_MQ_PCI=y
-# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CEVT_R4K=y
 CONFIG_CEVT_SYSTICK_QUIRK=y
 CONFIG_CLKDEV_LOOKUP=y
index 614c366..81e0848 100644 (file)
@@ -22,8 +22,6 @@ CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
 CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
 CONFIG_AT803X_PHY=y
 CONFIG_BLK_MQ_PCI=y
-# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CEVT_R4K=y
 CONFIG_CEVT_SYSTICK_QUIRK=y
 CONFIG_CLKDEV_LOOKUP=y
index a4b4979..de4dffe 100644 (file)
@@ -21,8 +21,6 @@ CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
 CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
 CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
 CONFIG_BLK_MQ_PCI=y
-# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CEVT_R4K=y
 # CONFIG_CEVT_SYSTICK_QUIRK is not set
 CONFIG_CLKDEV_LOOKUP=y
index 2ca5ecf..11b5a0b 100644 (file)
@@ -4,6 +4,7 @@
 
 SUBTARGET:=rt288x
 BOARDNAME:=RT288x based boards
+FEATURES+=small_flash
 CPU_TYPE:=24kc
 
 DEFAULT_PACKAGES += kmod-rt2800-soc wpad-mini
index dadf88e..346a8a8 100644 (file)
@@ -12,8 +12,6 @@ CONFIG_ARCH_SUPPORTS_UPROBES=y
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
 CONFIG_ARCH_USE_BUILTIN_BSWAP=y
 CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
-# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CEVT_R4K=y
 CONFIG_CEVT_SYSTICK_QUIRK=y
 CONFIG_CLKDEV_LOOKUP=y
index 300639f..e36fa63 100644 (file)
@@ -4,7 +4,7 @@
 
 SUBTARGET:=rt305x
 BOARDNAME:=RT3x5x/RT5350 based boards
-FEATURES+=usb ramdisk
+FEATURES+=usb ramdisk small_flash
 CPU_TYPE:=24kc
 
 DEFAULT_PACKAGES += kmod-rt2800-soc wpad-mini
index f663d49..93d803e 100644 (file)
@@ -22,8 +22,6 @@ CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
 CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
 CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
 CONFIG_BLK_MQ_PCI=y
-# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CEVT_R4K=y
 # CONFIG_CEVT_SYSTICK_QUIRK is not set
 CONFIG_CLKDEV_LOOKUP=y
index a2631d1..2cc1985 100644 (file)
@@ -4,7 +4,7 @@
 
 SUBTARGET:=rt3883
 BOARDNAME:=RT3662/RT3883 based boards
-FEATURES+=usb pci
+FEATURES+=usb pci small_flash
 CPU_TYPE:=74kc
 
 DEFAULT_PACKAGES += kmod-rt2800-pci kmod-rt2800-soc wpad-mini
index 9290a18..a02dc03 100644 (file)
@@ -16,7 +16,6 @@ CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
 CONFIG_ATA=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_SD=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_CEVT_R4K=y
 CONFIG_CLONE_BACKWARDS=y
 CONFIG_CPU_GENERIC_DUMP_TLB=y