kernel: only optimized for size if small_flash

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>
This commit is contained in:
Mathias Kresin 2018-07-09 20:48:56 +02:00
parent 621fa91a82
commit cf7154db07
29 changed files with 30 additions and 40 deletions

View file

@ -806,3 +806,25 @@ config KERNEL_DEVKMEM
Say Y here if you want to support the /dev/kmem device. The 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 /dev/kmem device is rarely used, but can be used for certain
kind of kernel debugging operations. 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

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
BOARD:=adm5120 BOARD:=adm5120
BOARDNAME:=Infineon/ADMtek ADM5120 BOARDNAME:=Infineon/ADMtek ADM5120
FEATURES:=low_mem source-only FEATURES:=low_mem small_flash source-only
SUBTARGETS:=router_le router_be rb1xx SUBTARGETS:=router_le router_be rb1xx
INITRAMFS_EXTRA_FILES:= INITRAMFS_EXTRA_FILES:=

View file

@ -45,7 +45,6 @@ CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
CONFIG_ARM_AMBA=y CONFIG_ARM_AMBA=y
CONFIG_BUILD_BIN2C=y CONFIG_BUILD_BIN2C=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_CEVT_R4K=y CONFIG_CEVT_R4K=y
CONFIG_CLONE_BACKWARDS=y CONFIG_CLONE_BACKWARDS=y
CONFIG_CMDLINE="console=ttyAM0,115200 rootfstype=squashfs,jffs2" CONFIG_CMDLINE="console=ttyAM0,115200 rootfstype=squashfs,jffs2"

View file

@ -58,8 +58,6 @@ CONFIG_BLK_DEV_SD=y
# CONFIG_BPF_SYSCALL is not set # CONFIG_BPF_SYSCALL is not set
# CONFIG_BRIDGE is not set # CONFIG_BRIDGE is not set
CONFIG_CACHE_L2X0=y CONFIG_CACHE_L2X0=y
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKDEV_LOOKUP=y
CONFIG_CLKSRC_OF=y CONFIG_CLKSRC_OF=y
CONFIG_CLKSRC_PROBE=y CONFIG_CLKSRC_PROBE=y

View 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_BLK_MQ_PCI=y
CONFIG_LEDS_RESET=y CONFIG_LEDS_RESET=y
CONFIG_OF_ADDRESS_PCI=y CONFIG_OF_ADDRESS_PCI=y

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
ARCH:=mipsel ARCH:=mipsel
BOARD:=au1000 BOARD:=au1000
BOARDNAME:=RMI/AMD AU1x00 BOARDNAME:=RMI/AMD AU1x00
FEATURES:=squashfs usb pci source-only FEATURES:=squashfs usb pci small_flash source-only
SUBTARGETS:=au1500 au1550 SUBTARGETS:=au1500 au1550
MAINTAINER:=Florian Fainelli <florian@openwrt.org> MAINTAINER:=Florian Fainelli <florian@openwrt.org>

View file

@ -11,7 +11,6 @@ CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
CONFIG_ARCH_REQUIRE_GPIOLIB=y CONFIG_ARCH_REQUIRE_GPIOLIB=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_CEVT_R4K=y CONFIG_CEVT_R4K=y
CONFIG_CLONE_BACKWARDS=y CONFIG_CLONE_BACKWARDS=y
CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock0 rootfstype=squashfs,jffs2" CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock0 rootfstype=squashfs,jffs2"

View file

@ -580,7 +580,6 @@ CONFIG_CAVIUM_OCTEON_HELPER=y
# CONFIG_CAVIUM_OCTEON_SIMULATOR is not set # CONFIG_CAVIUM_OCTEON_SIMULATOR is not set
# CONFIG_CAVIUM_OCTEON_SOC is not set # CONFIG_CAVIUM_OCTEON_SOC is not set
# CONFIG_CB710_CORE 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 is not set
CONFIG_CC_STACKPROTECTOR_NONE=y CONFIG_CC_STACKPROTECTOR_NONE=y
# CONFIG_CC_STACKPROTECTOR_REGULAR is not set # CONFIG_CC_STACKPROTECTOR_REGULAR is not set

View file

@ -717,8 +717,6 @@ CONFIG_CARDBUS=y
# CONFIG_CB710_CORE is not set # CONFIG_CB710_CORE is not set
# CONFIG_CC10001_ADC is not set # CONFIG_CC10001_ADC is not set
# CONFIG_CCS811 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 is not set
CONFIG_CC_STACKPROTECTOR_NONE=y CONFIG_CC_STACKPROTECTOR_NONE=y
# CONFIG_CC_STACKPROTECTOR_REGULAR is not set # CONFIG_CC_STACKPROTECTOR_REGULAR is not set

View file

