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

requires std? #14

Open
gauteh opened this issue Sep 25, 2021 · 6 comments
Open

requires std? #14

gauteh opened this issue Sep 25, 2021 · 6 comments

Comments

@gauteh
Copy link

gauteh commented Sep 25, 2021

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?

@gauteh
Copy link
Author

gauteh commented Sep 26, 2021

   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"

@nickray
Copy link
Member

nickray commented Sep 26, 2021

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.

@nickray
Copy link
Member

nickray commented Sep 26, 2021

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.

@gauteh
Copy link
Author

gauteh commented Sep 29, 2021

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

@nickray
Copy link
Member

nickray commented Sep 29, 2021

I released 0.3.2: https://docs.rs/littlefs2/0.3.2/littlefs2/#no_std

@gauteh
Copy link
Author

gauteh commented Sep 30, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants