wasm2js does not support 64-bit memories

Open
#4,518 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
cpp, wasm
Domain
compilers

Research direction

Reproduce the failure with the shown clang --target=wasm64 command and wasm2js on add.wasm. Start by tracing the i64-to-i32-lowering pass and its validation output; done means the wasm64 input translates without load/store pointer type validation errors.

Written by the indexing model from the issue text.

Description

For C++ source code,

extern "C" int add (int first, int second)
{
  return first + second;
}

Compiling with clang-15 with wasm64 target,

clang --target=wasm64 --no-standard-libraries -Wl,--export-all -Wl,--no-entry -o add.wasm add.cc

And translate to js using wasm2js,

wasm2js add.wasm

However it fails with

[PassRunner]   running pass: i64-to-i32-lowering...               0.0005889 seconds.                                                                                                                             [PassRunner]   (validating)                                                                                                                                                                                      [PassRunner] running nested passes                                                                                                                                                                               [PassRunner]   running pass: ... 0.0002939 seconds.                                                                                                                                                              [PassRunner] nested passes took 0.0002939 seconds.
[wasm-validator error in function add] i32 != i64: store pointer must match memory index type, on
(i32.store offset=12
 (block (result i32)
  (local.set $40
   (local.get $20)
  )
  (local.get $19)
 )
 (local.get $21)
)
[wasm-validator error in function add] i32 != i64: store pointer must match memory index type, on
(i32.store offset=8
 (block (result i32)
  (local.set $37
   (local.get $23)
  )
  (local.get $22)
 )                                                                                                                                                                                                                (local.get $24)                                                                                                                                                                                                 )
[wasm-validator error in function add] i32 != i64: load pointer type must match memory index type, on
(i32.load offset=12
 (block (result i32)
  (local.set $35
   (local.get $26)
  )
  (local.get $25)
 )
)
[wasm-validator error in function add] i32 != i64: load pointer type must match memory index type, on
(i32.load offset=8
 (block (result i32)
  (local.set $38
   (local.get $29)
  )
  (local.get $28)
 )
)
Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
2d 1h
Merged PRs (30d)
70

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WebAssembly/binaryen

All issues in WebAssembly/binaryen

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.