orxfun / orx-split-vec

An efficient constant access time vector with dynamic capacity and pinned elements.
https://crates.io/crates/orx-split-vec
MIT License
2 stars 2 forks source link

WASM support #46

Closed MichaReiser closed 1 month ago

MichaReiser commented 2 months ago

We have a transitive dependency on this project through Salsa and orx-concurrent-vec.

I'm now trying to build a WASM playground for our project but noticed that this crate fails to build on WASM:

error[E0080]: evaluation of constant value failed
    --> /home/micha/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:1245:5
     |
1245 | /     uint_impl! {
1246 | |         Self = usize,
1247 | |         ActualT = u32,
1248 | |         SignedT = isize,
...    |
1262 | |         bound_condition = " on 32-bit targets",
1263 | |     }
     | |_____^ attempt to compute `65536_usize * 65536_usize`, which would overflow
     |
note: inside `core::num::<impl usize>::pow`
    --> /home/micha/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:1245:5
     |
1245 | /     uint_impl! {
1246 | |         Self = usize,
1247 | |         ActualT = u32,
1248 | |         SignedT = isize,
...    |
1262 | |         bound_condition = " on 32-bit targets",
1263 | |     }
     | |_____^
note: inside `cumulative_capacity`
    --> /home/micha/.cargo/registry/src/index.crates.io-6f17d22bba15001f/orx-split-vec-3.2.0/src/growth/doubling/constants.rs:8:5
     |
8    |     usize::pow(2, (fragment_idx + FIRST_FRAGMENT_CAPACITY_POW + 1) as u32) - FIRST_FRAGMENT_CAPACITY
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `doubling::constants::CUMULATIVE_CAPACITIES`
    --> /home/micha/.cargo/registry/src/index.crates.io-6f17d22bba15001f/orx-split-vec-3.2.0/src/growth/doubling/constants.rs:42:5
     |
42   |     cumulative_capacity(29),
     |     ^^^^^^^^^^^^^^^^^^^^^^^
     = note: this error originates in the macro `uint_impl` (in Nightly builds, run with -Z macro-backtrace for more info)

Would it be possible to add WASM support for this crate? If not, then I'll try to work around the limitation on the Salsa level.

Thanks

MichaReiser commented 2 months ago

This error might not be WASM-specific but applies to 32-bit architectures as well. Trying to build the library for i686-pc-windows-gnu fails with the same error.

MichaReiser commented 2 months ago

Oh, there's already a PR for it. I'm sorry https://github.com/orxfun/orx-split-vec/pull/45

orxfun commented 1 month ago

An attempted fix is merged on PR https://github.com/orxfun/orx-split-vec/pull/50 . Please check and let me know if the problem persists.

MichaReiser commented 1 month ago

Looks good. Thank you so much!