@ -680,8 +680,6 @@ CONFIG_CARDBUS=y
# CONFIG_CAVIUM_OCTEON_SOC is not set # CONFIG_CAVIUM_OCTEON_SOC is not set
# CONFIG_CB710_CORE is not set # CONFIG_CB710_CORE is not set
# CONFIG_CC10001_ADC 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 is not set
CONFIG_CC_STACKPROTECTOR_NONE=y CONFIG_CC_STACKPROTECTOR_NONE=y
# CONFIG_CC_STACKPROTECTOR_REGULAR is not set # CONFIG_CC_STACKPROTECTOR_REGULAR is not set

View file

@ -20,8 +20,6 @@ CONFIG_ARCH_USE_BUILTIN_BSWAP=y
CONFIG_ARCH_USE_QUEUED_RWLOCKS=y CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=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_R4K=y
CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKDEV_LOOKUP=y
CONFIG_CLONE_BACKWARDS=y CONFIG_CLONE_BACKWARDS=y

View file

@ -145,8 +145,6 @@ CONFIG_CAN_RAW=y
# CONFIG_CAN_SJA1000 is not set # CONFIG_CAN_SJA1000 is not set
# CONFIG_CAN_SOFTING is not set # CONFIG_CAN_SOFTING is not set
# CONFIG_CAN_TI_HECC 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_CFS_BANDWIDTH is not set
CONFIG_CGROUPS=y CONFIG_CGROUPS=y
CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_CPUACCT=y

View file

@ -156,8 +156,6 @@ CONFIG_CAVIUM_ERRATUM_22375=y
CONFIG_CAVIUM_ERRATUM_23144=y CONFIG_CAVIUM_ERRATUM_23144=y
CONFIG_CAVIUM_ERRATUM_23154=y CONFIG_CAVIUM_ERRATUM_23154=y
CONFIG_CAVIUM_ERRATUM_27456=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=y
# CONFIG_CEPH_LIB_PRETTYDEBUG is not set # CONFIG_CEPH_LIB_PRETTYDEBUG is not set
# CONFIG_CEPH_LIB_USE_DNS_RESOLVER is not set # CONFIG_CEPH_LIB_USE_DNS_RESOLVER is not set

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
ARCH:=arm ARCH:=arm
BOARD:=mcs814x BOARD:=mcs814x
BOARDNAME:=Moschip MCS814x BOARDNAME:=Moschip MCS814x
FEATURES:=usb squashfs low_mem source-only FEATURES:=usb squashfs low_mem small_flash source-only
CPU_TYPE:=arm926ej-s CPU_TYPE:=arm926ej-s
MAINTAINER:=Florian Fainelli <florian@openwrt.org> MAINTAINER:=Florian Fainelli <florian@openwrt.org>

View file

@ -26,7 +26,6 @@ CONFIG_ARM_L1_CACHE_SHIFT=5
# CONFIG_ARM_THUMB is not set # CONFIG_ARM_THUMB is not set
CONFIG_BINFMT_MISC=y CONFIG_BINFMT_MISC=y
# CONFIG_CACHE_L2X0 is not set # CONFIG_CACHE_L2X0 is not set
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKDEV_LOOKUP=y
CONFIG_CLONE_BACKWARDS=y CONFIG_CLONE_BACKWARDS=y
CONFIG_CMDLINE="earlyprintk" CONFIG_CMDLINE="earlyprintk"

View file

@ -88,8 +88,6 @@ CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_SERDEV=y CONFIG_BT_HCIUART_SERDEV=y
CONFIG_BT_HCIVHCI=y CONFIG_BT_HCIVHCI=y
CONFIG_BUILD_BIN2C=y CONFIG_BUILD_BIN2C=y
# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKDEV_LOOKUP=y
CONFIG_CLKSRC_MMIO=y CONFIG_CLKSRC_MMIO=y
CONFIG_CLOCK_THERMAL=y CONFIG_CLOCK_THERMAL=y

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
ARCH:=powerpc ARCH:=powerpc
BOARD:=ppc40x BOARD:=ppc40x
BOARDNAME:=AMCC/IBM PPC40x BOARDNAME:=AMCC/IBM PPC40x
FEATURES:=squashfs broken FEATURES:=squashfs small_flash broken
CPU_TYPE:=405 CPU_TYPE:=405
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org> MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>

View file

@ -27,7 +27,6 @@ CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
CONFIG_AUDIT_ARCH=y CONFIG_AUDIT_ARCH=y
CONFIG_BOOKE_WDT=y CONFIG_BOOKE_WDT=y
CONFIG_BOUNCE=y CONFIG_BOUNCE=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_CLONE_BACKWARDS=y CONFIG_CLONE_BACKWARDS=y
CONFIG_CMDLINE="console=ttyS0,115200 rootfstype=squashfs,jffs2 noinitrd" CONFIG_CMDLINE="console=ttyS0,115200 rootfstype=squashfs,jffs2 noinitrd"
CONFIG_CMDLINE_BOOL=y CONFIG_CMDLINE_BOOL=y

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
ARCH:=powerpc ARCH:=powerpc
BOARD:=ppc44x BOARD:=ppc44x
BOARDNAME:=AMCC/IBM PPC44x BOARDNAME:=AMCC/IBM PPC44x
FEATURES:=squashfs broken FEATURES:=squashfs small_flash broken
CPU_TYPE:=440 CPU_TYPE:=440
MAINTAINER:=Imre Kaloz <kaloz@openwrt.org> MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>

