pganalyze/pg-query-emscripten

WASM build

EliSnow opened this issue · 6 comments

With WASM now supported in Firefox and Chrome it would be good to see a WASM build. I spent a few hours trying to get it work, but had no luck when using the trzeci/emscripten:sdk-tag-1.37.3-64bit docker image.

Good idea, I'd love to get a working WebAssembly build. Was there any particular error you ran into with your testing?

It's possible I was doing something wrong, but I added -s WASM=1 to the end of line 40 of the Makefile and I was getting a non-descriptive python file not found error while attempting to build. Without that added the normal asm.js would build fine.

Here's the exact error I'm seeing:

Traceback (most recent call last):
  File "/usr/local/bin/em++", line 16, in <module>
    emcc.run()
  File "/emsdk_portable/emscripten/tag-1.37.3/emcc.py", line 2146, in run
    subprocess.check_call(cmd)
  File "/usr/lib/python2.7/subprocess.py", line 535, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
Makefile:39: recipe for target 'update_source' failed

I was able to resolve the error I was seeing by adding a line to my ~/.emscripten file, and got the WASM code to build!

One question which remains is how is it best to distribute the WASM build alongside the asm.js? There are ways to build WASM so it will fall back to asm.js but that has it's downsides.

@EliSnow Thats a good question - I don't have any preference there, so if you have a suggestion happy to take that.

I guess we could just have a pg_query_wasm.js build output along the current one (which requires WebAssembly, i.e. no asm.js compatibility layer), and then its left to the user to implement some kind of browser feature selection?