Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/preamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions src/runtime_init_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>')
outputStdin = self.run_process([EMCC, '-x', 'c++', '-dM', '-E', '-'], input="#include <string>", stdout=PIPE).stdout
Expand Down
Loading