Fix WASM build issues, improve test coverage and improve cmake files

* Ensure compiler.usethread=0 is set before compilation in single-threaded WASM builds
* Explicitly enable exceptions for the single-threaded WASM module
* Test the single-threaded module in addition to the multi-threaded module in internal and external CI
* Consolidate wasm/tests/CMakeLists.txt into wasm/CMakeLists.txt, fixing the single-threaded benchmark test build which was missing shared linker flags

PiperOrigin-RevId: 901149728
Change-Id: If4946e29e5116610782d218906cf3f5940c1cdd0
This commit is contained in:
Matija Kecman
2026-04-17 01:28:40 -07:00
committed by Copybara-Service
parent f91ce9a627
commit c23b5e8420
5 changed files with 78 additions and 87 deletions
+6 -3
View File
@@ -212,25 +212,28 @@ build_test_wasm() {
echo "Building and testing WASM bindings..."
source emsdk/emsdk_env.sh
export PATH="$(pwd)/node_modules/.bin:$PATH"
echo "Building Multi-Threaded version..."
echo "Build MuJoCo with Emscripten (Multi-Threaded)..."
emcmake cmake -B build_wasm_mt \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF \
-DMUJOCO_WASM_THREADS=ON \
$WASM_CMAKE_ARGS
cmake --build build_wasm_mt --parallel $(nproc)
echo "Run bindings tests for Multi-Threaded version..."
npm run test --prefix ./wasm
echo "Moving Multi-Thread version under mt subfolder..."
mkdir -p wasm/dist/mt
mv wasm/dist/mujoco.* wasm/dist/mt/
echo "Building Single-Threaded version..."
echo "Build MuJoCo with Emscripten (Single-Threaded)..."
emcmake cmake -B build_wasm_st \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF \
-DMUJOCO_WASM_THREADS=OFF \
$WASM_CMAKE_ARGS
cmake --build build_wasm_st --parallel $(nproc)
echo "Run bindings tests for Single-Threaded version..."
npm run test --prefix ./wasm
}