Closed chaozju closed 1 year ago
Hm, I can't seem to reproduce. What version of nightly are you using?
@ehuss Hi, My toolchain info is
chao@DESKTOP-B79IRTG:~/rust-playground/hello$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/chao/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu
1.40.0-x86_64-unknown-linux-gnu
installed targets for active toolchain
--------------------------------------
riscv64gc-unknown-linux-gnu
riscv64gc-unknown-none-elf
wasm32-wasi
x86_64-unknown-linux-gnu
x86_64-unknown-linux-musl
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.42.0 (b8cedc004 2020-03-09)
That doesn't show the nightly version you are using. rustc +nightly -V
shows which nightly version you have.
@ehuss
OOPS
chao@DESKTOP-B79IRTG:~/rust-playground/hello$ rustc +nightly -V
rustc 1.44.0-nightly (f509b26a7 2020-03-18)
2020-03-18
This is quite old. Can you try with the latest nightly? rustup update nightly
can be used to update.
@ehuss same error after updating nightly
Which exact version did you use?
@ehuss rustc 1.46.0-nightly (feb3536eb 2020-06-09)
I'm getting the same error with 1.46.0-nightly (0c03aee8b 2020-07-05)
and panic="abort" in Cargo.toml. Changing panic to "unwind" removes the error.
@chaozju, did you use panic="abort"?
panic="abort" also works when using -Z build-std=panic_abort,std
, as suggested by @alexcrichton in #29.
@dbdr It works, THX
Hi, I got the same error with rustc 1.51.0-nightly (04caa632d 2021-01-30)
and adding a dependencie:
Cargo.toml:
[package]
name = "rust_issue"
version = "0.1.0"
authors = ["gmorer"]
edition = "2018"
[lib]
crate-type = ["lib"]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[dependencies]
wasm-bindgen = "0.2"
src/lib.rs:
#![no_std]
extern crate alloc;
use alloc::boxed::Box;
pub fn my_fn() -> i32 {
let mem = Box::new(4);
*mem
}
compile line:
cargo build --target=wasm32-unknown-unknown -Z build-std=alloc,panic_abort
Got the following error:
$> cargo build --target=wasm32-unknown-unknown -Z build-std=alloc,panic_abort
Compiling core v0.0.0 (/home/me/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
[...]
Compiling panic_abort v0.0.0 (/home/me/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/panic_abort)
Compiling rust_issue v0.1.0 (/home/me/gits/rust_issue)
error: duplicate lang item in crate `core` (which `alloc` depends on): `bool`.
|
= note: the lang item is first defined in crate `core` (which `rust_issue` depends on)
= note: first definition in `core` loaded from /home/me/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcore-73412d1456c20040.rlib
= note: second definition in `core` loaded from /home/me/gits/rust_issue/target/wasm32-unknown-unknown/debug/deps/libcore-d3db196937483bcf.rmeta
error: duplicate lang item in crate `core` (which `alloc` depends on): `char`.
|
= note: the lang item is first defined in crate `core` (which `rust_issue` depends on)
= note: first definition in `core` loaded from /home/me/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcore-73412d1456c20040.rlib
= note: second definition in `core` loaded from /home/me/gits/rust_issue/target/wasm32-unknown-unknown/debug/deps/libcore-d3db196937483bcf.rmeta
error: duplicate lang item in crate `core` (which `alloc` depends on): `str`.
|
= note: the lang item is first defined in crate `core` (which `rust_issue` depends on)
= note: first definition in `core` loaded from /home/me/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcore-73412d1456c20040.rlib
= note: second definition in `core` loaded from /home/me/gits/rust_issue/target/wasm32-unknown-unknown/debug/deps/libcore-d3db196937483bcf.rmeta
@gmorer you have to ensure your dependencies do not use std
if you are not building std
. wasm-bindgen
has a default std
feature, so it has to be turned off:
wasm-bindgen = {version="0.2", default-features=false}
However, it looks like wasm-bindgen is broken in no_std environments. This line assumes mem::
is available, but it is gated here.
I'm going to close as it isn't clear that there is an issue here. Better panic support is tracked in #29, and it looks like the wasm_bindgen issue was an issue with an external package.
I am testing with hello world case for
build-std
featuremy code
then got
and