JianyuWang0623 opened a new pull request, #4109:
URL: https://github.com/apache/nuttx-apps/pull/4109
## Summary
Fix four build integration issues in system/toybox's CMake support: the
applet selection filter, KCONFIG_CONFIG clobbering, flat-link symbol
collisions, and the unconditionally compiled builtin bridge file.
## Impact
Only enabled applets are compiled now, so the "Toybox commands" menu
takes effect in CMake builds (the Makefile path already filtered on
`=y`). Toybox genconfig no longer overwrites the outer build's .config
when the surrounding build exports KCONFIG_CONFIG. Flat links with apps
that define `strstart` or `show_help` (such as quickjs's `strstart`)
succeed, and builds with `CONFIG_SYSTEM_TOYBOX_BUILTIN_BRIDGE=n` no
longer compile bridge code.
## Testing
Build Host: Ubuntu 22.04.5 LTS, Linux x86_64, gcc 13.4.0 (host gcc,
CROSSDEV empty), CMake 3.23.0, Ninja 1.10.1
Target: sim:toybox
```
$ cmake -B build -DBOARD_CONFIG=sim:toybox -G Ninja && cmake --build build
-j28
$ printf 'uname -a\nhelp\nexit\n' | ./build/nuttx
Toybox 0.8.14-nuttx for NuttX -- 'help' lists commands, 'exit' leaves the
prompt.
toybox> uname -a
NuttX 13.1.1 77ed93a25dd-dirty Nov 22 2026 10:52:58 sim Toybox
toybox> help
[ base64 basename cal cat chgrp chmod chown cksum clear cmp comm cp
cpio cut date dd df diff dirname dos2unix du echo egrep env expand
expr fallocate false fgrep file find fmt free fsync getopt grep groups
gunzip gzip head help hostname id kill killall ln logname ls md5sum
mkdir mkfifo mktemp mv nice nl nohup nproc od paste pgrep pidof pkill
printenv printf prlimit ps pwd readlink realpath renice rev rm rmdir
sed seq setsid sha1sum sha224sum sha256sum sha384sum sha512sum sleep
sort split stat strings sync tac tail tar tee test time timeout touch
tr true truncate ulimit uname uniq unix2dos unlink uptime usleep uudecode
uuencode uuidgen wc which whoami xargs xxd yes zcat
toybox> exit
```
Applet selection (sim:toybox with only uname/usleep/ls enabled in the
"Toybox commands" menu, the 109 others explicitly disabled), same run
command. Without the fix the selection is ignored and every applet is
compiled in:
```
toybox> help
[ base64 basename cal cat chgrp chmod chown cksum clear cmp comm cp
cpio cut date dd df diff dirname dos2unix du echo egrep env expand
expr fallocate false fgrep file find fmt free fsync getopt grep groups
gunzip gzip head help hostname id kill killall ln logname ls md5sum
mkdir mkfifo mktemp mv nice nl nohup nproc od paste pgrep pidof pkill
printenv printf prlimit ps pwd readlink realpath renice rev rm rmdir
sed seq setsid sha1sum sha224sum sha256sum sha384sum sha512sum sleep
sort split stat strings sync tac tail tar tee test time timeout touch
tr true truncate ulimit uname uniq unix2dos unlink uptime usleep uudecode
uuencode uuidgen wc which whoami xargs xxd yes zcat
toybox> exit
```
With the fix, the same config builds only the three selected applets:
```
toybox> help
ls uname usleep
toybox> exit
```
KCONFIG_CONFIG clobbering: on master, the configure step leaves toybox's
own configuration in the build directory's .config (KCONFIG_CONFIG is
exported by the outer build), and the next configure fails:
```
$ head -4 build/.config
# Sun Nov 22 10:37:35 2026
# CONFIG_IS_ANDROID is not set
# CONFIG_IS_FDPIC is not set
$ cmake -B build -DBOARD_CONFIG=sim:toybox -G Ninja
CMake Error at CMakeLists.txt:619 (include):
include could not find requested file:
platform
```
With the fix, build/.config is the NuttX configuration and is
byte-identical before and after the configure step, and a second
configure succeeds:
```
$ sha256sum build/.config # before configure
26e548ed823853d6fa1db0d33402b654498e983857453b469a46ff2a3ced8c8d
build/.config
$ cmake -B build -DBOARD_CONFIG=sim:toybox -G Ninja
$ sha256sum build/.config # after configure
26e548ed823853d6fa1db0d33402b654498e983857453b469a46ff2a3ced8c8d
build/.config
$ cmake -B build -DBOARD_CONFIG=sim:toybox -G Ninja # reconfigure
-- Configuring done
-- Generating done
-- Build files have been written to: .../build
```
Flat-link collision (sim:toybox with interpreters/quickjs enabled),
without the fix the link fails:
```
/usr/bin/ld: .../apps/interpreters/quickjs/liblibqjs.a(cutils.c.o): in
function `strstart':
.../apps/interpreters/quickjs/quickjs/cutils.c:60: multiple definition of
`strstart';
.../apps/system/toybox/libapps_toybox.a(lib.c.o):.../apps/system/toybox/toybox/lib/lib.c:507:
first defined here
collect2: error: ld returned 1 exit status
```
With the fix the same config links and both toybox and quickjs run:
```
toybox> uname -a
NuttX 13.1.1 77ed93a25dd Nov 22 2026 10:44:54 sim Toybox
toybox> qjs -e print(40+2)
42
toybox> exit
```
Builtin bridge guard (sim:toybox with
CONFIG_SYSTEM_TOYBOX_BUILTIN_BRIDGE=n): the build works and the toybox
archive no longer carries dead bridge code with dangling references to
apps/builtin:
```
$ nm apps/system/toybox/libapps_toybox.a | grep -c "U exec_builtin\|U
builtin_isavail"
0
$ printf 'uname -a\nqjs -e print(1)\nexit\n' | ./build/nuttx
Toybox 0.8.14-nuttx for NuttX -- 'help' lists commands, 'exit' leaves the
prompt.
toybox> uname -a
NuttX 13.1.1 77ed93a25dd Nov 22 2026 10:51:54 sim Toybox
toybox> qjs -e print(1)
toybox_multiplex: Unknown command qjs (see "toybox_multiplex --help")
toybox> exit
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]