kernel: use KCFLAGS for passing EXTRA_OPTIMIZATION flags
authorRafał Miłecki <rafal@milecki.pl>
Wed, 15 Jun 2022 08:41:37 +0000 (10:41 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Fri, 8 Jul 2022 09:28:01 +0000 (11:28 +0200)
This uses kernel's generic variable and doesn't require patching it with
a custom Makefile change. It's expected *not* to change any behaviour.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
(cherry picked from commit 1d42af720c6b6dcfcdd0b89bce386fca1607dcb3)
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
(cherry picked from commit 24e27bec9a6df1511a504cf04cd9578a23e74657)

include/kernel.mk
rules.mk
target/linux/generic/pending-5.10/201-extra_optimization.patch

index e4074a48f4b27b3522b95b239af0817b5bacfec9..5057d8bf6fa601c7cb2af51fedb9455c5f1c5ae5 100644 (file)
@@ -101,7 +101,7 @@ endif
 KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS)
 
 KERNEL_MAKE_FLAGS = \
-       KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR)))" \
+       KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION)))" \
        HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
        CROSS_COMPILE="$(KERNEL_CROSS)" \
        ARCH="$(LINUX_KARCH)" \
index 8d4f61921192c92fd771800c092e1cc0cefff5be..8a4254e638cb32bea07ab9176cee99387ea001c8 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -62,7 +62,6 @@ ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES))
 BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD))
 SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET))
 TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION))
-export EXTRA_OPTIMIZATION:=$(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION)))
 TARGET_SUFFIX=$(call qstrip,$(CONFIG_TARGET_SUFFIX))
 BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX))
 SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
index cb1de80764109a832cc4561dd26838005f5e1920..dcf39c574ff2f258df12b1f6608b0983f44bc146 100644 (file)
@@ -14,18 +14,12 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 
 --- a/Makefile
 +++ b/Makefile
-@@ -735,11 +735,11 @@ KBUILD_CFLAGS    += $(call cc-disable-warni
- KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
- ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
--KBUILD_CFLAGS += -O2
-+KBUILD_CFLAGS += -O2 $(EXTRA_OPTIMIZATION)
+@@ -739,7 +739,7 @@ KBUILD_CFLAGS += -O2
  else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
--KBUILD_CFLAGS += -O3
-+KBUILD_CFLAGS += -O3 $(EXTRA_OPTIMIZATION)
+ KBUILD_CFLAGS += -O3
  else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 -KBUILD_CFLAGS += -Os
-+KBUILD_CFLAGS += -Os -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION)
++KBUILD_CFLAGS += -Os -fno-reorder-blocks -fno-tree-ch
  endif
  
  # Tell gcc to never replace conditional load with a non-conditional one