Skip to content

WebAssembly support #153

@waywardmonkeys

Description

@waywardmonkeys

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions