Description
I tried to cross compile a hello world with WASI SDK as explained at https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/wasm32_wasi/index.html:
cargo init
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk_11.0_amd64_ubuntu20.04.deb
sudo dpkg -i wasi-sdk_11.0_amd64_ubuntu20.04.deb
rm wasi-sdk_11.0_amd64_ubuntu20.04.deb
export CC_wasm32_wasi=/opt/wasi-sdk/bin/clang
export CARGO_TARGET_WASM32_WASI_LINKER=/opt/wasi-sdk/bin/clang
cargo build --target wasm32-wasi
I expected to see this happen: the build succeeds with Rust v1.45.2 , so next versions should be compatible.
Instead, this happened when updating to Rust v1.46.0: https://github.com/TjeuKayim/wasi-link-fail/runs/1109104907
error: linking with `/opt/wasi-sdk/bin/clang` failed: exit code: 1
##[error] |
= note: wasm-ld: error: unknown argument: --eh-frame-hdr
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
And 1.48.0-nightly (2020-09-12) produces another error: https://github.com/TjeuKayim/wasi-link-fail/runs/1109104926
error: linking with `/opt/wasi-sdk/bin/clang` failed: exit code: 1
##[error] |
= note: wasm-ld: error: std-5fceb8daecdd3ed8.std.5ro3oaeh-cgu.0.rcgu.o: Bad relocation type:
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
A weird exception is my Manjaro Linux system with Rust 1.46.0, it only builds succesfully when I add RUSTFLAGS='-C link-args=-Wl,-v'
. I have no clue why, and couldn't reproduce this on Ubuntu.
See this repository for a minimal reproduction https://github.com/TjeuKayim/wasi-link-fail.