Summary:
- Added `codegen-units = 1` and `opt-level = 'z'` to the release profile in `Cargo.toml`
- These changes optimize the build for minimal binary size
Impact:
- Reduces the final binary size by ~7% (244316 -> 228380 bytes)
- Improves resource utilization for embedded systems
- No functional changes to the application behavior
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Build Rust applictions with cargo is the most commn way,
and it's more easy to cooporate with Rust ecosystem.
This example shows how to use cargo to build a simple hello world
application.
And please notice that you need to install nighly version of rustc
to support this feature, any version after https://github.com/rust-lang/rust/pull/127755
is merged, can use NuttX as cargo target directly.
Build
-----
To build hello_rust_cargo application, you can use any target that based
on RISCV32IMAC, for example:
```
cmake -B build -DBOARD_CONFIG=rv-virt:nsh -GNinja .
```
And disable ARCH_FPU in menuconfig, since the hard coded target triple
in this demo is `riscv32imac`.
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>