From: <kai.kang@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH] module.bbclass: check whether CONFIG_MODULES set
Date: Wed, 4 Feb 2026 10:09:08 +0800 [thread overview]
Message-ID: <20260204020908.864912-1-kai.kang@windriver.com> (raw)
From: Kai Kang <kai.kang@windriver.com>
Check whether kernel config CONFIG_MODULES set or not before do_compile
and do_install in module.bbclass. If not set, it cannot build and
install external modules.
Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
meta/classes-recipe/module.bbclass | 60 +++++++++++++++++-------------
1 file changed, 34 insertions(+), 26 deletions(-)
diff --git a/meta/classes-recipe/module.bbclass b/meta/classes-recipe/module.bbclass
index 4948e995c5..d2b90e9c2c 100644
--- a/meta/classes-recipe/module.bbclass
+++ b/meta/classes-recipe/module.bbclass
@@ -47,37 +47,45 @@ python do_devshell:prepend () {
}
module_do_compile() {
- unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
- oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \
- KERNEL_VERSION=${KERNEL_VERSION} \
- CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
- AR="${KERNEL_AR}" OBJCOPY="${KERNEL_OBJCOPY}" \
- STRIP="${KERNEL_STRIP}" \
- O=${STAGING_KERNEL_BUILDDIR} \
- KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \
- ${MAKE_TARGETS}
+ if grep -q -i '^CONFIG_MODULES=y$' ${STAGING_KERNEL_BUILDDIR}/.config ; then
+ unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
+ oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \
+ KERNEL_VERSION=${KERNEL_VERSION} \
+ CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
+ AR="${KERNEL_AR}" OBJCOPY="${KERNEL_OBJCOPY}" \
+ STRIP="${KERNEL_STRIP}" \
+ O=${STAGING_KERNEL_BUILDDIR} \
+ KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \
+ ${MAKE_TARGETS}
+ else
+ bbnote "The present kernel disabled CONFIG_MODULES that cannot build or install external modules."
+ fi
}
module_do_install() {
- unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
- oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \
- INSTALL_FW_PATH="${D}${nonarch_base_libdir}/firmware" \
- CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" \
- STRIP="${KERNEL_STRIP}" \
- O=${STAGING_KERNEL_BUILDDIR} \
- KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \
- ${MODULES_INSTALL_TARGET}
+ if grep -q -i '^CONFIG_MODULES=y$' ${STAGING_KERNEL_BUILDDIR}/.config; then
+ unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
+ oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \
+ INSTALL_FW_PATH="${D}${nonarch_base_libdir}/firmware" \
+ CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" \
+ STRIP="${KERNEL_STRIP}" \
+ O=${STAGING_KERNEL_BUILDDIR} \
+ KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \
+ ${MODULES_INSTALL_TARGET}
- if [ ! -e "${B}/${MODULES_MODULE_SYMVERS_LOCATION}/Module.symvers" ] ; then
- bbwarn "Module.symvers not found in ${B}/${MODULES_MODULE_SYMVERS_LOCATION}"
- bbwarn "Please consider setting MODULES_MODULE_SYMVERS_LOCATION to a"
- bbwarn "directory below B to get correct inter-module dependencies"
+ if [ ! -e "${B}/${MODULES_MODULE_SYMVERS_LOCATION}/Module.symvers" ] ; then
+ bbwarn "Module.symvers not found in ${B}/${MODULES_MODULE_SYMVERS_LOCATION}"
+ bbwarn "Please consider setting MODULES_MODULE_SYMVERS_LOCATION to a"
+ bbwarn "directory below B to get correct inter-module dependencies"
+ else
+ install -Dm0644 "${B}/${MODULES_MODULE_SYMVERS_LOCATION}"/Module.symvers ${D}${includedir}/${BPN}/Module.symvers
+ # Module.symvers contains absolute path to the build directory.
+ # While it doesn't actually seem to matter which path is specified,
+ # clear them out to avoid confusion
+ sed -e 's:${B}/::g' -i ${D}${includedir}/${BPN}/Module.symvers
+ fi
else
- install -Dm0644 "${B}/${MODULES_MODULE_SYMVERS_LOCATION}"/Module.symvers ${D}${includedir}/${BPN}/Module.symvers
- # Module.symvers contains absolute path to the build directory.
- # While it doesn't actually seem to matter which path is specified,
- # clear them out to avoid confusion
- sed -e 's:${B}/::g' -i ${D}${includedir}/${BPN}/Module.symvers
+ bbnote "The present kernel disabled CONFIG_MODULES that cannot build or install external modules."
fi
}
--
2.34.1
next reply other threads:[~2026-02-04 2:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 2:09 kai.kang [this message]
2026-02-04 13:46 ` [OE-core] [PATCH] module.bbclass: check whether CONFIG_MODULES set Bruce Ashfield
2026-02-04 13:58 ` Richard Purdie
2026-02-04 14:02 ` Bruce Ashfield
2026-02-04 14:05 ` Richard Purdie
2026-02-04 14:10 ` Bruce Ashfield
2026-02-04 15:53 ` Richard Purdie
2026-02-05 9:08 ` Kai
2026-02-05 12:58 ` Bruce Ashfield
2026-02-05 14:49 ` Richard Purdie
2026-02-12 6:48 ` Kai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260204020908.864912-1-kai.kang@windriver.com \
--to=kai.kang@windriver.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox