WASM updates (Reply 1)

@jan - Not sure there is much to do on my end; the CI/CD in place on GitHub - SWI-Prolog/npm-swipl-wasm: SWI-Prolog WebAssembly build as a NPM package should take care of preparing a new npm release whenever you release your new version of SWI-Prolog.

For building or running on node this needs a fairly recent version of Node.js. v18.16 works.

Is this necessary? Currently; we test for Node 16+ in the npm distribution; and I’d prefer to still support Node 16 until it’s EOL in April 2024 (c.f. Node v16.13.0 (LTS) | Node.js)

You get most automatically. I had a quick look at the Dockerfile of the repo. Compared to Building SWI-Prolog using Emscripten for WebAssembly (WASM), this is lacking behind a bit. As we discussed, I’d include pcre2 and remove GMP. That gives an images that is only marginally larger, has more functionality and is completely covered by permissive licenses (BSD-2, MIT, a little Apache and some non-standard permissive licenses). Only (notably) rational number arithmetic is slower.

I don’t know what version, but after updating to 3.1.37 on dev.swi-prolog.org the build failed because node.js complained about invalid opcodes. That is node.js from Ubuntu 20.04. Forgotten which version. 10? After upgrading to the latest stable, all worked fine again.

1 Like

@jan - I’m trying to reproduce your all test passed results; some questions:

  • Do you have a docker image with all this working; if not
    • What commit of swi-prolog did you test this with?
    • What was your .emscripten config?

Currently each attempt I am making at running ctest [-j 16] results in a failure on the swipl:basic test.

No. Local machine. Ubuntu 22.04, Emscripten 3.1.37, Node.js 18.16. Current head of swipl-devel.git.
I use this configure run:

source $WASM_HOME/emsdk/emsdk_env.sh
[ -f $TOOLCHAIN ] || echo "Could not find emscripten toolchain"

          -DCMAKE_BUILD_TYPE=Release \
	  -G Ninja .. $@

pcre and zlib installed as Building SWI-Prolog using Emscripten for WebAssembly (WASM)

After build, simply ran ctest -j 16 (16 core desktop). Reproduced on two machines, the dev.swi-prolog.org server and my local development machine.

On older versions I had crashes due to C-stack overflows (fixed by passing the right link flags) and IEEE float tests failing. Apparently fixed in Emscripten and/or Node.

1 Like

Got it working now (c.f. Feat/ctest passing by jeswr · Pull Request #143 · SWI-Prolog/npm-swipl-wasm · GitHub). So will have all of this goodness in swipl-wasm once the next release of SWIPL is made.