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 d2d1909956f35b74d034e7197b9f02915a7707f3..58f7d6009442c8c41f99a6221e5f1a99765dc44b 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 56916bdcea0791513a0c5ab60b35585fdb6630ba..fbfaf6d23cf5537ead98a056e31791d624970e47 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 000424c2e4bd6e2dede16216f5ecce9b52c912a2..231877e6a08a89c33fa02b1496ae2ed153b667f1 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 6ccc34b9573e77c241c0d49dc97af02dfeb9610b..a44d3ac522c60654d07c02d2761a06ac0b5317d5 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 f5a485d083671a0c1686928381e6ab8a0e8b0837..01af54446d91d3d92dedade0c8fe4b2d8ad56f2e 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 ddc28d0f099e7d6531d727d8a9d1d2d7d1e1dd76..3a79b4c3169bc66eff02b779cc3939d97ea1a608 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 cb2eee20ebdcc734b1e7ec50ec0b513eb1141141..abce20a6ad94f989c2b7f63757337b5d68244d6e 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 0f66960fdcdc8d318110dbe43556fc81dc902eb1..0eec5c65d689f7f8204e6766c517e4e2e27f4027 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 3ed2fed7a60dbfcd2ab37d8f6256842b5525d107..e7304b41ce55c2796215fcbde3390beb307f9c4f 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 83abfdc8ff1493c9f5f1e453e23266f658a4e0fb..011172b7af3770b7b54a84d9a8301b6f94eb8f04 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 12264413d28f9fb0c0601d9a933475169ce8f739..aec0efa408eadaa664acb1725ea61d618275a48a 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 6f8ef627f7e3307cca720d6a9de30c4b3f8dd22d..b7695891df8040a356003acf32e292b1107ee836 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 0873b2a8c1be8902530c88900da3b96362100f62..06a63057e8e263b3b59570a8f7d1e1f9f9a751fa 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 0f69bbe322522ef3e4bbb2d4febb0a9c00cd1652..f507842f09439d22307846aa5530c10ede8ee560 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 7f1c5705fd94f7d3966afe5dd80a5d62d42cab1a..0b74cd699693c6e554a386792a20d8bce66fec11 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 ce705e58f5892bc3c2c7be50bfc8d7a151034bdb..15cd47a4ae64745c0859dc09e487c93bdc1d8a51 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 3529bb3db501e4eed0db5a4b4a40647324e389e9..ebe09988a8e1f90d26c4a7bae0ac189378d193fd 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 85bbe0cb9ba4a4fdec7dd6e94dd124492777b4ac..fc53dde8c101d1c9dec0f987f36b784b1ea4d610 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 07404d5b47e3f8f60465cdaac38932ff550aa112..52772e4a8affc5d609a20e7a86db09dd4460c3a6 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 842d898c70ed9afb5534158f71dc26305fe605df..48880b667424be92af740f34f4e2704b5b961e80 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 d60696b225946313f02f82825176243dc8132d8d..89de071446c00f507c4f99f06a3606ff6f406ec4 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 614c366d1e88cf13475893fa58a09ab3822fda21..81e08489315d6ae6e0996970ceaacd66df5de44c 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 a4b49790a3c211b34ec80664ca5c554423498ad1..de4dffe885cf13af9ae7457a8bbbb6dc45f960c5 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 2ca5ecfbb3746fed8bbdea7465e338863a389b22..11b5a0b5201de8b116f0775bbf21abf3c6c39a0a 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 dadf88e0322fa4b1035d85634e93c94920fce2e3..346a8a8814f72f73b3a1a8f7e69ce8ea9009e89c 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 300639fa38efdfd50c8b9037c952ad7533dbf9f5..e36fa637b1db0c3054ce92a7fc67e1d50fd561da 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 f663d49865081508389f533505b844d021f37d58..93d803e2edefb360236b78303c044e03b983e879 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 a2631d1ac7053870614a2869cd7e6dec73b21c32..2cc19858e49a9a63405e87c8916ddbaf65dbe252 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 9290a1869af4183c3a83cb33e85febd5e9d65555..a02dc03bb3b17302cd59d4d3eb4917669362c690 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