aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMark Mentovai <mark@mentovai.com>2022-09-11 13:48:17 -0400
committerPetr Štetiar <ynezz@true.cz>2022-10-20 09:53:23 +0200
commit802bfe080678b3a8a94868b717bd127afcabc5b7 (patch)
tree64f604113f761d7ee6987574eb77c9d00c15fcd5 /include
parent5e31c82bb506bff9c60c4d01791bea7a29e4a020 (diff)
downloadupstream-802bfe080678b3a8a94868b717bd127afcabc5b7.tar.gz
upstream-802bfe080678b3a8a94868b717bd127afcabc5b7.tar.bz2
upstream-802bfe080678b3a8a94868b717bd127afcabc5b7.zip
kernel: disable stack validation for external module builds as needed
c3e31b6a9b04 and 5f8e5872406d disable stack validation when the build host is not running Linux, as the objtool kernel build tool required for stack validation is not portable to other build host environments. This was achieved by setting CONFIG_STACK_VALIDATION= in KERNEL_MAKEOPTS, and by setting SKIP_STACK_VALIDATION=1 in the environment. KERNEL_MAKEOPTS only has effect for the kernel build, not for external module builds, but through kernel 5.14, SKIP_STACK_VALIDATION worked to disable this feature too, so stack validation was disabled for external module builds as well. Since kernel 0d989ac2c90b, the kernel build no longer considers SKIP_STACK_VALIDATION, so the feature will be disabled for the kernel build, but not for external module builds. When building OpenWrt on a non-Linux build host targeting x86 (the only target architecture for which OpenWrt enables the kernel CONFIG_STACK_VALIDATION) and using kernel 5.15 (such as via CONFIG_TESTING_KERNEL), this caused a build failure during any external module build, such as kmod-button-hotplug. This manifested as build errors such as: make[4]: *** No rule to make target '.../build_dir/target-x86_64_musl/linux-x86_64/button-hotplug/button-hotplug.o', needed by '.../build_dir/target-x86_64_musl/linux-x86_64/button-hotplug/button-hotplug.mod'. Stop. Although button-hotplug.c was present, the implicit rule to make $(obj)/%.o from $(src)/%.c in the kernel's scripts/Makefile.build could not be satisfied in this case, as it also depends on $(objtool_dep), non-empty as a result of the failure to propagate disabling of stack validation to external module builds, in a configuration where it is not possible to build objtool. KERNEL_MAKEOPTS is used for just the kernel build itself, while KERNEL_MAKE_FLAGS is used for both the kernel build and for external module builds. This restores the ability to build OpenWrt in such configurations by moving the CONFIG_STACK_VALIDATION= make argument from KERNEL_MAKEOPTS to KERNEL_MAKE_FLAGS where it is able to affect external module builds properly. Note that the kernel's objtool and related configuration have seen a major overhaul since kernel 5.15, and may need more attention again after 22922deae13f, in kernel 5.19. Signed-off-by: Mark Mentovai <mark@mentovai.com>
Diffstat (limited to 'include')
-rw-r--r--include/kernel.mk10
1 files changed, 5 insertions, 5 deletions
diff --git a/include/kernel.mk b/include/kernel.mk
index 001718d89d..2efa3bf8f8 100644
--- a/include/kernel.mk
+++ b/include/kernel.mk
@@ -125,17 +125,17 @@ ifeq ($(call qstrip,$(CONFIG_EXTERNAL_KERNEL_TREE))$(call qstrip,$(CONFIG_KERNEL
KERNELRELEASE=$(LINUX_VERSION)
endif
+ifneq ($(HOST_OS),Linux)
+ KERNEL_MAKE_FLAGS += CONFIG_STACK_VALIDATION=
+ export SKIP_STACK_VALIDATION:=1
+endif
+
KERNEL_MAKEOPTS := -C $(LINUX_DIR) $(KERNEL_MAKE_FLAGS)
ifdef CONFIG_USE_SPARSE
KERNEL_MAKEOPTS += C=1 CHECK=$(STAGING_DIR_HOST)/bin/sparse
endif
-ifneq ($(HOST_OS),Linux)
- KERNEL_MAKEOPTS += CONFIG_STACK_VALIDATION=
- export SKIP_STACK_VALIDATION:=1
-endif
-
PKG_EXTMOD_SUBDIRS ?= .
PKG_SYMVERS_DIR = $(KERNEL_BUILD_DIR)/symvers