Description / Steps to reproduce the issue
Description:
When building NuttX with Rust applications using CMake, the build fails because cargo build is invoked with an invalid --debug argument. In Cargo, the debug build is the default, and it does not recognize a --debug flag (it uses --release for optimized builds).
Steps to Reproduce:
- Configure NuttX for a board with a Rust example (e.g.,
nucleo-h563zi:nsh with Rust enabled).
- Run CMake configuration:
cmake -S . -B build -DBOARD_CONFIG=nucleo-h563zi:nsh -GNinja
- Attempt to build:
Expected Result:
The Rust crate should be compiled successfully using the default Cargo profile.
Actual Result:
The build fails with the following error:
FAILED: apps/examples/rust/hello/hello/target/.../debug/libhello.a
...
cargo build --debug -Zbuild-std=std,panic_abort ...
error: unexpected argument '--debug' found
tip: `--debug` is the default for `cargo build`; instead `--release` is supported
Usage: cargo build [OPTIONS]
Proposed Fix:
The nuttx_add_rust.cmake script currently uses --${RUST_PROFILE} which evaluates to cargo build --debug when CONFIG_DEBUG_FULLOPT is not set. This should be changed to omit the flag for debug builds and only provide --release when appropriate.
# Determine build profile based on CONFIG_DEBUG_FULLOPT
if(CONFIG_DEBUG_FULLOPT)
set(RUST_PROFILE_FLAG "--release")
set(RUST_PROFILE "release")
...
else()
set(RUST_PROFILE_FLAG "")
set(RUST_PROFILE "debug")
...
endif()
# In add_custom_command
COMMAND
...
cargo build ${RUST_PROFILE_FLAG}
...
On which OS does this issue occur?
[OS: Mac]
What is the version of your OS?
26.4.1
NuttX Version
12.13.0
Issue Architecture
[Arch: arm]
Issue Area
[Area: Examples]
Host information
No response
Verification
Description / Steps to reproduce the issue
Description:
When building NuttX with Rust applications using CMake, the build fails because
cargo buildis invoked with an invalid--debugargument. In Cargo, the debug build is the default, and it does not recognize a--debugflag (it uses--releasefor optimized builds).Steps to Reproduce:
nucleo-h563zi:nshwith Rust enabled).cmake -S . -B build -DBOARD_CONFIG=nucleo-h563zi:nsh -GNinjaExpected Result:
The Rust crate should be compiled successfully using the default Cargo profile.
Actual Result:
The build fails with the following error:
Proposed Fix:
The
nuttx_add_rust.cmakescript currently uses--${RUST_PROFILE}which evaluates tocargo build --debugwhenCONFIG_DEBUG_FULLOPTis not set. This should be changed to omit the flag for debug builds and only provide--releasewhen appropriate.On which OS does this issue occur?
[OS: Mac]
What is the version of your OS?
26.4.1
NuttX Version
12.13.0
Issue Architecture
[Arch: arm]
Issue Area
[Area: Examples]
Host information
No response
Verification