Repository: rust
Issue: linking error when compiling for wasm-unknown-unknown 
Labels: T-compiler,O-wasm


linking error when compiling for `wasm-unknown-unknown`  target (wasmer, not browser/js), whenever i include a mod/file that is using Hashmap or some other library linking fails. Probably related to multivalue?

`rustc 1.61.0-nightly (68369a041 2022-02-22)`
[rust_err_example.zip](https://github.com/rust-lang/rust/files/8191827/rust_err_example.zip)


minimal reproducible program 

```rust

/*
// .cargo/config

[build]
target = "wasm32-unknown-unknown"
rustflags = ["-C", "target-feature=+multivalue"]

*/

use std::{collections::HashMap};


#[no_mangle]
pub extern "C" fn hello_wasm() {
    let mut h = HashMap::new();
    h.insert("aaa", "bbbb");
}

extern "C" {
    fn _eg_host_fn(dataptr: *const u8, datalen: usize);
}



```

The current output is:

```
❯ RUST_BACKTRACE=1 cargo build
   Compiling rust_err_example v0.1.0 (/home/madman/zhome/code/project1/project1/code/sdk/rust_err_example)
error: linking with `rust-lld` failed: exit status: 1
  |
  = note: "rust-lld" "-flavor" "wasm" "--rsp-quoting=posix" "--export" "hello_wasm" "--export=__heap_base" "--export=__data_end" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--fatal-warnings" "--no-demangle" "--no-entry" "--export-dynamic" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.11iwiw9r0s5mzjb7.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.1258ztn9pt5knfvs.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.12xhe7leq0aju6fd.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.188i91463q8e9p84.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.1h0ysnt5937kmbzk.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.1nlz73acqyac20pl.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.1o38r4jvicv5u4p3.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.1o40oc3xw3pw1jjz.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.1yz127u1anjmc6m.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.233m9qjz05hce2rg.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.23bw55ocu8niaw11.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.24f2ki5wkma8dv5c.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.27v0g9hmzq1z91ei.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.289rd83e4ctsbkwf.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.2ctonn8v2m51gczi.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.2hvia29cdkwujjdq.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.2lcy2aajvfmjs2sd.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.2md2e4m3cb9crd0p.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.2rn6s3uoi53kzzet.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.2rpk3k7cwb2uj22t.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.2ursypg8rt1ogssm.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.2v0u5ndce2ic5iqp.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.30b2xblpnthpz8bh.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3cj95sxwxz854oln.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3cora075ycv7iqzq.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3d64wbyhsfmgqocf.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3gffdm44o345r9rw.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3ggpxa8xd4oolnh3.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3hd0somw0vpiectf.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3n5kna9tzigs0n0w.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3o5062kejcxwx2tk.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3rq4k7i4ust2vhb0.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.48kdz4t1twhak8f7.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.4cvrgxhhfnkdrhli.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.4gzneq5bphgbffd7.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.4ia3e7uubejtgl2r.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.4kth0yjzxkifma06.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.4qshhnty03lrm7n0.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.4t3icbkw15xe0ze4.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.4valv0k3l3b09fxl.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.4vb0osqimq4533q0.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.4wa36n7a72ay8zjk.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.54dqbdhad8e0i5v3.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.54gs9cii5q2nxfna.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.566dk5mgmrgcaur1.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.5a1bfzacojdeylyn.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.5q4z5jmgtaqrwkm.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.650nzpbq2sfvruu.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.gffu2pc0i2wzusr.rcgu.o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.66tx2mizddcosfb.rcgu.o" "-L" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps" "-L" "/home/madman/zhome/code/project1/project1/target/debug/deps" "-L" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-d9a8e4ca4a56d589.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libpanic_abort-da549f624a11fc3f.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libdlmalloc-32eef8ba9e79754a.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/librustc_demangle-a4b3f55336174ba0.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd_detect-a6de6d9a3d929e91.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libhashbrown-e1fe72c54436e3c8.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libminiz_oxide-25ac77357ee76304.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libadler-da31b97afd77e5cd.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_alloc-e4890f293e1fb8b8.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libunwind-401a7652bd4b8049.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcfg_if-7cf7d086fa3880b1.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/liblibc-bc607ebb983da335.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/liballoc-e7063ff5ba60248a.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_core-10bf4b0039d4de0f.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcore-3365b6c50e94718e.rlib" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-0a74812a9f34fee4.rlib" "-L" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib" "-L" "/home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/self-contained" "-o" "/home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.wasm" "--gc-sections" "--no-entry" "-O0"
  = note: rust-lld: error: function signature mismatch: _ZN9hashbrown3raw11Fallibility9alloc_err17h87bbeac836209cefE
          >>> defined as (i32, i32, i32) -> i32 in /home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.233m9qjz05hce2rg.rcgu.o
          >>> defined as (i32, i32, i32, i32) -> void in /home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libhashbrown-e1fe72c54436e3c8.rlib(hashbrown-e1fe72c54436e3c8.hashbrown.578d61c0-cgu.0.rcgu.o)
          
          rust-lld: error: function signature mismatch: _ZN9hashbrown3raw11Fallibility17capacity_overflow17h758747893b4c22b1E
          >>> defined as (i32) -> i32 in /home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.233m9qjz05hce2rg.rcgu.o
          >>> defined as (i32, i32) -> void in /home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libhashbrown-e1fe72c54436e3c8.rlib(hashbrown-e1fe72c54436e3c8.hashbrown.578d61c0-cgu.0.rcgu.o)
          
          rust-lld: error: function signature mismatch: _ZN3std3sys4wasm6common19hashmap_random_keys17h19d54f33dc288cf5E
          >>> defined as () -> i64 in /home/madman/zhome/code/project1/project1/target/wasm32-unknown-unknown/debug/deps/rust_err_example.3cj95sxwxz854oln.rcgu.o
          >>> defined as (i32) -> void in /home/madman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-d9a8e4ca4a56d589.rlib(std-d9a8e4ca4a56d589.std.9d65eda6-cgu.0.rcgu.o)
          

error: could not compile `rust_err_example` due to previous error

```
```
rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/madman/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu
nightly-2021-04-15-x86_64-unknown-linux-gnu
nightly-2021-07-28-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)

installed targets for active toolchain
--------------------------------------

wasm32-unknown-unknown
x86_64-unknown-linux-gnu

active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.61.0-nightly (68369a041 2022-02-22)

```