nom: Building nom for no_std fails on dependency memchr

Hello there, I’m trying to build nom for a RISC-V target which will use no_std. But after adding it to my Cargo.toml rust complained that a dependency required std.

However looking at the previous issues, I found https://github.com/Geal/nom/issues/1370 and saw that there was a fix so I switched my dependency to point directly at github:

[dependencies.nom]
# version = "7.0.0"
git = "https://github.com/Geal/nom"
default-features = false
features = []

However this is still producing:

error[E0463]: can't find crate for `std`
  |
  = note: the `riscv32imac-unknown-none-elf` 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`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `memchr`

Looking at the nom Cargo.toml features, it seems like turning off all default features (like I’m doing above) should turn off std in all deps. And it did help, as I fixed the error I was getting in the issue above but I now get an error for memchr.

Any ideas why setting default-features = false wouldn’t do the trick for memchr?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16

Most upvoted comments

Oh perfect! Thanks @buhe and @Geal for your help! I updated the example project. To make it work here’s what I did:

  1. First update rust with rustup update
  2. Run cargo fix --edition
    • The build will still fail after this command runs, but just continue.
  3. Set the edition in Cargo.toml to 2021
  4. cargo build should now properly build with nom, and the memchr dependency error no longer occurs.

oh…I change 2018 to 2021, everything is ok.