From cdacef2165f8731c0650c51f84bc70e1c5fe464e Mon Sep 17 00:00:00 2001 From: Birch-san Date: Sun, 8 Dec 2024 16:52:34 +0000 Subject: [PATCH 1/3] chmod +x build_emscripten.sh --- build_emscripten.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build_emscripten.sh diff --git a/build_emscripten.sh b/build_emscripten.sh old mode 100644 new mode 100755 From 4663ff3828922de49a6ead42557919855f5c42d4 Mon Sep 17 00:00:00 2001 From: Birch-san Date: Sun, 8 Dec 2024 16:54:21 +0000 Subject: [PATCH 2/3] define start_sec, start_usec on b2Timer when __EMSCRIPTEN__ is defined. because timer.c expects to be able to assign to these properties. --- include/box2d/base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/box2d/base.h b/include/box2d/base.h index ac4c0970e..d431028ca 100644 --- a/include/box2d/base.h +++ b/include/box2d/base.h @@ -115,7 +115,7 @@ typedef struct b2Timer { #if defined( _WIN32 ) int64_t start; -#elif defined( __linux__ ) || defined( __APPLE__ ) +#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __EMSCRIPTEN__ ) unsigned long long start_sec; unsigned long long start_usec; #else From 3a6ecf60400775a030125ea99d238ad25b314fc8 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Thu, 21 Nov 2024 20:25:44 -0600 Subject: [PATCH 3/3] Add pthread support for Emscripten build. --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7f31e52f..62637e96f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,15 @@ if (MSVC OR APPLE) endif() endif() +#emscripten pthread support +if(EMSCRIPTEN) + set(EMSCRIPTEN_PTHREADS_COMPILER_FLAGS "-pthread -s USE_PTHREADS=1") + set(EMSCRIPTEN_PTHREADS_LINKER_FLAGS "${EMSCRIPTEN_PTHREADS_COMPILER_FLAGS} -s PROXY_TO_PTHREAD") + string(APPEND CMAKE_C_FLAGS " ${EMSCRIPTEN_PTHREADS_COMPILER_FLAGS}") + string(APPEND CMAKE_CXX_FLAGS " ${EMSCRIPTEN_PTHREADS_COMPILER_FLAGS}") + string(APPEND CMAKE_EXE_LINKER_FLAGS " ${EMSCRIPTEN_PTHREADS_LINKER_FLAGS}") +endif() + # Deterministic math # https://box2d.org/posts/2024/08/determinism/ if (MINGW OR APPLE OR UNIX)