On Tue, Feb 3, 2026 at 9:09 PM Kai Kang via lists.openembedded.org
<[email protected]> wrote:

> From: Kai Kang <[email protected]>
>
> 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.
>

This isn't the place to do that check.

If modules are disabled get modules_do_compile out of the tasks.

Bruce



>
> Signed-off-by: Kai Kang <[email protected]>
> ---
>  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
>
>
> 
>
>

-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#230526): 
https://lists.openembedded.org/g/openembedded-core/message/230526
Mute This Topic: https://lists.openembedded.org/mt/117627823/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to