-
Notifications
You must be signed in to change notification settings - Fork 547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
examples: New app to build Rust with Cargo #2487
base: master
Are you sure you want to change the base?
Conversation
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 rust-lang/rust#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 <[email protected]>
[Experimental Bot, please feedback here] PR Requirements ReviewMeeting Requirements? Partially Summary:
Impact:
Testing:
Specific Concerns
RecommendationThis PR addresses a desirable feature but is not yet ready for merging in its current state. Address the concerns outlined above to ensure a robust, well-documented, and well-tested addition to NuttX. |
COMMAND | ||
cargo build --release -Zbuild-std=core --manifest-path | ||
${CMAKE_CURRENT_SOURCE_DIR}/hello/Cargo.toml --target | ||
riscv32imac-unknown-nuttx-elf --target-dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we generalize the common to a function for all possible arch?
OUTPUT | ||
${CMAKE_BINARY_DIR}/hello_rust_cargo/riscv32imac-unknown-nuttx-elf/release/libhello.a | ||
COMMAND | ||
cargo build --release -Zbuild-std=core --manifest-path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we move to examples/hello_rust_cargo/hello/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or better examples/rust/cargo/hello? :-)
PROGNAME = $(CONFIG_EXAMPLES_HELLO_RUST_CARGO_PROGNAME) | ||
PRIORITY = $(CONFIG_EXAMPLES_HELLO_RUST_CARGO_PRIORITY) | ||
STACKSIZE = $(CONFIG_EXAMPLES_HELLO_RUST_CARGO_STACKSIZE) | ||
MODULE = $(CONFIG_EXAMPLES_HELLO_RUST_CARGO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how to link libhello.a
ping @no1wudi |
I'll continue this work next week |
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 rust-lang/rust#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:
And disable ARCH_FPU in menuconfig, since the hard coded target triple in this demo is
riscv32imac
.TODO