diff --git a/src/preamble_minimal.js b/src/preamble_minimal.js index 42805b09e35dc..c266903e66cdf 100644 --- a/src/preamble_minimal.js +++ b/src/preamble_minimal.js @@ -93,10 +93,6 @@ else { if (!ENVIRONMENT_IS_PTHREAD) { #endif -#if ASSERTIONS && SHARED_MEMORY -assert(wasmMemory.buffer instanceof SharedArrayBuffer, 'requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag'); -#endif - updateMemoryViews(); #if PTHREADS diff --git a/src/runtime_init_memory.js b/src/runtime_init_memory.js index b6b050e467a08..3d53d72f200de 100644 --- a/src/runtime_init_memory.js +++ b/src/runtime_init_memory.js @@ -45,15 +45,6 @@ if (!ENVIRONMENT_IS_PTHREAD) { 'index': 'i64', #endif }); -#if SHARED_MEMORY - if (!(wasmMemory.buffer instanceof SharedArrayBuffer)) { - err('requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag'); - if (ENVIRONMENT_IS_NODE) { - err('(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)'); - } - throw Error('bad memory'); - } -#endif } updateMemoryViews(); diff --git a/test/test_other.py b/test/test_other.py index 923a49d1a98ee..5e96b205f9562 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12071,6 +12071,18 @@ def test_pthread_hello(self, args): def test_pthread_relocatable(self): self.do_run_in_out_file_test('hello_world.c', emcc_args=['-sRELOCATABLE']) + @node_pthreads + def test_pthread_unavailable(self): + # Run a simple hello world program that uses pthreads + self.emcc_args += ['-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'] + self.do_run_in_out_file_test('hello_world.c') + + # Now run the same program but with SharedArrayBuffer undefined, it should run + # fine and then fail on the first call to pthread_create. + create_file('pre.js', 'SharedArrayBuffer = undefined\n') + expected = 'pthread_create: environment does not support SharedArrayBuffer, pthreads are not available' + self.do_runf('hello_world.c', expected, assert_returncode=NON_ZERO, emcc_args=['--pre-js=pre.js']) + def test_stdin_preprocess(self): create_file('temp.h', '#include ') outputStdin = self.run_process([EMCC, '-x', 'c++', '-dM', '-E', '-'], input="#include ", stdout=PIPE).stdout