toku-mac opened a new issue, #3472:
URL: https://github.com/apache/nuttx-apps/issues/3472

   ### 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:**
   1. Configure NuttX for a board with a Rust example (e.g., 
`nucleo-h563zi:nsh` with Rust enabled).
   2. Run CMake configuration:
      ```bash
      cmake -S . -B build -DBOARD_CONFIG=nucleo-h563zi:nsh -GNinja
      ```
   3. Attempt to build:
      ```bash
      cmake --build build
      ```
   
   **Expected Result:**
   The Rust crate should be compiled successfully using the default Cargo 
profile.
   
   **Actual Result:**
   The build fails with the following error:
   ```text
   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.
   
   ```cmake
     # 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
   
   - [x] I have verified before submitting the report.


-- 
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]

Reply via email to