kernel: support setting extra CFLAGS for kernel compilation
authorRafał Miłecki <rafal@milecki.pl>
Wed, 15 Jun 2022 10:36:36 +0000 (12:36 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Fri, 8 Jul 2022 13:38:42 +0000 (15:38 +0200)
They may be used e.g. to optimize kernel size or performance.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
(cherry picked from commit 907d7d747243044f86588f0d82993e8c106cb02c)

config/Config-devel.in
include/kernel.mk

index 126462bfc3a0a12324b3ac38614c4f94638d0115..a068f694e5a9d91b4a76848f265df0139e628ccb 100644 (file)
@@ -74,6 +74,10 @@ menuconfig DEVEL
                  Store ccache in this directory.
                  If not set, uses './.ccache'
 
+       config KERNEL_CFLAGS
+               string "Kernel extra CFLAGS" if DEVEL
+               default ""
+
        config EXTERNAL_KERNEL_TREE
                string "Use external kernel tree" if DEVEL
                default ""
index 5057d8bf6fa601c7cb2af51fedb9455c5f1c5ae5..070d1bca759d8a71d63652b08ba4b7c5428d9cfb 100644 (file)
@@ -101,7 +101,7 @@ endif
 KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS)
 
 KERNEL_MAKE_FLAGS = \
-       KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION)))" \
+       KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) $(call qstrip,$(CONFIG_KERNEL_CFLAGS))" \
        HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
        CROSS_COMPILE="$(KERNEL_CROSS)" \
        ARCH="$(LINUX_KARCH)" \