From 6ac9ba6caefea738df513fd788074831b1b184fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 7 Jul 2023 15:08:26 +0200 Subject: [PATCH] Add Meson cross-file for WebAssembly with Emscripten --- scripts/wasm.ini | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 scripts/wasm.ini diff --git a/scripts/wasm.ini b/scripts/wasm.ini new file mode 100644 index 00000000..d1d6c52a --- /dev/null +++ b/scripts/wasm.ini @@ -0,0 +1,44 @@ +# Meson cross file for creating a WebAssembly version of the preprocessor. +# +# Requires emscripten to be installed. +# Was successfully tested with emscripten 3.1.69 installed through emsdk +# tool, as described on: https://emscripten.org/docs/getting_started/downloads.html +# Don’t forget to source script snippet in current shell before running meson. +# +# Compilation creates a .wasm and .js wrapper under <builddir>/src/ +# +# Can be run locally with node.js using: +# node dynare-preprocessor.js file.mod +# NB: a version of node.js is shipped with emscripten (under the node/ +# subdirectory), but another version should also work. + +[binaries] +cpp = 'em++' + +[host_machine] +system = 'emscripten' +# Could be changed to wasm64 if 4GB memory constraint is hit +# Some background: https://v8.dev/blog/4gb-wasm-memory +cpu_family = 'wasm32' +cpu = 'wasm32' +endian = 'little' + +[built-in options] +# Never do a debug build, because otherwise the lack of optimisations can +# overflow the memory capacities. +buildtype = 'release' +# The -fexceptions flag (for both compilation and linking) is needed for an +# unknown reason (C++ compilers are supposed to always add exception support). +# The -Wno-unqualified-std-cast-call flag removes many warnings about “move†+# not being qualified with “std::†namespace. +# The -fexperimental-library flag is needed to get std::jthread support (it was +# supposed to no longer be necessary for LLVM 20, but for some reason we still +# need it). +cpp_args = [ '-fexceptions', '-Wno-unqualified-std-cast-call', '-fexperimental-library' ] +# NODERAWFS=1 is needed for accessing the local filesystem +cpp_link_args = [ '-s', 'NODERAWFS=1', '-fexceptions' ] + +[properties] +# It’s necessary to use a different copy of Boost than the one under +# /usr/include, because otherwise GCC headers confuse Clang +boost_root = '/tmp/boost_1_86_0' -- GitLab