memchr icon indicating copy to clipboard operation
memchr copied to clipboard

Duplicate lang items with 2/more crates depended on this in Cargo.toml and -Zbuild-std

Open js2xxx opened this issue 3 years ago • 5 comments

To reproduce the error,

  1. Create a lib crate
  2. Add 2 or more crates depended on memchr to the Cargo.toml. For me, it would be nom = "7.0" and object = "0.26"
  3. Execute cargo build -Z build-std=core,compiler_builtins,alloc -Z build-std-features=compiler-builtins-mem --target x86_64-unknown-linux-gnu

And there'll go thousands of lines of output of cargo with duplicate lang items or so.

My rust version: nightly-x86_64-unknown-linux-gnu (default) rustc 1.56.0-nightly (b03ccace5 2021-08-24)

js2xxx avatar Aug 25 '21 13:08 js2xxx

Does this happen with memchr 2.4.0? I wonder if this is related to #89? cc @alexcrichton

BurntSushi avatar Aug 25 '21 14:08 BurntSushi

I believe the bug here is that the std feature of memchr is enabled but you're not building std as part of -Zbuild-std.

alexcrichton avatar Aug 25 '21 14:08 alexcrichton

Well, actually it doen't work either if marking the crate with #![no_std] and setting default-features = false of those dependent crates, which disables the std dependency.

js2xxx avatar Aug 25 '21 15:08 js2xxx

To be honest, I don't know. This doesn't really look like an issue with memchr to me. This crate doesn't define lang items. So I suspect your issue is elsewhere. Either way, I don't know what the next debugging steps are.

BurntSushi avatar Aug 25 '21 15:08 BurntSushi

Alright, I'll search for more info about build-std. Maybe there's something.

js2xxx avatar Aug 25 '21 15:08 js2xxx

Closing due to inactivity and a general suspicion that this isn't related to memchr specifically.

BurntSushi avatar Jul 11 '23 01:07 BurntSushi