wasmerio / wasmer

🚀 The leading Wasm Runtime supporting WASIX, WASI and Emscripten
https://wasmer.io
MIT License
18.28k stars 775 forks source link

Compiler error: attempt to shift left by `32_i32`, which would overflow #4048

Open arvid-norlander opened 1 year ago

arvid-norlander commented 1 year ago

Describe the bug

I'm attempting to cross-compile wasmer-cli to 32-bit x86 (the long term goal is to embed it in 32-bit x86 and ARM programs running on industrial controllers using the C API). To begin with I tried the following command after checking out the v4.0.0 tag:

$ cargo build --target i686-unknown-linux-gnu --features cranelift --all-targets
warning: invalid feature `sys` in required-features of target `errors`: `sys` is not present in [features] section
   Compiling proc-macro2 v1.0.60
   Compiling unicode-ident v1.0.9
   Compiling quote v1.0.28
[... everything going normally ...]
   Compiling wasmer-vm v4.0.0 (/home/tmgarn/workspace/wasmer/lib/vm)
error: this arithmetic operation will overflow
  --> lib/vm/src/threadconditions.rs:72:36
   |
72 |         if self.inner.map.len() >= 1 << 32 {
   |                                    ^^^^^^^ attempt to shift left by `32_i32`, which would overflow
   |
   = note: `#[deny(arithmetic_overflow)]` on by default

   Compiling wasmer-compiler v4.0.0 (/home/tmgarn/workspace/wasmer/lib/compiler)
error: could not compile `wasmer-vm` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...

It appears that wasmer is broken on 32-bit systems?

$ wasmer -vV; rustc -vV
zsh: command not found: wasmer
rustc -vV       
rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2

Unsurprisingly it can't find wasmer since I can't build it (duh).


Note that if I execute the command inside the checkout of wasmer I get the following instead due to the rust-toolchain file. However, in that case, I get different errors much earlier in the process (and I will not be building with such an old rust later on). Apparently I cannot build once_cell with that version.

$ rustc -vV
rustc 1.67.1 (d5a82bbd2 2023-02-07)
binary: rustc
commit-hash: d5a82bbd26e1ad8b7401f6a718a9c57c96905483
commit-date: 2023-02-07
host: x86_64-unknown-linux-gnu
release: 1.67.1
LLVM version: 15.0.6

Steps to reproduce

  1. Attempt to build a version of wasmer for i686-unknown-linux-gnu.
  2. Get compiler error

Expected behavior

A successful build.

Actual behavior

Compiler error, as shown above.

Additional context

It doesn't matter if I set up a GCC/linker sysroot for cross compiling or not in this case (I tried both with and without), it doesn't even get that far. Eventually I will need it of course.

ptitSeb commented 1 year ago

We'd love to support that, but don't have the bandwidth internally. If you provide a pull request with the fix, we'll gladly merge it.

stale[bot] commented 3 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.