Files
rpi-buildroot/package/pkg-kernel-module.mk
Thomas Petazzoni 1d8d9e8d6c package/pkg-kernel-module: disable CONFIG_TRIM_UNUSED_KSYMS
The kernel option CONFIG_TRIM_UNUSED_KSYMS=y allows to trim unused
kernel symbols... which basically prevents building external
modules. This option has been enabled in the default MIPS architecture
kernel defconfig since pretty much forever, and it causes build
failures of all our external modules on MIPS in the autobuilders.

To fix this in a global manner, we handle the problem in the
kernel-module infrastructure, by appending to the
<pkg>_LINUX_CONFIG_FIXUPS variable provided by the package.

Fixes:

  http://autobuild.buildroot.net/results/c26abec4e24d06557079654b12825efb2211996f/ (cryptodev-linux)
  http://autobuild.buildroot.net/results/699c618730cb33f0ccf54f90e4b722198fd3d3bc/ (emlog)
  http://autobuild.buildroot.net/results/f1d5626f5698a955bf378217528fbf4f8f741435/ (rtl8812au-aircrack-ng)
  http://autobuild.buildroot.net/results/c9a507757ce3a01cd08d596cb519ee9f19caf77c/ (mdio-tools)

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
2025-01-05 11:48:30 +01:00

107 lines
3.8 KiB
Makefile

################################################################################
# kernel module infrastructure for building Linux kernel modules
#
# This file implements an infrastructure that eases development of package
# .mk files for out-of-tree Linux kernel modules. It should be used for all
# packages that build a Linux kernel module using the kernel's out-of-tree
# buildsystem, unless they use a complex custom buildsystem.
#
# The kernel-module infrastructure requires the packages that use it to also
# use another package infrastructure. kernel-module only defines post-build
# and post-install hooks. This allows the package to build both kernel
# modules and/or user-space components (with any of the other *-package
# infra).
#
# As such, it is to be used in conjunction with another *-package infra,
# like so:
#
# $(eval $(kernel-module))
# $(eval $(generic-package))
#
# Note: if the caller needs access to the kernel modules (either after they
# are built or after they are installed), it will have to define its own
# post-build/install hooks *after* calling kernel-module, but *before*
# calling the other *-package infra, like so:
#
# $(eval $(kernel-module))
# define FOO_MOD_TWEAK
# # do something
# endef
# FOO_POST_BUILD_HOOKS += FOO_MOD_TWEAK
# $(eval $(generic-package))
#
# Note: this infra does not check that the kernel is enabled; it is expected
# to be enforced at the Kconfig level with proper 'depends on'.
################################################################################
################################################################################
# inner-kernel-module -- generates the make targets needed to support building
# a kernel module
#
# argument 1 is the lowercase package name
# argument 2 is the uppercase package name
################################################################################
define inner-kernel-module
# If the package is enabled, ensure the kernel will support modules
ifeq ($$(BR2_PACKAGE_$(2)),y)
LINUX_NEEDS_MODULES = y
endif
# The kernel must be built first.
$(2)_DEPENDENCIES += \
linux \
$$(BR2_MAKE_HOST_DEPENDENCY)
# This is only defined in some infrastructures (e.g. autotools, cmake),
# but not in others (e.g. generic). So define it here as well.
$(2)_MAKE ?= $$(BR2_MAKE)
# If not specified, consider the source of the kernel module to be at
# the root of the package.
$(2)_MODULE_SUBDIRS ?= .
$(2)_LINUX_CONFIG_FIXUPS += \
$$(sep)$$(call KCONFIG_DISABLE_OPT,CONFIG_TRIM_UNUSED_KSYMS)
# Build the kernel module(s)
# Force PWD for those packages that want to use it to find their
# includes and other support files (Booo!)
define $(2)_KERNEL_MODULES_BUILD
@$$(call MESSAGE,"Building kernel module(s)")
$$(foreach d,$$($(2)_MODULE_SUBDIRS), \
$$(LINUX_MAKE_ENV) $$($$(PKG)_MAKE) \
-C $$(LINUX_DIR) \
$$(LINUX_MAKE_FLAGS) \
$$($(2)_MODULE_MAKE_OPTS) \
PWD=$$(@D)/$$(d) \
M=$$(@D)/$$(d) \
modules$$(sep))
endef
$(2)_POST_BUILD_HOOKS += $(2)_KERNEL_MODULES_BUILD
# Install the kernel module(s)
# Force PWD for those packages that want to use it to find their
# includes and other support files (Booo!)
define $(2)_KERNEL_MODULES_INSTALL
@$$(call MESSAGE,"Installing kernel module(s)")
$$(foreach d,$$($(2)_MODULE_SUBDIRS), \
$$(LINUX_MAKE_ENV) $$($$(PKG)_MAKE) \
-C $$(LINUX_DIR) \
$$(LINUX_MAKE_FLAGS) \
$$($(2)_MODULE_MAKE_OPTS) \
PWD=$$(@D)/$$(d) \
M=$$(@D)/$$(d) \
modules_install$$(sep))
endef
$(2)_POST_INSTALL_TARGET_HOOKS += $(2)_KERNEL_MODULES_INSTALL
endef
################################################################################
# kernel-module -- the target generator macro for kernel module packages
################################################################################
kernel-module = $(call inner-kernel-module,$(pkgname),$(call UPPERCASE,$(pkgname)))