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

Building nom for no_std fails on dependency memchr #1457

Closed
dougli1sqrd opened this issue Nov 4, 2021 · 16 comments
Closed

Building nom for no_std fails on dependency memchr #1457

dougli1sqrd opened this issue Nov 4, 2021 · 16 comments

Comments

@dougli1sqrd
Copy link

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 #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?

@Geal
Copy link
Collaborator

Geal commented Nov 4, 2021

is there another dependency using nom and activating features on it?

@dougli1sqrd
Copy link
Author

There isn't. There are other dependencies that depend on memchr though. However, removing nom from my deps allows the project to build, implying that the other dependencies with memchr are also not activating std? It's only when nom is added.

When I get a chance I'll try making a minimal project to see if there is some weird interaction with another dependency I have.

When running cargo build --verbose rustc is definitely trying to build memchr with default featurs and std.

Running `rustc --crate-name memchr --edition=2018 /home/dougli1sqrd/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.4.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=d2a84c1b4c2d1b6d -C extra-filename=-d2a84c1b4c2d1b6d --out-dir /home/dougli1sqrd/code/rustbox-hifive1-revb/target/riscv32imac-unknown-none-elf/debug/deps --target riscv32imac-unknown-none-elf -L dependency=/home/dougli1sqrd/code/rustbox-hifive1-revb/target/riscv32imac-unknown-none-elf/debug/deps -L dependency=/home/dougli1sqrd/code/rustbox-hifive1-revb/target/debug/deps --extern 'noprelude:alloc=/home/dougli1sqrd/code/rustbox-hifive1-revb/target/riscv32imac-unknown-none-elf/debug/deps/liballoc-0d2f52b706d884a6.rmeta' --extern 'noprelude:compiler_builtins=/home/dougli1sqrd/code/rustbox-hifive1-revb/target/riscv32imac-unknown-none-elf/debug/deps/libcompiler_builtins-3d482bac6f4ec347.rmeta' --extern 'noprelude:core=/home/dougli1sqrd/code/rustbox-hifive1-revb/target/riscv32imac-unknown-none-elf/debug/deps/libcore-52354e9c53940d67.rmeta' -Z unstable-options --cap-lints allow -C link-arg=-Trustbox/src/lds/memory-hifive1-revb.x -C link-arg=-Tlink.x

It sounds like what you're saying, ultimately, is that some other dep could be turning it back on for memchr?

@Geal
Copy link
Collaborator

Geal commented Nov 4, 2021

this looks really weird, and from what you're telling it comes from nom. Could you show the output of cargo tree -e features ? With and without nom in tree?

@buhe
Copy link

buhe commented Nov 5, 2021

├── nom v7.1.0 (https://github.com/Geal/nom#b6f79c4d)
│   ├── memchr v2.3.4
│   └── minimal-lexical v0.2.1
│   [build-dependencies]
│   └── version_check feature "default"
│       └── version_check v0.9.3

I also happen same error, this is my output, thanks.

@buhe
Copy link

buhe commented Nov 5, 2021

my rust env is nightly-2021-11-01, my case also a RISC-V target (k210) which will use no_std.

my cargo.toml file is


nom = { git = "https://github.com/Geal/nom", default-features = false}

@Geal
Copy link
Collaborator

Geal commented Nov 5, 2021

could you provide an example project? I tested locally with that:

[package]                                                                                         
name = "no_std_test"                                                                              
version = "0.1.0"                                                                                 
edition = "2021"                                                                                  
                                                                                                                                                                        
[dependencies]                                                                                    
#nom = { version = "7.0.0", default-features = false, features = [] }                             
nom = { git = "https://github.com/Geal/nom", default-features = false, features = [] }            
                                                                                                  
[profile.dev]                                                                                     
panic = "abort"                                                                                   
                                                                                                  
[profile.release]                                                                                 
panic = "abort"                                                                                   
#![no_main]                                                
#![no_std]                                                 
                                                           
use core::panic::PanicInfo;                                
                                                           
fn main() {                                                
  let s = "abc";                                           
  nom::character::complete::digit0::<_, ()>(s).unwrap();   
}                                                          
                                                           
#[panic_handler]                                           
fn panic(_panic: &PanicInfo<'_>) -> ! {                    
    loop {}                                                
}                                                          

and it builds fine. I tried with rustc 1.57.0-nightly (5ecc8ad84 2021-09-19) and the same target

@dougli1sqrd
Copy link
Author

Here is my cargo tree outputs:

with nom
$ cargo tree -e features -p console

console v0.1.0 (/home/dougli1sqrd/code/rustbox-hifive1-revb/console)
├── hashbrown v0.11.2
├── nom v7.0.0 (https://github.com/Geal/nom#324125f2)
│   ├── memchr v2.4.1
│   └── minimal-lexical v0.2.1
│   [build-dependencies]
│   └── version_check feature "default"
│       └── version_check v0.9.3
├── buddyalloc feature "default"
│   └── buddyalloc v0.1.5
├── embedded-hal feature "default"
│   └── embedded-hal v0.2.6
│       ├── void v1.0.2
│       └── nb feature "default"
│           └── nb v0.1.3
│               └── nb feature "default"
│                   └── nb v1.0.0
├── heapless feature "default"
│   ├── heapless v0.7.7
│   │   ├── stable_deref_trait v1.2.0
│   │   └── hash32 feature "default"
│   │       └── hash32 v0.2.1
│   │           └── byteorder v1.4.3
│   └── heapless feature "cas"
│       ├── heapless v0.7.7 (*)
│       └── heapless feature "atomic-polyfill"
│           └── heapless v0.7.7 (*)
├── hifive1 feature "board-hifive1-revb"
│   ├── hifive1 v0.10.0
│   │   ├── embedded-hal feature "default" (*)
│   │   ├── nb feature "default" (*)
│   │   ├── e310x-hal feature "default"
│   │   │   └── e310x-hal v0.9.3
│   │   │       ├── embedded-hal feature "default" (*)
│   │   │       ├── embedded-hal feature "unproven"
│   │   │       │   ├── embedded-hal v0.2.6 (*)
│   │   │       │   └── nb feature "unstable"
│   │   │       │       └── nb v0.1.3 (*)
│   │   │       ├── nb feature "default" (*)
│   │   │       ├── e310x feature "default"
│   │   │       │   └── e310x v0.9.0
│   │   │       │       ├── bare-metal feature "default"
│   │   │       │       │   └── bare-metal v0.2.5
│   │   │       │       │       [build-dependencies]
│   │   │       │       │       └── rustc_version feature "default"
│   │   │       │       │           └── rustc_version v0.2.3
│   │   │       │       │               └── semver feature "default"
│   │   │       │       │                   └── semver v0.9.0
│   │   │       │       │                       └── semver-parser feature "default"
│   │   │       │       │                           └── semver-parser v0.7.0
│   │   │       │       ├── riscv feature "default"
│   │   │       │       │   └── riscv v0.6.0
│   │   │       │       │       ├── bare-metal feature "default" (*)
│   │   │       │       │       └── bit_field feature "default"
│   │   │       │       │           └── bit_field v0.10.1
│   │   │       │       │       [build-dependencies]
│   │   │       │       │       └── riscv-target feature "default"
│   │   │       │       │           └── riscv-target v0.1.2
│   │   │       │       │               ├── lazy_static feature "default"
│   │   │       │       │               │   └── lazy_static v1.4.0
│   │   │       │       │               └── regex feature "default"
│   │   │       │       │                   ├── regex v1.5.4
│   │   │       │       │                   │   ├── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── aho-corasick feature "default"
│   │   │       │       │                   │   │   ├── aho-corasick v0.7.18
│   │   │       │       │                   │   │   │   └── memchr v2.4.1
│   │   │       │       │                   │   │   └── aho-corasick feature "std"
│   │   │       │       │                   │   │       ├── aho-corasick v0.7.18 (*)
│   │   │       │       │                   │   │       └── memchr feature "std"
│   │   │       │       │                   │   │           └── memchr v2.4.1
│   │   │       │       │                   │   └── memchr feature "default"
│   │   │       │       │                   │       ├── memchr v2.4.1
│   │   │       │       │                   │       └── memchr feature "std" (*)
│   │   │       │       │                   ├── regex feature "perf"
│   │   │       │       │                   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   ├── regex feature "perf-cache"
│   │   │       │       │                   │   │   └── regex v1.5.4 (*)
│   │   │       │       │                   │   ├── regex feature "perf-dfa"
│   │   │       │       │                   │   │   └── regex v1.5.4 (*)
│   │   │       │       │                   │   ├── regex feature "perf-inline"
│   │   │       │       │                   │   │   └── regex v1.5.4 (*)
│   │   │       │       │                   │   └── regex feature "perf-literal"
│   │   │       │       │                   │       ├── regex v1.5.4 (*)
│   │   │       │       │                   │       ├── regex feature "aho-corasick"
│   │   │       │       │                   │       │   └── regex v1.5.4 (*)
│   │   │       │       │                   │       └── regex feature "memchr"
│   │   │       │       │                   │           └── regex v1.5.4 (*)
│   │   │       │       │                   ├── regex feature "std"
│   │   │       │       │                   │   └── regex v1.5.4 (*)
│   │   │       │       │                   ├── regex feature "unicode"
│   │   │       │       │                   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   ├── regex feature "unicode-age"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-age"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-bool"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-bool"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-case"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-case"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-gencat"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-gencat"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-perl"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-perl"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-script"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-script"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-segment"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-segment"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   └── regex-syntax feature "unicode"
│   │   │       │       │                   │       ├── regex-syntax v0.6.25
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-age" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-bool" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-case" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-gencat" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-perl" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-script" (*)
│   │   │       │       │                   │       └── regex-syntax feature "unicode-segment" (*)
│   │   │       │       │                   └── regex-syntax feature "default"
│   │   │       │       │                       ├── regex-syntax v0.6.25
│   │   │       │       │                       └── regex-syntax feature "unicode" (*)
│   │   │       │       └── vcell feature "default"
│   │   │       │           └── vcell v0.1.3
│   │   │       ├── e310x feature "rt"
│   │   │       │   └── e310x v0.9.0 (*)
│   │   │       └── riscv feature "default" (*)
│   │   └── riscv feature "default" (*)
│   └── e310x-hal feature "g002"
│       ├── e310x-hal v0.9.3 (*)
│       └── e310x feature "g002"
│           └── e310x v0.9.0 (*)
├── hifive1 feature "default"
│   └── hifive1 v0.10.0 (*)
├── lazy_static feature "default"
│   └── lazy_static v1.4.0
├── linked_list_allocator feature "default"
│   ├── linked_list_allocator v0.9.1
│   │   └── spinning_top feature "default"
│   │       └── spinning_top v0.2.4
│   │           └── lock_api feature "default"
│   │               └── lock_api v0.4.5
│   │                   └── scopeguard v1.1.0
│   └── linked_list_allocator feature "use_spin_nightly"
│       ├── linked_list_allocator v0.9.1 (*)
│       ├── linked_list_allocator feature "const_mut_refs"
│       │   └── linked_list_allocator v0.9.1 (*)
│       ├── linked_list_allocator feature "spinning_top"
│       │   └── linked_list_allocator v0.9.1 (*)
│       ├── linked_list_allocator feature "use_spin"
│       │   ├── linked_list_allocator v0.9.1 (*)
│       │   └── linked_list_allocator feature "spinning_top" (*)
│       └── spinning_top feature "nightly"
│           ├── spinning_top v0.2.4 (*)
│           └── lock_api feature "nightly"
│               └── lock_api v0.4.5 (*)
├── spinning_top feature "default" (*)
├── lock_api feature "default" (*)
├── panic-halt feature "default"
│   └── panic-halt v0.2.0
├── rand feature "small_rng"
│   └── rand v0.8.4
│       └── rand_core feature "default"
│           └── rand_core v0.6.3
├── riscv feature "default"
│   └── riscv v0.7.0
│       ├── bit_field feature "default" (*)
│       └── bare-metal feature "default"
│           └── bare-metal v1.0.0
│       [build-dependencies]
│       └── riscv-target feature "default" (*)
├── riscv-rt feature "default"
│   └── riscv-rt v0.8.0
│       ├── riscv feature "default" (*)
│       ├── r0 feature "default"
│       │   └── r0 v1.0.0
│       └── riscv-rt-macros feature "default"
│           └── riscv-rt-macros v0.1.6 (proc-macro)
│               ├── rand v0.5.6
│               │   └── rand_core v0.3.1
│               │       └── rand_core feature "default"
│               │           └── rand_core v0.4.2
│               ├── proc-macro2 feature "default"
│               │   ├── proc-macro2 v0.4.30
│               │   │   └── unicode-xid feature "default"
│               │   │       └── unicode-xid v0.1.0
│               │   └── proc-macro2 feature "proc-macro"
│               │       └── proc-macro2 v0.4.30 (*)
│               ├── quote feature "default"
│               │   ├── quote v0.6.13
│               │   │   └── proc-macro2 v0.4.30 (*)
│               │   └── quote feature "proc-macro"
│               │       ├── quote v0.6.13 (*)
│               │       └── proc-macro2 feature "proc-macro" (*)
│               ├── syn feature "default"
│               │   ├── syn v0.15.44
│               │   │   ├── proc-macro2 v0.4.30 (*)
│               │   │   ├── quote v0.6.13 (*)
│               │   │   └── unicode-xid feature "default" (*)
│               │   ├── syn feature "clone-impls"
│               │   │   └── syn v0.15.44 (*)
│               │   ├── syn feature "derive"
│               │   │   └── syn v0.15.44 (*)
│               │   ├── syn feature "parsing"
│               │   │   └── syn v0.15.44 (*)
│               │   ├── syn feature "printing"
│               │   │   ├── syn v0.15.44 (*)
│               │   │   └── syn feature "quote"
│               │   │       └── syn v0.15.44 (*)
│               │   └── syn feature "proc-macro"
│               │       ├── syn v0.15.44 (*)
│               │       ├── proc-macro2 feature "proc-macro" (*)
│               │       ├── quote feature "proc-macro" (*)
│               │       └── syn feature "quote" (*)
│               ├── syn feature "extra-traits"
│               │   └── syn v0.15.44 (*)
│               └── syn feature "full"
│                   └── syn v0.15.44 (*)
│       [build-dependencies]
│       └── riscv-target feature "default" (*)
└── volatile feature "default"
    └── volatile v0.4.4

Without Nom
$ cargo tree -e features -p console

console v0.1.0 (/home/dougli1sqrd/code/rustbox-hifive1-revb/console)
├── hashbrown v0.11.2
├── buddyalloc feature "default"
│   └── buddyalloc v0.1.5
├── embedded-hal feature "default"
│   └── embedded-hal v0.2.6
│       ├── void v1.0.2
│       └── nb feature "default"
│           └── nb v0.1.3
│               └── nb feature "default"
│                   └── nb v1.0.0
├── heapless feature "default"
│   ├── heapless v0.7.7
│   │   ├── stable_deref_trait v1.2.0
│   │   └── hash32 feature "default"
│   │       └── hash32 v0.2.1
│   │           └── byteorder v1.4.3
│   └── heapless feature "cas"
│       ├── heapless v0.7.7 (*)
│       └── heapless feature "atomic-polyfill"
│           └── heapless v0.7.7 (*)
├── hifive1 feature "board-hifive1-revb"
│   ├── hifive1 v0.10.0
│   │   ├── embedded-hal feature "default" (*)
│   │   ├── nb feature "default" (*)
│   │   ├── e310x-hal feature "default"
│   │   │   └── e310x-hal v0.9.3
│   │   │       ├── embedded-hal feature "default" (*)
│   │   │       ├── embedded-hal feature "unproven"
│   │   │       │   ├── embedded-hal v0.2.6 (*)
│   │   │       │   └── nb feature "unstable"
│   │   │       │       └── nb v0.1.3 (*)
│   │   │       ├── nb feature "default" (*)
│   │   │       ├── e310x feature "default"
│   │   │       │   └── e310x v0.9.0
│   │   │       │       ├── bare-metal feature "default"
│   │   │       │       │   └── bare-metal v0.2.5
│   │   │       │       │       [build-dependencies]
│   │   │       │       │       └── rustc_version feature "default"
│   │   │       │       │           └── rustc_version v0.2.3
│   │   │       │       │               └── semver feature "default"
│   │   │       │       │                   └── semver v0.9.0
│   │   │       │       │                       └── semver-parser feature "default"
│   │   │       │       │                           └── semver-parser v0.7.0
│   │   │       │       ├── riscv feature "default"
│   │   │       │       │   └── riscv v0.6.0
│   │   │       │       │       ├── bare-metal feature "default" (*)
│   │   │       │       │       └── bit_field feature "default"
│   │   │       │       │           └── bit_field v0.10.1
│   │   │       │       │       [build-dependencies]
│   │   │       │       │       └── riscv-target feature "default"
│   │   │       │       │           └── riscv-target v0.1.2
│   │   │       │       │               ├── lazy_static feature "default"
│   │   │       │       │               │   └── lazy_static v1.4.0
│   │   │       │       │               └── regex feature "default"
│   │   │       │       │                   ├── regex v1.5.4
│   │   │       │       │                   │   ├── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── aho-corasick feature "default"
│   │   │       │       │                   │   │   ├── aho-corasick v0.7.18
│   │   │       │       │                   │   │   │   └── memchr v2.4.1
│   │   │       │       │                   │   │   └── aho-corasick feature "std"
│   │   │       │       │                   │   │       ├── aho-corasick v0.7.18 (*)
│   │   │       │       │                   │   │       └── memchr feature "std"
│   │   │       │       │                   │   │           └── memchr v2.4.1
│   │   │       │       │                   │   └── memchr feature "default"
│   │   │       │       │                   │       ├── memchr v2.4.1
│   │   │       │       │                   │       └── memchr feature "std" (*)
│   │   │       │       │                   ├── regex feature "perf"
│   │   │       │       │                   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   ├── regex feature "perf-cache"
│   │   │       │       │                   │   │   └── regex v1.5.4 (*)
│   │   │       │       │                   │   ├── regex feature "perf-dfa"
│   │   │       │       │                   │   │   └── regex v1.5.4 (*)
│   │   │       │       │                   │   ├── regex feature "perf-inline"
│   │   │       │       │                   │   │   └── regex v1.5.4 (*)
│   │   │       │       │                   │   └── regex feature "perf-literal"
│   │   │       │       │                   │       ├── regex v1.5.4 (*)
│   │   │       │       │                   │       ├── regex feature "aho-corasick"
│   │   │       │       │                   │       │   └── regex v1.5.4 (*)
│   │   │       │       │                   │       └── regex feature "memchr"
│   │   │       │       │                   │           └── regex v1.5.4 (*)
│   │   │       │       │                   ├── regex feature "std"
│   │   │       │       │                   │   └── regex v1.5.4 (*)
│   │   │       │       │                   ├── regex feature "unicode"
│   │   │       │       │                   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   ├── regex feature "unicode-age"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-age"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-bool"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-bool"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-case"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-case"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-gencat"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-gencat"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-perl"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-perl"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-script"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-script"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   ├── regex feature "unicode-segment"
│   │   │       │       │                   │   │   ├── regex v1.5.4 (*)
│   │   │       │       │                   │   │   └── regex-syntax feature "unicode-segment"
│   │   │       │       │                   │   │       └── regex-syntax v0.6.25
│   │   │       │       │                   │   └── regex-syntax feature "unicode"
│   │   │       │       │                   │       ├── regex-syntax v0.6.25
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-age" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-bool" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-case" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-gencat" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-perl" (*)
│   │   │       │       │                   │       ├── regex-syntax feature "unicode-script" (*)
│   │   │       │       │                   │       └── regex-syntax feature "unicode-segment" (*)
│   │   │       │       │                   └── regex-syntax feature "default"
│   │   │       │       │                       ├── regex-syntax v0.6.25
│   │   │       │       │                       └── regex-syntax feature "unicode" (*)
│   │   │       │       └── vcell feature "default"
│   │   │       │           └── vcell v0.1.3
│   │   │       ├── e310x feature "rt"
│   │   │       │   └── e310x v0.9.0 (*)
│   │   │       └── riscv feature "default" (*)
│   │   └── riscv feature "default" (*)
│   └── e310x-hal feature "g002"
│       ├── e310x-hal v0.9.3 (*)
│       └── e310x feature "g002"
│           └── e310x v0.9.0 (*)
├── hifive1 feature "default"
│   └── hifive1 v0.10.0 (*)
├── lazy_static feature "default"
│   └── lazy_static v1.4.0
├── linked_list_allocator feature "default"
│   ├── linked_list_allocator v0.9.1
│   │   └── spinning_top feature "default"
│   │       └── spinning_top v0.2.4
│   │           └── lock_api feature "default"
│   │               └── lock_api v0.4.5
│   │                   └── scopeguard v1.1.0
│   └── linked_list_allocator feature "use_spin_nightly"
│       ├── linked_list_allocator v0.9.1 (*)
│       ├── linked_list_allocator feature "const_mut_refs"
│       │   └── linked_list_allocator v0.9.1 (*)
│       ├── linked_list_allocator feature "spinning_top"
│       │   └── linked_list_allocator v0.9.1 (*)
│       ├── linked_list_allocator feature "use_spin"
│       │   ├── linked_list_allocator v0.9.1 (*)
│       │   └── linked_list_allocator feature "spinning_top" (*)
│       └── spinning_top feature "nightly"
│           ├── spinning_top v0.2.4 (*)
│           └── lock_api feature "nightly"
│               └── lock_api v0.4.5 (*)
├── spinning_top feature "default" (*)
├── lock_api feature "default" (*)
├── panic-halt feature "default"
│   └── panic-halt v0.2.0
├── rand feature "small_rng"
│   └── rand v0.8.4
│       └── rand_core feature "default"
│           └── rand_core v0.6.3
├── riscv feature "default"
│   └── riscv v0.7.0
│       ├── bit_field feature "default" (*)
│       └── bare-metal feature "default"
│           └── bare-metal v1.0.0
│       [build-dependencies]
│       └── riscv-target feature "default" (*)
├── riscv-rt feature "default"
│   └── riscv-rt v0.8.0
│       ├── riscv feature "default" (*)
│       ├── r0 feature "default"
│       │   └── r0 v1.0.0
│       └── riscv-rt-macros feature "default"
│           └── riscv-rt-macros v0.1.6 (proc-macro)
│               ├── rand v0.5.6
│               │   └── rand_core v0.3.1
│               │       └── rand_core feature "default"
│               │           └── rand_core v0.4.2
│               ├── proc-macro2 feature "default"
│               │   ├── proc-macro2 v0.4.30
│               │   │   └── unicode-xid feature "default"
│               │   │       └── unicode-xid v0.1.0
│               │   └── proc-macro2 feature "proc-macro"
│               │       └── proc-macro2 v0.4.30 (*)
│               ├── quote feature "default"
│               │   ├── quote v0.6.13
│               │   │   └── proc-macro2 v0.4.30 (*)
│               │   └── quote feature "proc-macro"
│               │       ├── quote v0.6.13 (*)
│               │       └── proc-macro2 feature "proc-macro" (*)
│               ├── syn feature "default"
│               │   ├── syn v0.15.44
│               │   │   ├── proc-macro2 v0.4.30 (*)
│               │   │   ├── quote v0.6.13 (*)
│               │   │   └── unicode-xid feature "default" (*)
│               │   ├── syn feature "clone-impls"
│               │   │   └── syn v0.15.44 (*)
│               │   ├── syn feature "derive"
│               │   │   └── syn v0.15.44 (*)
│               │   ├── syn feature "parsing"
│               │   │   └── syn v0.15.44 (*)
│               │   ├── syn feature "printing"
│               │   │   ├── syn v0.15.44 (*)
│               │   │   └── syn feature "quote"
│               │   │       └── syn v0.15.44 (*)
│               │   └── syn feature "proc-macro"
│               │       ├── syn v0.15.44 (*)
│               │       ├── proc-macro2 feature "proc-macro" (*)
│               │       ├── quote feature "proc-macro" (*)
│               │       └── syn feature "quote" (*)
│               ├── syn feature "extra-traits"
│               │   └── syn v0.15.44 (*)
│               └── syn feature "full"
│                   └── syn v0.15.44 (*)
│       [build-dependencies]
│       └── riscv-target feature "default" (*)
└── volatile feature "default"
    └── volatile v0.4.4

I'll attempt a minimal project next.

@dougli1sqrd
Copy link
Author

Here's an example project I just made
https://github.com/dougli1sqrd/hifive-nom-example

This has only the parts required for running the hifive revb board, as well as nom. With nom it does not build, and without it does.

If you're building yourself, just be sure to use nightly and add the riscv target:

  1. rustup override set nightly in directory
  2. rustup target add riscv32imac-unknown-none-elf

Let me know if this helps

@buhe
Copy link

buhe commented Nov 6, 2021

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

@buhe
Copy link

buhe commented Nov 6, 2021

@dougli1sqrd you also try it.

@dougli1sqrd
Copy link
Author

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.

@Geal
Copy link
Collaborator

Geal commented Nov 6, 2021

Awesome, nice to see there's a fix. But... But why? Why is it fixed by changing the edition?

@buhe
Copy link

buhe commented Nov 6, 2021

Maybe 2.3.x new memchr not compatible 2018 rust?

@dougli1sqrd
Copy link
Author

I believe that rust 2021 has a new feature resolver that behaves differently? I wonder if we are running into a case that the earlier resolver had a hard time with but fixed with edition 2021.

@dougli1sqrd
Copy link
Author

Just as an added mystery, I've copied all the dependencies in my original project into my dummy project, and the dummy project still builds which is great! However, trying the steps above - updating to edition 2021 - does not fix my original project build issues. What's so baffling is at this point the dummy project Cargo.toml is identical to the original project, and I even copied all the code. So in one instance it builds and in another it does not.

I don't think this is a nom issue, but there's certainly some mysterious build magic happening.

@kaidokert
Copy link

Ran into exact same issue, even when just trying to use memchr directly, not nom. memchr=1.x worked fine, 2.x complained. Again, setting edition=2021 mysteriously works around it.

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

4 participants