libc/builtin: support per-application priority/stacksize under KERNEL build.

nsh_fileapp() could not apply an application's Kconfig-configured
priority/stacksize via posix_spawn() under CONFIG_BUILD_KERNEL, because
the registry table (struct builtin_s / g_builtins[]) was gated on
CONFIG_BUILTIN, which depends on !BUILD_KERNEL. Those settings were
silently ignored in KERNEL builds.

CONFIG_BUILTIN conflates the table with main_t-based dispatch, which is
meaningless under CONFIG_BUILD_KERNEL. Add a hidden derived symbol,
APP_REGISTRY, that tracks table availability independently of dispatch:

  config APP_REGISTRY
          bool
          default y if BUILTIN || BUILD_KERNEL

Switch the guards on the table itself (Make.defs, builtin.h) from
CONFIG_BUILTIN to CONFIG_APP_REGISTRY. Call sites that dereference
builtin->main stay gated on CONFIG_BUILTIN and remain unreachable
under CONFIG_BUILD_KERNEL.

Signed-off-by: liang.huang <liang.huang@houmo.ai>
This commit is contained in:
liang.huang 2026-07-12 07:57:07 +08:00 committed by Alan C. Assis
parent 34170a4475
commit 170a989ccb
4 changed files with 20 additions and 4 deletions

View file

@ -30,12 +30,16 @@
#include <nuttx/config.h>
#include <sys/types.h>
#ifdef CONFIG_BUILTIN
#ifdef CONFIG_APP_REGISTRY
/****************************************************************************
* Public Types
****************************************************************************/
/* Under CONFIG_BUILD_KERNEL, only priority/stacksize are consumed; main
* (and uid/gid/mode, if enabled) are populated but unused.
*/
struct builtin_s
{
FAR const char *name; /* Invocation name and as seen under /sbin/ */
@ -241,5 +245,5 @@ int builtin_getmode(int index);
}
#endif
#endif /* CONFIG_BUILTIN */
#endif /* CONFIG_APP_REGISTRY */
#endif /* __INCLUDE_NUTTX_LIB_BUILTIN_H */