Skip to content

examples/rust: Fix hello_rust_cargo CMake settings#3494

Merged
lupyuen merged 1 commit into
apache:masterfrom
toku-mac:fix_rust_cmake_config
May 22, 2026
Merged

examples/rust: Fix hello_rust_cargo CMake settings#3494
lupyuen merged 1 commit into
apache:masterfrom
toku-mac:fix_rust_cmake_config

Conversation

@toku-mac
Copy link
Copy Markdown
Contributor

examples/rust: Fix CMake stack and priority config names

Summary

This fixes the CMake configuration for the hello_rust_cargo example.

The CMake file was using CONFIG_EXAMPLES_HELLO_STACKSIZE and
CONFIG_EXAMPLES_HELLO_PRIORITY, but this application is configured by the
CONFIG_EXAMPLES_HELLO_RUST_CARGO_* symbols. The Makefile already uses the
Rust Cargo-specific symbols.

With this change, the CMake built-in application registration uses the
configured Rust Cargo example stack size and priority, matching the Makefile
behavior.

Impact

When running on a target, it prevents "malloc() and other functions failing and triggering assertions."

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(ARM GCC 14.3.rel1)
  • Target(s): arch(thumbv8m)
  • 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:

cd ~/nuttxspace/nuttx
source ../.venv/bin/activate
rm -rf build-debug
make distclean
# cmake --build build-default -t distcleanconfig
cmake -S . -B build-debug -DBOARD_CONFIG=nucleo-h563zi: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

Build:

cmake --build build-debug
[0/2] Re-checking globbed directories...
[1/2] Re-running CMake...
-- NuttX Host Tools
-- CMake C compiler: AppleClang
-- CMake system name: Darwin
-- CMake host system processor: arm64
   TOOLS_DIR path is "/Users/toku/nuttxspace/nuttx"
   HOST = Darwin
-- Configuring done (0.1s)
-- Generating done (0.3s)
-- Build files have been written to: /Users/toku/nuttxspace/nuttx/build-debug/bin_host
-- nuttx_add_subdirectory: Skipping cxx-oot-build
-- Configuring done (3.1s)
-- Generating done (0.7s)
-- Build files have been written to: /Users/toku/nuttxspace/nuttx/build-debug
[0/4] Re-checking globbed directories...
[1155/1161] Building Rust crate hello
   Compiling compiler_builtins v0.1.160 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins)
   Compiling core v0.0.0 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/core)
   Compiling libc v0.2.185
   Compiling object v0.37.3
   Compiling std v0.0.0 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/std)
   Compiling proc-macro2 v1.0.106
   Compiling quote v1.0.45
   Compiling unicode-ident v1.0.24
   Compiling serde_core v1.0.228
   Compiling zmij v1.0.21
   Compiling serde_json v1.0.149
   Compiling serde v1.0.228
   Compiling syn v2.0.117
   Compiling rustc-std-workspace-core v1.99.0 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc)
   Compiling adler2 v2.0.1
   Compiling memchr v2.7.6
   Compiling panic_abort v0.0.0 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/panic_abort)
   Compiling cfg-if v1.0.4
   Compiling rustc-demangle v0.1.27
   Compiling rustc-literal-escaper v0.0.7
   Compiling unwind v0.0.0 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/unwind)
   Compiling serde_derive v1.0.228
   Compiling rustc-std-workspace-alloc v1.99.0 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
   Compiling panic_unwind v0.0.0 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/panic_unwind)
   Compiling gimli v0.32.3
   Compiling hashbrown v0.17.0
   Compiling std_detect v0.1.5 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/std_detect)
   Compiling miniz_oxide v0.8.9
   Compiling addr2line v0.25.1
   Compiling proc_macro v0.0.0 (/Users/toku/.rustup/toolchains/nightly-2026-04-29-aarch64-apple-darwin/lib/rustlib/src/rust/library/proc_macro)
   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 20.43s
[1156/1161] Linking CXX executable nuttx
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: warning: umm_mallinfo.c.o: missing .note.GNU-stack section implies executable stack
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
Memory region         Used Size  Region Size  %age Used
           flash:     1267092 B         2 MB     60.42%
            sram:       11560 B       256 KB      4.41%
[1158/1161] Generating System.map

Testing logs before change:

  • Running hello_rust_cargo may sometimes cause assertion failures.

Testing logs after change:

  • Improves stability of operation.
nsh> help
help usage:  help [-v] [<cmd>]

    .           cp          expr        mount       kill        uname       
    [           cmp         false       mv          pkill       umount      
    ?           dirname     fdinfo      pidof       sleep       unset       
    alias       df          free        printf      usleep      uptime      
    unalias     dmesg       help        ps          source      watch       
    basename    echo        hexdump     pwd         test        xd          
    break       env         ls          rm          time        wait        
    cat         exec        mkdir       rmdir       true        
    cd          exit        mkrd        set         truncate    

Builtin Apps:
    dd                  nsh                 sh                  hello_rust_cargo    
nsh> 
nsh> uname -a
NuttX 12.13.0 a50614512c May 22 2026 09:27:10 arm nucleo-h563zi
nsh> 
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!

Use the hello_rust_cargo-specific Kconfig symbols for the built-in
application stack size and priority.

Previously, CMake referenced the generic hello example symbols, so the
configured hello_rust_cargo stack size could be ignored.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
@lupyuen
Copy link
Copy Markdown
Member

lupyuen commented May 22, 2026

@no1wudi Could you help to review this PR? Thanks :-)

@lupyuen lupyuen merged commit c9c5c75 into apache:master May 22, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants