Hello, I'm not too familiar with the Rust/WASM eco-system so this might be a silly issue, but I've been trying to get the very first example in the book to build without success. I've built a provisioned a VM using Vagrant and am trying to run cargo build whilst ssh'd in.
I'm running into the following error.
> cargo build --target wasm32-unknown-unknown --verbose
Fresh unicode-xid v0.1.0
Fresh cfg-if v0.1.6
Fresh lazy_static v1.2.0
Fresh log v0.4.6
Fresh proc-macro2 v0.4.24
Fresh wasm-bindgen-shared v0.2.29
Fresh quote v0.6.10
Fresh syn v0.15.23
Fresh wasm-bindgen-backend v0.2.29
Fresh wasm-bindgen-macro-support v0.2.29
Fresh wasm-bindgen-macro v0.2.29
Fresh wasm-bindgen v0.2.29
Compiling colormap v0.1.0 (/vagrant)
Running `rustc --edition=2018 --crate-name colormap src/lib.rs --color always --crate-type cdylib --emit=dep-info,link -C debuginfo=2 -C metadata=bae851322f19a06d --out-dir /vagrant/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/vagrant/target/wasm32-unknown-unknown/debug/incremental -L dependency=/vagrant/target/wasm32-unknown-unknown/debug/deps -L dependency=/vagrant/target/debug/deps --extern wasm_bindgen=/vagrant/target/wasm32-unknown-unknown/debug/deps/libwasm_bindgen-d5c375595d526f5c.rlib`
error: linking with `rust-lld` failed: exit code: 1
|
= note: "rust-lld" "-flavor" "wasm" "-L" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.13k17v8e4f88k07q.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.1twf20wipw2o6j71.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.2n8voq6eg5z6bzup.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.3376557lo0jlb5mp.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.38n8iiz97gf9a188.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.3cf4t33aecxzfs23.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.3etm3y4ssqlp8g5y.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.40ucp5fciql9bq9n.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.415wgnu86mi2osyg.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.4f8qpmbp53wh81ti.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.4k5s3cx7dchgogqh.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.51911haxf6ddp48r.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.5fe375dgmcb296pq.rcgu.o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.biecf0khta96lea.rcgu.o" "-o" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.wasm" "--export" "greet" "--export" "__wbindgen_describe___wbg_alert_784255b767c74791" "--export" "__wbindgen_describe_greet" "--export" "__wbindgen_free" "--export" "__wbindgen_global_argument_ptr" "--export" "__wbindgen_malloc" "/vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.1g8qapulbl4a9k0r.rcgu.o" "--gc-sections" "-O0" "-L" "/vagrant/target/wasm32-unknown-unknown/debug/deps" "-L" "/vagrant/target/debug/deps" "-L" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib" "/vagrant/target/wasm32-unknown-unknown/debug/deps/libwasm_bindgen-d5c375595d526f5c.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-abe145ba76171775.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libpanic_abort-96005f604f7dbd6e.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libdlmalloc-ed3f28cdc088f8c3.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libbacktrace_sys-5bc11286719e2ece.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libunwind-d068423794124d61.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/librustc_demangle-f04c7eda49d54f2c.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/liblibc-86eba1c052850cdc.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/liballoc-54d5eed3884d8bd6.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_core-f298ce55474b8b8e.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcore-58a74e26059c2878.rlib" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-04d6453cdba92f37.rlib" "--no-threads" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--no-entry" "--export-table" "--fatal-warnings" "--export-dynamic" "--no-demangle"
= note: rust-lld: error: failed to open /vagrant/target/wasm32-unknown-unknown/debug/deps/colormap.wasm: Invalid argument
error: aborting due to previous error
error: Could not compile `colormap`.
Caused by:
process didn't exit successfully: `rustc --edition=2018 --crate-name colormap src/lib.rs --color always --crate-type cdylib --emit=dep-info,link -C debuginfo=2 -C metadata=bae851322f19a06d --out-dir /vagrant/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/vagrant/target/wasm32-unknown-unknown/debug/incremental -L dependency=/vagrant/target/wasm32-unknown-unknown/debug/deps -L dependency=/vagrant/target/debug/deps --extern wasm_bindgen=/vagrant/target/wasm32-unknown-unknown/debug/deps/libwasm_bindgen-d5c375595d526f5c.rlib` (exit code: 1)
The VM is running Ubuntu 18.04 (64-bit). For more details I've pushed the latest changes to my repo.
Any help would be much appreciated! :bowing_man:
Just a note that running the equivalent in a Docker container seems to work fine. I wanted to avoid using Docker as a single container for my development environment will be a bit of a hack/bloated if I were to include all the dependencies (node, etc). :thinking:
Could be a C-compile-tools issue. Try sudo apt update and sudo apt install build-essential
I'm already doing so when I provision the VM. If you see
https://gitlab.com/rycwo/colormap/blob/master/Vagrantfile#L59 and line 69
in the same file.
On Sun, 30 Dec 2018, 15:18 David-OConnor <[email protected] wrote:
Could be a C-compile-tools issue. Try sudo apt update and sudo apt
install build-essential.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/rustwasm/wasm-bindgen/issues/1136#issuecomment-450560236,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEmueZEZDTDaMHPPlSAXPg0YicEgrZRdks5u-L0RgaJpZM4ZktuR
.
Are you able to test on your native OS?
With my current setup it's not super easy to, but I've got the first example working via a Docker container I've built. I guess the issue here is more about getting it working in a Vagrant-provisioned VM?
Thanks for the report! Unfortunately there's probably not a whole lot we can do about this. The error is:
= note: rust-lld: error: failed to open /vagrant/target/.../colormap.wasm: Invalid argument
Seeing what's happened in the past, what's probably going on here is that there's a shared filesystem with the VM and LLD is executing some syscall which isn't implemented on the shared filesystem. The bug here is probably with upstream LLD itself to perhaps be a bit more conservative with what filesystem operations it executes (e.g. falling back to slower implementations possibly).
Actually tracking this down and reporting it though may be hard!
Interesting, does this mean that there's a chance using a different Vagrant
box (i.e. Debian instead of Ubuntu) could work? Or is this something
inherently problematic with using Virtualbox/Vagrant? I guess Docker isn't
exactly the same type of virtualization so perhaps would explain why it
works. Happy to help investigate if given some direction!
My guess from seeing issues like this historically is that this is a bug in vagrant's drivers, not the image itself. One thing that could help is running strace over the rust-lld command that failed (although running rust-lld may be a bit tricky).
With strace we could narrow down what the exact syscall is (hopefully) and maybe point to a fix.
Thanks for the tip. I've uploaded a working Vagrantfile and some dummy commands I ran in order to hit the error here: https://gitlab.com/snippets/1798231.
I'm not too familiar with reading strace output so I've attached it as a file here for others to make sense of strace_output.txt. Not sure if I did it correctly though, just ran strace rustc <...> where <...> are the rest of the args to rustc. Hope it helps!
Oh right sorry, can you pass the -f flag to strace to follow children? Currently that's missing the syscalls for lld itself
Yup! Here's the new output: strace_output.txt. Anything glaring in there? :thinking:
Ok definitely looks like a filesystem bug I think:
...
[pid 3523] openat(AT_FDCWD, "add.big.wasm.tmp40654c7", O_RDWR|O_CREAT|O_EXCL, 0777) = 3
...
[pid 3523] mmap(NULL, 1365434, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = -1 EINVAL (Invalid argument)
I believe that's opening a file, writing a bit to it, and then mmaping it into the address space to write it out. Presumably the vagrant filesystem doesn't allow mmaping files...
I'll try to dig around later into LLD and see if we can report an upstream bug
Ok I've filed an upstream LLD bug for this. In the meantime I'm gonna close this in favor of that, thanks for the report though!