Skip to content

Commit 6aa0f9a

Browse files
Enable threads under node when running cmake checks (#15590)
1 parent eac0b82 commit 6aa0f9a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

emcmake.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ def has_substr(args, substr):
3535

3636
if not has_substr(args, '-DCMAKE_CROSSCOMPILING_EMULATOR'):
3737
node_js = config.NODE_JS[0]
38-
args.append(f'-DCMAKE_CROSSCOMPILING_EMULATOR={node_js}')
38+
# In order to allow cmake to run code built with pthreads we need to pass some extra flags to node.
39+
# Note that we also need --experimental-wasm-bulk-memory which is true by default and hence not added here
40+
# See https://github.com/emscripten-core/emscripten/issues/15522
41+
args.append(f'-DCMAKE_CROSSCOMPILING_EMULATOR={node_js};--experimental-wasm-threads')
3942

4043
# On Windows specify MinGW Makefiles or ninja if we have them and no other
4144
# toolchain was specified, to keep CMake from pulling in a native Visual

tests/test_other.py

+4
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,10 @@ def test_cmake_static_lib(self, custom):
721721
else:
722722
self.assertTrue(building.is_ar('libstatic_lib.a'))
723723

724+
# Tests that cmake functions which require evaluation via the node runtime run properly with pthreads
725+
def test_cmake_pthreads(self):
726+
self.run_process([EMCMAKE, 'cmake', '-DCMAKE_C_FLAGS=-pthread', test_file('cmake/target_js')])
727+
724728
# Tests that the CMake variable EMSCRIPTEN_VERSION is properly provided to user CMake scripts
725729
def test_cmake_emscripten_version(self):
726730
self.run_process([EMCMAKE, 'cmake', test_file('cmake/emscripten_version')])

0 commit comments

Comments
 (0)