toku-mac opened a new pull request, #3544:
URL: https://github.com/apache/nuttx-apps/pull/3544
## Summary
On the sim target, `hello_rust_cargo_main()` finished with an infinite `loop
{}`.
As a result the example never returned to NSH and the prompt appeared to
hang after running `hello_rust_cargo`.
This PR makes the example return cleanly to NSH on sim (Windows/macOS/Linux)
while preserving the original looping behavior on real targets.
- Add a Cargo `sim` feature to the hello crate.
- Enable the feature only when `CONFIG_ARCH_SIM` is set, from both the CMake
and Make build paths.
- In `lib.rs`, compile out the trailing `loop {}` when the `sim` feature is
active and return `0` instead.
- Plumb a generic features mechanism through the Rust build helpers so the
feature can be passed to `cargo build` consistently.
## Testing
I confirm that changes are verified on local setup and works as intended:
* Build Host(s): OS (macOS 26.5), CPU(Apple M1), compiler(Apple clang
version 21.0.0)
* Target(s): arch(sim)
* Ensure your PATH environment variable is properly configured to allow
execution of: menuconfig, olddefconfig, savedefconfig, and setconfig.
* Use the Rust toolchain version prior to nightly-2026-04-29 to avoid errors
related to
lib/rustlib/src/rust/library/std/src/sys/net/connection/socket/unix.rs.
Configuration and Build:
### with make
```
make distclean
./tools/configure.sh sim:nsh
printf 'CONFIG_SYSTEM_TIME64=y
CONFIG_FS_LARGEFILE=y
CONFIG_TLS_NELEM=16
CONFIG_DEV_URANDOM=y
CONFIG_EXAMPLES_HELLO_RUST_CARGO=y
CONFIG_EXAMPLES_HELLO_RUST_CARGO_STACKSIZE=8192
' >> .config
make olddefconfig
make
...
Compiling hello v0.1.0 (/Users/toku/nuttxspace/apps/examples/rust/hello)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 29.52s
LN: platform/board to /Users/toku/nuttxspace/apps/platform/dummy
Register: gpio
Register: hello
Register: hello_rust_cargo
Register: dd
Register: dumpstack
Register: nsh
Register: sh
Register: ostest
CP: /Users/toku/nuttxspace/nuttx/include/nuttx/config.h
CP: /Users/toku/nuttxspace/nuttx/include/nuttx/fs/hostfs.h
Building Rust code with cargo...
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.78s
LD: nuttx
ld: warning: -ld_classic is deprecated and will be removed in a future
release
ld: warning: -ld_classic is deprecated and will be removed in a future
release
```
### with CMake
```
rm -rf build-debug
make distclean
cmake -S . -B build-debug -DBOARD_CONFIG=sim:nsh -GNinja
printf 'CONFIG_SYSTEM_TIME64=y
CONFIG_FS_LARGEFILE=y
CONFIG_TLS_NELEM=16
CONFIG_DEV_URANDOM=y
CONFIG_EXAMPLES_HELLO_RUST_CARGO=y
CONFIG_EXAMPLES_HELLO_RUST_CARGO_STACKSIZE=8192
' >> build-debug/.config
cmake --build build-debug -t olddefconfig
cmake --build build-debug
...
Compiling pin-project-lite v0.2.17
Compiling memchr v2.8.0
Compiling itoa v1.0.18
Compiling tokio v1.52.3
Compiling hello v0.1.0 (/Users/toku/nuttxspace/apps/examples/rust/hello)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 35.66s
[1225/1230] Linking C executable nuttx
ld: warning: -ld_classic is deprecated and will be removed in a future
release
[1227/1230] Patching Mach-O init section type flags
```
Execute:
```
NuttShell (NSH) NuttX-12.13.0
nsh> help
help usage: help [-v] [<cmd>]
. cmp false mkfifo readlink time
[ dirname fdinfo mkrd rm true
? date free mount rmdir truncate
alias df help mv set uname
unalias dmesg hexdump pidof kill umount
basename echo losetup poweroff pkill unset
break env ln quit sleep uptime
cat exec ls printf usleep watch
cd exit mkdir ps source xd
cp expr mkfatfs pwd test wait
Builtin Apps:
dd nsh ostest hello
dumpstack sh gpio
hello_rust_cargo
nsh> uname -a
NuttX 12.13.0 82fb723bde-dirty Jun 16 2026 10:16:16 sim sim
nsh> hello_rust_cargo
{"name":"John","age":30}
{"name":"Jane","age":25}
Deserialized: Alice is 28 years old
Pretty JSON:
{
"name": "Alice",
"age": 28
}
Hello world from tokio!
nsh> poweroff
```
## PR verification Self-Check
* [x] My PR adheres to Contributing
[Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md) and
[Documentation](https://nuttx.apache.org/docs/latest/contributing/index.html)
(git commit title and message, coding standard, etc).
* [x] My PR is ready for review and can be safely merged into a codebase.
--
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]