examples/rust: Avoid the infinite loop on sim for hello_rust_cargo#3544
Open
toku-mac wants to merge 1 commit into
Open
examples/rust: Avoid the infinite loop on sim for hello_rust_cargo#3544toku-mac wants to merge 1 commit into
toku-mac wants to merge 1 commit into
Conversation
On the sim target (Windows/macOS/Linux), hello_rust_cargo_main() ended
with an infinite `loop {}` that never returned control to NSH, so the
example could not exit and the shell prompt hung.
Introduce a Cargo `sim` feature that is enabled only when CONFIG_ARCH_SIM
is set, and use it to compile out the trailing infinite loop and return 0
instead. Other embedded targets keep the original looping behavior.
Signed-off-by: Shoji Tokunaga <toku@mac.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On the sim target,
hello_rust_cargo_main()finished with an infiniteloop {}.As a result the example never returned to NSH and the prompt appeared to hang after running
hello_rust_cargo.This PR makes the example return cleanly to NSH on sim (Windows/macOS/Linux) while preserving the original looping behavior on real targets.
simfeature to the hello crate.CONFIG_ARCH_SIMis set, from both the CMake and Make build paths.lib.rs, compile out the trailingloop {}when thesimfeature is active and return0instead.cargo buildconsistently.Testing
I confirm that changes are verified on local setup and works as intended:
Configuration and Build:
with make
with CMake
Execute:
PR verification Self-Check