trussed-dev/littlefs2

requires std?

gauteh opened this issue · 6 comments

Hi, just discovered this lib. Seems like something very useful for storing data on an sd card on a microcontroller. When I try to add this library to a no_std binary I get errors with memchr, does it require std with an allocator?

   Compiling memchr v2.4.1
   Compiling generic-array v0.14.4
   Compiling regex v1.5.4
   Compiling delog v0.1.2
   Compiling serde_derive v1.0.130
   Compiling bare-metal v0.2.5
   Compiling cortex-m-rt v0.7.0
   Compiling cortex-m v0.7.3
error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv7em-none-eabi` target may not support the standard library
  = note: `std` is required by `memchr` because it does not declare `#![no_std]`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `memchr` due to previous error
[package]
name = "sby-buoy"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
littlefs2 = "0.3.1"
panic-halt = "0.2.0"

Hey, thanks for your interest. You don't need no_std (cf. https://docs.rs/memchr/2.4.1/memchr/#crate-features), we use this in https://github.com/solokeys/solo2/tree/main/runners/lpc55. I think if you link to https://github.com/solokeys/solo2/tree/main/components/c-stubs in your dependencies it might just work, if not let me know and I can try to reconstruct what exactly the dependencies are.

I remembered... In this commit: nickray@cdcb99f I removed a workaround for fact that the bindgen build dependency (of littlefs2-sys) triggers the std feature of memchr. However, with a new cargo you can simply add a line resolver = "2" under [package] in your consuming crate.

The link to a c-stubs is necessary at build time, otherwise you'll get a linker error then.

I'll try and improve the docs on this.

Thanks. I'll experiment a bit more when I get a bit further on the project