From 94877d6271f9fae1c6caa346aba440a58567ef18 Mon Sep 17 00:00:00 2001 From: vhavlena Date: Thu, 28 Nov 2024 20:33:40 +0100 Subject: [PATCH 1/3] shared_list: fix compilation error --- 3rdparty/simlib/include/mata/simlib/util/shared_list.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/simlib/include/mata/simlib/util/shared_list.hh b/3rdparty/simlib/include/mata/simlib/util/shared_list.hh index 420f28a5..9cb78b7d 100644 --- a/3rdparty/simlib/include/mata/simlib/util/shared_list.hh +++ b/3rdparty/simlib/include/mata/simlib/util/shared_list.hh @@ -108,7 +108,7 @@ public: } if (elem) - --elem->counter_; + --elem->refcount_; } template From 1904e03769e8ccd2e6a0f5143a6ebd3c7eb94d34 Mon Sep 17 00:00:00 2001 From: vhavlena Date: Thu, 28 Nov 2024 20:34:37 +0100 Subject: [PATCH 2/3] cmake: update cmake files for WASM build --- CMakeLists.txt | 5 +++++ src/CMakeLists.txt | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97063f71..991c1ef5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,11 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) option(MATA_WERROR "Warnings should be handled as errors" OFF) option(MATA_ENABLE_COVERAGE "Build with coverage compiler flags" OFF) +# For the case of WASM build we need to add -pthread option +if (EMSCRIPTEN) + add_compile_options(-pthread) +endif() + # Only do these if this is the main project, and not if it is included through add_subdirectory if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # Store compile commands into 'build/compile_commands.json', which are needed, beside others, for linters. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7cad7754..698a7239 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,6 +34,11 @@ set_target_properties(libmata PROPERTIES target_include_directories(libmata PUBLIC "${PROJECT_SOURCE_DIR}/include/") +# For the case of WASM build we need to link with pthread +if (EMSCRIPTEN) + target_link_libraries(libmata PRIVATE pthread) +endif() + target_link_libraries(libmata PUBLIC cudd simlib) target_link_libraries(libmata PRIVATE re2) From 190224c1d656de274ab5e8ac34d7f7c244e60050 Mon Sep 17 00:00:00 2001 From: vhavlena Date: Fri, 29 Nov 2024 09:16:06 +0100 Subject: [PATCH 3/3] readme for building to WASM --- README-WASM.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 README-WASM.md diff --git a/README-WASM.md b/README-WASM.md new file mode 100644 index 00000000..c6affeb0 --- /dev/null +++ b/README-WASM.md @@ -0,0 +1,9 @@ +## Building Mata to WASM + +In order to build Mata library to WASM, you need to have `emscripten` set up, along with all of its dependencies. +You can use the system packages or consult [emsdk](https://github.com/emscripten-core/emsdk). +For building Mata to WASM then use the following steps: + +1. create folder `build-wasm` for the WASM build of libmata.a +2. in `build-wasm` run `emcmake cmake -DBUILD_TYPE=Release -DMATA_BUILD_EXAMPLES:BOOL=OFF -DBUILD_TESTING:BOOL=OFF ..` +3. build the library using `emmake make` (the WASM static library `src/libmata.a` should be created after that) \ No newline at end of file