WebAssembly / WebAssembly/wabt

More docs for building/using libwabt?

Open
#1,267 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
8.1k
Forks
827
Avg merge
4d 6h
Merged PRs (30d)
18

Description

I wasn't able to find much documentation about libwabt.js, but I was able to piece this together from various sources. Corrections/elaborations are invited.

Usage

Call either parseWat(filename:string, watSource:string, features: object) or readWasm(buffer: Uint8Array, {readDebugNames:true}).

The features object can contain any of the following boolean keys: mutable_globals, exceptions, multi_value, sign_extension, sat_float_to_int, simd, threads, tail_call, bulk_memory, reference_types.

The calls to parseWat and readWasm will return an object wasm that supports the following methods:

  • wasm.destroy()
  • wasm.resolveNames()
  • wasm.validate(features)
  • wasm.toBinary({log: boolean, write_debug_names: boolean}): { log: string, buffer: Uint8Array}
  • wasm.generateNames()
  • wasm.applyNames()
  • wasm.toText({foldExprs: boolean, inlineExport: boolean}): string
Updating/Building

The file demo/libwabt.js in the wabt git repository is periodically updated. It's not clear how to do this manually oneself, to incorporate recent changes to the repo. Issue #536 says that this can be done by running make emscripten-release, which uses a target from the repo's top-level Makefile.

However, I just now tried going into my emsdk folder, updating it following the instructions here (including the source ./emsdk_env.sh command), then cd-ing into my wabt repo and trying make emscripten-release. This fails with:

mkdir -p out/emscripten/Release/
cd out/emscripten/Release/ && cmake -G "Unix Makefiles" /Users/jim/Documents/CLOUD/dev/wasm/wabt/ -DCMAKE_TOOLCHAIN_FILE=/Users/jim/Documents/CLOUD/dev/wasm/emsdk/upstream/emscripten//cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release 
CMake Error at /Users/jim/_dev/wasm/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake:100 (message):
  Failed to fetch compiler version information with command
  "'/Users/jim/_dev/wasm/emsdk/upstream/emscripten/emcc' -v"! Process
  returned with error code 1.
Call Stack (most recent call first):
  /opt/local/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:93 (include)
  CMakeLists.txt:18 (project)


CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
make: *** [out/emscripten/Release/Makefile] Error 1

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.

Research direction

Start with demo/libwabt.js, the top-level Makefile, and the emscripten-release target referenced from issue #536. Verify the documented parseWat/readWasm API and investigate the reported emsdk/CMake failure. Done means the usage details and reproducible steps for updating or building libwabt.js are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, javascript
Domain
build-system, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.