View file

@ -34,7 +34,6 @@ CONFIG_BOOKE=y
CONFIG_BOOKE_WDT=y CONFIG_BOOKE_WDT=y
CONFIG_BOUNCE=y CONFIG_BOUNCE=y
CONFIG_CANYONLANDS=y CONFIG_CANYONLANDS=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_CLONE_BACKWARDS=y CONFIG_CLONE_BACKWARDS=y
CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock1 rootfstype=squashfs,jffs2 noinitrd" CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock1 rootfstype=squashfs,jffs2 noinitrd"
CONFIG_CMDLINE_BOOL=y CONFIG_CMDLINE_BOOL=y

View file

@ -22,8 +22,6 @@ CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
CONFIG_AT803X_PHY=y CONFIG_AT803X_PHY=y
CONFIG_BLK_MQ_PCI=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_R4K=y
CONFIG_CEVT_SYSTICK_QUIRK=y CONFIG_CEVT_SYSTICK_QUIRK=y
CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKDEV_LOOKUP=y

View file

@ -22,8 +22,6 @@ CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
CONFIG_AT803X_PHY=y CONFIG_AT803X_PHY=y
CONFIG_BLK_MQ_PCI=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_R4K=y
CONFIG_CEVT_SYSTICK_QUIRK=y CONFIG_CEVT_SYSTICK_QUIRK=y
CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKDEV_LOOKUP=y

View file

@ -21,8 +21,6 @@ CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
CONFIG_BLK_MQ_PCI=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_R4K=y
# CONFIG_CEVT_SYSTICK_QUIRK is not set # CONFIG_CEVT_SYSTICK_QUIRK is not set
CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKDEV_LOOKUP=y

View file

@ -4,6 +4,7 @@
SUBTARGET:=rt288x SUBTARGET:=rt288x
BOARDNAME:=RT288x based boards BOARDNAME:=RT288x based boards
FEATURES+=small_flash
CPU_TYPE:=24kc CPU_TYPE:=24kc
DEFAULT_PACKAGES += kmod-rt2800-soc wpad-mini DEFAULT_PACKAGES += kmod-rt2800-soc wpad-mini

View file

@ -12,8 +12,6 @@ CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_USE_BUILTIN_BSWAP=y CONFIG_ARCH_USE_BUILTIN_BSWAP=y
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=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_R4K=y
CONFIG_CEVT_SYSTICK_QUIRK=y CONFIG_CEVT_SYSTICK_QUIRK=y
CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKDEV_LOOKUP=y

View file

@ -4,7 +4,7 @@
SUBTARGET:=rt305x SUBTARGET:=rt305x
BOARDNAME:=RT3x5x/RT5350 based boards BOARDNAME:=RT3x5x/RT5350 based boards
FEATURES+=usb ramdisk FEATURES+=usb ramdisk small_flash
CPU_TYPE:=24kc CPU_TYPE:=24kc
DEFAULT_PACKAGES += kmod-rt2800-soc wpad-mini DEFAULT_PACKAGES += kmod-rt2800-soc wpad-mini

View file

@ -22,8 +22,6 @@ CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
CONFIG_BLK_MQ_PCI=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_R4K=y
# CONFIG_CEVT_SYSTICK_QUIRK is not set # CONFIG_CEVT_SYSTICK_QUIRK is not set
CONFIG_CLKDEV_LOOKUP=y CONFIG_CLKDEV_LOOKUP=y

View file

@ -4,7 +4,7 @@
SUBTARGET:=rt3883 SUBTARGET:=rt3883
BOARDNAME:=RT3662/RT3883 based boards BOARDNAME:=RT3662/RT3883 based boards
FEATURES+=usb pci FEATURES+=usb pci small_flash
CPU_TYPE:=74kc CPU_TYPE:=74kc
DEFAULT_PACKAGES += kmod-rt2800-pci kmod-rt2800-soc wpad-mini DEFAULT_PACKAGES += kmod-rt2800-pci kmod-rt2800-soc wpad-mini

View file

@ -16,7 +16,6 @@ CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
CONFIG_ATA=y CONFIG_ATA=y
CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_SD=y CONFIG_BLK_DEV_SD=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_CEVT_R4K=y CONFIG_CEVT_R4K=y
CONFIG_CLONE_BACKWARDS=y CONFIG_CLONE_BACKWARDS=y
CONFIG_CPU_GENERIC_DUMP_TLB=y CONFIG_CPU_GENERIC_DUMP_TLB=y