servo / servo/rust-harfbuzz

WebAssembly support

Open
#153 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
90
Forks
68
PR merge metrics
No merged PRs in 30d

Description

I'm partially able to get a hacked up local build with WebAssembly locally as something that I'd been playing with, but I saw that @pcwalton is also working on this ... so I'll share what I know here:

I was doing:

PATH=~/Development/emscripten:$PATH HARFBUZZ_SYS_NO_PKG_CONFIG=1 cargo test --target wasm32-unknown-emscripten --features=build-native-harfbuzz --no-run

The build.rs needs to have it use the cmake code path, so I had just done this for now:

-    if target.contains("windows") {
+    if target.contains("windows") || target.contains("emscripten") {

Then, I had modified the bundled harfbuzz-sys/harfbuzz/CMakeLists.txt to skip the APPLE section so that it doesn't try to build CoreText support or link against ApplicationServices.

The section here is:

if (APPLE AND HB_HAVE_CORETEXT)

Once I did that, I can get a working build and run the tests manually:

node ../target/wasm32-unknown-emscripten/debug/deps/harfbuzz_sys-d3b521c3c3fe5aaa.js

running 15 tests
test bindgen_test_layout__hb_var_int_t ... ok
test bindgen_test_layout_hb_aat_layout_feature_selector_info_t ... ok
test bindgen_test_layout_hb_feature_t ... ok
test bindgen_test_layout_hb_font_extents_t ... ok
test bindgen_test_layout_hb_glyph_extents_t ... ok
test bindgen_test_layout_hb_glyph_info_t ... ok
test bindgen_test_layout_hb_glyph_position_t ... ok
test bindgen_test_layout_hb_ot_color_layer_t ... ok
test bindgen_test_layout_hb_ot_math_glyph_part_t ... ok
test bindgen_test_layout_hb_ot_math_glyph_variant_t ... ok
exception thrown: ReferenceError: _setThrew is not defined,ReferenceError: _setThrew is not defined
    at invoke_viiii (/Users/bruce/Development/endoli/rust-harfbuzz/target/wasm32-unknown-emscripten/debug/deps/harfbuzz_sys-d3b521c3c3fe5aaa.js:5806:5)
    at __ZN3std9panicking18continue_panic_fmt17h8da0cc447534547bE (wasm-function[696]:232)
    at __ZN3std9panicking15begin_panic_fmt17h1e4b0c823bda4a29E (wasm-function[695]:173)
    at __ZN12harfbuzz_sys38bindgen_test_layout_hb_ot_name_entry_t17h33662a45aab25317E (wasm-function[108]:1037)
    at __ZN12harfbuzz_sys38bindgen_test_layout_hb_ot_name_entry_t28__u7b__u7b_closure_u7d__u7d_17h3396e4a55b0eff6cE (wasm-function[130]:30)
    at dynCall_vi (wasm-function[1181]:14)
    at Module.dynCall_vi (/Users/bruce/Development/endoli/rust-harfbuzz/target/wasm32-unknown-emscripten/debug/deps/harfbuzz_sys-d3b521c3c3fe5aaa.js:6131:38)
    at invoke_vi (/Users/bruce/Development/endoli/rust-harfbuzz/target/wasm32-unknown-emscripten/debug/deps/harfbuzz_sys-d3b521c3c3fe5aaa.js:5758:5)
    at __ZN4core3ops8function6FnOnce9call_once17hbdf62de6b20e5c0eE (wasm-function[165]:46)
    at __ZN4test28__rust_begin_short_backtrace17h5ca4862777d64d58E (wasm-function[342]:17)

This looks like I need to tell emcc to have -s DISABLE_EXCEPTION_CATCHING=0 ... but I hadn't done that yet.

Contributor guide

No contributing guide indexed for this repository

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 build.rs and harfbuzz-sys/harfbuzz/CMakeLists.txt, then reproduce the cargo test --target wasm32-unknown-emscripten command using Emscripten. Check the generated JavaScript test with node, including the _setThrew failure; done means the WebAssembly build and tests run without the reported platform and exception-handling issues.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.