-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Description
I'm building on Arch Linux (x86_64) and I've built rust 1.49.0 with the following config.toml:
[build]
target = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]
extended = true
docs = false
sanitizers = false
profiler = true
vendor = true
[rust]
channel = "stable"
rpath = false
[install]
prefix = "/usr"
[target.x86_64-unknown-linux-gnu]
llvm-config = "/usr/bin/llvm-config"
[target.wasm32-unknown-unknown]
llvm-config = "/usr/bin/llvm-config"
wasi-root = "/usr/lib/wasi"
profiler = false
I've actually tried building it twice. Once with the above and once without the llvm-config
lines, both give me the same problem.
I'm using the latest wasm-pack, 0.9.1.
When I cd into https://github.com/rustwasm/wasm-bindgen/tree/master/examples/without-a-bundler
and run wasm-pack build --target web
:
$ wasm-pack build --target web
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling proc-macro2 v1.0.24
Compiling unicode-xid v0.2.1
Compiling wasm-bindgen-shared v0.2.69 (wasm-bindgen-0.2.69/crates/shared)
Compiling log v0.4.11
Compiling syn v1.0.57
Compiling cfg-if v0.1.10
Compiling lazy_static v1.4.0
Compiling bumpalo v3.4.0
Compiling wasm-bindgen v0.2.69 (wasm-bindgen-0.2.69)
Compiling cfg-if v1.0.0
Compiling quote v1.0.8
Compiling wasm-bindgen-backend v0.2.69 (wasm-bindgen-0.2.69/crates/backend)
Compiling wasm-bindgen-macro-support v0.2.69 (wasm-bindgen-0.2.69/crates/macro-support)
Compiling wasm-bindgen-macro v0.2.69 (wasm-bindgen-0.2.69/crates/macro)
Compiling js-sys v0.3.46 (wasm-bindgen-0.2.69/crates/js-sys)
Compiling web-sys v0.3.46 (wasm-bindgen-0.2.69/crates/web-sys)
Compiling without-a-bundler v0.1.0 (wasm-bindgen-0.2.69/examples/without-a-bundler)
error: linker `rust-lld` not found
|
= note: No such file or directory (os error 2)
error: aborting due to previous error
error: could not compile `without-a-bundler`
To learn more, run the command again with --verbose.
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
Some person here thinks this is a problem with the rust compiler: drager/wasm-pack#754 (comment)
It seems like that's true, because this thread explains what the gentoo packagers did to their rust package work around this problem:
https://bugs.gentoo.org/715348
(tldr: sed -i '/linker:/ s/rust-lld/wasm-ld/' src/librustc_target/spec/wasm32_base.rs
)
The only place I can find a file called rust-lld is rustc-1.49.0-src/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld
after I build, but that just seems like a build artifact that never gets installed anywhere. Am I missing something special that I have to do to get rust-lld deployed/installed properly? Have I done something wrong in my config.toml file or otherwise?
Note that
RUSTFLAGS="-C linker=lld" wasm-pack build --target web
works for me but
RUSTFLAGS="-C linker=wasm-ld" wasm-pack build --target web
fails with some error about something needing to be build with -fPIC
and a warning that "creating shared libraries, with -shared, is not yet stable"
Needing to override RUSTFLAGS to fix a (broken?) default linker doesn't feel like an actual solution.