Which toolchain to use when testing building no_std alloc crates?

For no_std, building thumbv6m-none-eabi can be very useful to find any accidental std use, and to make sure you import everything from core you need to.
It seems that this target doesn't have alloc available, so the build ends with an error on using any using alloc::.

Building with the thumbv6m-none-eabi target is still useful, because you can still ignore just the alloc errors, but is there any target that both doesn't have an std, and has an alloc implementation?

There's a clippy lint for this: https://rust-lang.github.io/rust-clippy/master/index.html#/std_instead_of_core

1 Like

Thank you, that's super useful.

When I compile with thumbv6m-none-eabi, there seems to be no core prelude as well.
As a result, I had to manually include imports like Option to make it (almost, because of alloc) compile for that target.
Is that considered a standard approach for no_std crates, or do most of them rely on the core prelude being available?

If you use #![no_std] the core prelude at core::prelude::rust_2021 (or whatever edition you use) should be used.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.