Skip to content
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

Undocumented Cargo.toml features #194

Open
VorpalBlade opened this issue Apr 26, 2023 · 2 comments
Open

Undocumented Cargo.toml features #194

VorpalBlade opened this issue Apr 26, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@VorpalBlade
Copy link

The README only documents a handful of the features (native, pio, binstart and libstart). However, there are several more:

  • std
  • alloc_handler
  • panic_handler

While I can guess roughly about what these do, it would be nice to have documentation on them. For example, should I use alloc_handler here or the alloc feature in esp-idf-svc? What is the difference?

@ivmarkov
Copy link
Collaborator

ivmarkov commented Apr 27, 2023

You are right about lack of enough documentation (btw - we gladly accept PRs, including for documentation!).

Yet, you are also asking a generic Rust "what is the difference between std vs no_std" question. Let me try to address it:

If you are opting out from std (i.e. the std feature is not enabled - and note that it IS enabled by default, as the cases where you might not want std enabled with the esp-idf-* crates are niche, if existing at all), then you must provide yourself a) an alloc-handler and b) a panic-handler. The respective two features just provide these two handlers for you. The alloc-handler feature implements a Rust allocator (needed by the Rust alloc module which will be used when the alloc feature is enabled) which is just based on ESP IDF's malloc/free libc code. The panic handler in turn just calls the ESP IDF panic handler.

This old Rust bug is containing a nice and more elaborated info on the generic question you are asking: rust-lang/rust#66740

@VorpalBlade
Copy link
Author

You are right that I'm new to embedded and no-std rust (though I have done that sort of things in C before). In the case of the HALs and related crates it wasn't clear to me where they are 1) enabling feature that use alloc/std 2) providing things that allow std/alloc to work. 3) providing things that allow non-std to work (i.e. replace things that std/alloc would normally provide).

@Vollbrecht Vollbrecht added the documentation Improvements or additions to documentation label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants