modify BUILD_LOADABLE to MODULES which backwards-compatible Kernel

maintains the same semantics as Kernel’s module build
and compatible with Kconfiglib implementation.

The problem of kconfiglib not being able to use tri-states is this:
linux is here torvalds/linux@6dd85ff
The module option is extracted from one of the triate three states into a MODULE keyword.
Kconfiglib supports the default implementation of module to be MODULE for compatibility with the linux kernel, and triate degenerates into bool two states
Refer to this code: 061e71f7d7/kconfiglib.py (L4274-L4284)

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
This commit is contained in:
xuxin19 2024-03-15 11:19:34 +08:00 committed by Xiang Xiao
parent 0561b55860
commit 1d3dd328dd
7 changed files with 27 additions and 40 deletions

View File

@ -335,15 +335,9 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/.config OR NOT "${NUTTX_DEFCONFIG}" STREQUAL
# store original expanded .config # store original expanded .config
configure_file(${CMAKE_BINARY_DIR}/.config ${CMAKE_BINARY_DIR}/.config.orig configure_file(${CMAKE_BINARY_DIR}/.config ${CMAKE_BINARY_DIR}/.config.orig
COPYONLY) COPYONLY)
if(KCONFIG_ERROR)
string(REPLACE "\n" ";" KCONFIG_ESTRING ${KCONFIG_ERROR}) message(WARNING "Kconfig Configuration Error: ${KCONFIG_ERROR}")
foreach(estring ${KCONFIG_ESTRING})
string(REGEX MATCH "the 'modules' option is not supported" result
${estring})
if(NOT result)
message(WARNING "Kconfig Configuration Error: ${estring}")
endif() endif()
endforeach()
if(KCONFIG_STATUS AND NOT KCONFIG_STATUS EQUAL 0) if(KCONFIG_STATUS AND NOT KCONFIG_STATUS EQUAL 0)
message( message(

View File

@ -127,7 +127,7 @@ Symbol tables have differing usefulness in different NuttX build modes:
share resources with other user code (but should use system calls to share resources with other user code (but should use system calls to
interact with the OS). interact with the OS).
#. But in the kernel build mode (``CONFIG_BUILD_LOADABLE``), only fully linked #. But in the kernel build mode (``CONFIG_MODULES``), only fully linked
executables loadable via ``execl()``, ``execv()``, or ``posix_spawan()`` executables loadable via ``execl()``, ``execv()``, or ``posix_spawan()``
can be used. can be used.
There is no use for a symbol table with the kernel build since all There is no use for a symbol table with the kernel build since all

View File

@ -132,11 +132,6 @@ If you are a working on Windows, which also need the support of windows-curses:
pip install windows-curses pip install windows-curses
.. tip::
It should be noted that kconfiglib does not support **modules** attributes.
(https://github.com/ulfalizer/Kconfiglib/blob/master/kconfiglib.py#L3239-L3254,
the community seems to have stopped updating), if the features depends on
``CONFIG_BUILD_LOADABLE``, kconfiglib may not be a good choice.
Toolchain Toolchain
========= =========

15
Kconfig
View File

@ -273,14 +273,17 @@ config BASE_DEFCONFIG
current configuration. It is useful for getting the current configuration current configuration. It is useful for getting the current configuration
on runtime. on runtime.
config BUILD_LOADABLE config MODULES
bool bool
option modules
---help--- ---help---
Automatically selected if KERNEL build is selected. Automatically selected if KERNEL build is selected.
This selection only effects the behavior of the 'make export' This selection marks the implementation of Kconfig
target and currently has no effect unless you wish to build to enable the module build function, and is used to
loadable applications in a FLAT build. enable 'm' in the triate state. Its semantics are
consistent with Kernel. This selection also effects
the behavior of the 'make export' target and currently
has no effect unless you wish to build loadable applications
in a FLAT build.
choice choice
prompt "Memory organization" prompt "Memory organization"
@ -312,8 +315,8 @@ config BUILD_PROTECTED
config BUILD_KERNEL config BUILD_KERNEL
bool "NuttX kernel build" bool "NuttX kernel build"
depends on ARCH_USE_MMU && ARCH_ADDRENV depends on ARCH_USE_MMU && ARCH_ADDRENV
select BUILD_LOADABLE
select LIB_SYSCALL select LIB_SYSCALL
select MODULES
---help--- ---help---
Builds NuttX as a separately compiled kernel. No applications are Builds NuttX as a separately compiled kernel. No applications are
built. All user applications must reside in a file system where built. All user applications must reside in a file system where

View File

@ -22,7 +22,7 @@ config PATH_INITIAL
config BINFMT_LOADABLE config BINFMT_LOADABLE
bool bool
select BUILD_LOADABLE select MODULES
default n default n
---help--- ---help---
Automatically selected if a loadable binary format is selected. Automatically selected if a loadable binary format is selected.

View File

@ -157,7 +157,7 @@ function(nuttx_add_application)
# loadable build requires applying ELF flags to all applications # loadable build requires applying ELF flags to all applications
if(CONFIG_BUILD_LOADABLE) if(CONFIG_MODULES)
target_compile_options( target_compile_options(
${TARGET} ${TARGET}
PRIVATE PRIVATE

View File

@ -638,10 +638,7 @@ pass2dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT)
KCONFIG_ENV = APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) KCONFIG_ENV = APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR)
KCONFIG_ENV += APPSBINDIR=${CONFIG_APPS_DIR} BINDIR=${TOPDIR} KCONFIG_ENV += APPSBINDIR=${CONFIG_APPS_DIR} BINDIR=${TOPDIR}
LOADABLE = $(shell grep "=m$$" $(TOPDIR)/.config)
ifeq ($(CONFIG_BUILD_LOADABLE)$(LOADABLE),)
KCONFIG_LIB = $(shell command -v menuconfig 2> /dev/null) KCONFIG_LIB = $(shell command -v menuconfig 2> /dev/null)
endif
# Prefer "kconfiglib" if host OS supports it # Prefer "kconfiglib" if host OS supports it
@ -657,21 +654,19 @@ define kconfig_tweak_disable
kconfig-tweak --file $1 -u $2 kconfig-tweak --file $1 -u $2
endef endef
else else
KCONFIG_WARNING = if [ -s kwarning ]; \ KCONFIG_WARNING = 2> >(tee kwarning) | cat && if [ -s kwarning ]; \
then rm kwarning; \ then rm kwarning; \
exit 1; \ exit 1; \
else \ else \
rm kwarning; \ rm kwarning; \
fi fi
MODULE_WARNING = "warning: the 'modules' option is not supported" KCONFIG_OLDCONFIG = oldconfig ${KCONFIG_WARNING}
PURGE_MODULE_WARNING = 2> >(grep -v ${MODULE_WARNING} | tee kwarning) | cat && ${KCONFIG_WARNING} KCONFIG_OLDDEFCONFIG = olddefconfig ${KCONFIG_WARNING}
KCONFIG_OLDCONFIG = oldconfig ${PURGE_MODULE_WARNING} KCONFIG_MENUCONFIG = menuconfig $(subst | cat,,${KCONFIG_WARNING})
KCONFIG_OLDDEFCONFIG = olddefconfig ${PURGE_MODULE_WARNING} KCONFIG_NCONFIG = guiconfig ${KCONFIG_WARNING}
KCONFIG_MENUCONFIG = menuconfig $(subst | cat,,${PURGE_MODULE_WARNING})
KCONFIG_NCONFIG = guiconfig ${PURGE_MODULE_WARNING}
KCONFIG_QCONFIG = ${KCONFIG_NCONFIG} KCONFIG_QCONFIG = ${KCONFIG_NCONFIG}
KCONFIG_GCONFIG = ${KCONFIG_NCONFIG} KCONFIG_GCONFIG = ${KCONFIG_NCONFIG}
KCONFIG_SAVEDEFCONFIG = savedefconfig --out defconfig.tmp ${PURGE_MODULE_WARNING} KCONFIG_SAVEDEFCONFIG = savedefconfig --out defconfig.tmp ${KCONFIG_WARNING}
define kconfig_tweak_disable define kconfig_tweak_disable
$(Q) sed -i'.orig' '/$2/d' $1 $(Q) sed -i'.orig' '/$2/d' $1
$(Q) rm -f $1.orig $(Q) rm -f $1.orig