amethyst / shred

Shared resource dispatcher
Apache License 2.0
234 stars 66 forks source link

wasm32 support #168

Closed TatriX closed 2 years ago

TatriX commented 4 years ago

Latest stable version doesn't compile to wasm32: shred = { version = "0.9.3", default-features = false }

  |
7 |         dispatcher::{SystemId, ThreadLocal, ThreadPoolWrapper},
  |                                             ^^^^^^^^^^^^^^^^^ no `ThreadPoolWrapper` in `dispatch::dispatcher`
jrb0001 commented 4 years ago

Building without the parallel feature seems to be broken in general: #163.

TatriX commented 4 years ago

I made the same changes by hand on my local copy of shred and it helped.

remram44 commented 4 years ago

I'm also running into issues using emscripten:

Unsupported:   %10 = mul nuw nsw i128 %9, 6364136223846793005
LLVM ERROR: Binary operator type not yet supported for integer types larger than 64 bits

This comes from shred functions, though I can't tell if this is from inlined code from another crate.

asm ``` ; Function Attrs: uwtable define internal void @_ZN5shred5world5World5fetch17hb8432d2f614fd87fE(%"shred::world::Fetch>"* noalias nocapture sret dereferenceable(12), %"shred::world::World"* noalias nocapture readonly align 8 dereferenceable(32)) unnamed_addr #0 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality { %3 = alloca %"core::fmt::Arguments", align 4 %4 = alloca %"core::option::Option>", align 4 %5 = bitcast %"core::option::Option>"* %4 to i8* call void @llvm.lifetime.start.p0i8(i64 12, i8* nonnull %5) %6 = getelementptr inbounds %"shred::world::World", %"shred::world::World"* %1, i32 0, i32 0, i32 0 %7 = load i64, i64* %6, align 8, !alias.scope !889, !noalias !894 %8 = xor i64 %7, 7429700665903085545 %9 = zext i64 %8 to i128 %10 = mul nuw nsw i128 %9, 6364136223846793005 ; ERROR HERE %11 = trunc i128 %10 to i64 %12 = lshr i128 %10, 64 %13 = trunc i128 %12 to i64 %14 = add i64 %13, %11 %15 = zext i64 %14 to i128 %16 = mul nuw nsw i128 %15, 6364136223846793005 %17 = trunc i128 %16 to i64 %18 = lshr i128 %16, 64 %19 = trunc i128 %18 to i64 %20 = add i64 %19, %17 %21 = getelementptr inbounds %"shred::world::World", %"shred::world::World"* %1, i32 0, i32 1, i32 3 %22 = bitcast %"hashbrown::raw::RawTable<((u32, char), graphics::glyph_cache::rusttype::Data)>"* %21 to i32* %23 = load i32, i32* %22, align 8, !alias.scope !899, !noalias !904 %24 = trunc i64 %20 to i32 %25 = and i32 %23, %24 %26 = getelementptr %"shred::world::World", %"shred::world::World"* %1, i32 0, i32 1, i32 3, i32 5 %27 = load i8*, i8** %26, align 4, !alias.scope !907, !noalias !908 %28 = lshr i64 %20, 25 %29 = trunc i64 %28 to i32 %30 = and i32 %29, 127 %31 = shl nuw nsw i32 %30, 8 %32 = or i32 %31, %30 %33 = shl nuw nsw i32 %32, 16 %34 = or i32 %33, %32 %35 = getelementptr %"shred::world::World", %"shred::world::World"* %1, i32 0, i32 1, i32 3, i32 7 %36 = bitcast i64** %35 to { [0 x i64], { i64, i64 }, [0 x i32], %"shred::cell::TrustCell>", [1 x i32] }** %37 = load { [0 x i64], { i64, i64 }, [0 x i32], %"shred::cell::TrustCell>", [1 x i32] }*, { [0 x i64], { i64, i64 }, [0 x i32], %"shred::cell::TrustCell>", [1 x i32] }** %36, align 8, !alias.scope !907, !noalias !908 br label %38 ```

[edit: Works with specs 0.14.3 and shred 0.7.2, but fails with specs 0.15.0 and shred 0.9.3]

torkleyy commented 2 years ago

I think wasm was implemented, could be wrong. If so, feel free to reopen or create a new issue.