From 916b0ea800f1599d06140688f948021f91053d30 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 7 Mar 2023 16:54:07 -0800 Subject: [PATCH] Switch from `-sUSE_PTHREAD` to the standard `-pthread`. NFC (#18917) We already supported this flag, but this change mostly updates all or tests and documentation to refer exclusively to that latter. --- docs/emcc.txt | 2 +- emcc.py | 4 +- site/source/docs/api_reference/fetch.rst | 8 +- .../docs/compiling/Building-Projects.rst | 2 +- site/source/docs/porting/networking.rst | 2 +- site/source/docs/porting/simd.rst | 2 +- site/source/docs/tools_reference/emcc.rst | 2 +- .../minimal_runtime_worker_externs.js | 2 +- src/library_pthread.js | 4 +- system/include/emscripten/em_asm.h | 2 +- system/include/emscripten/threading.h | 2 +- system/lib/wasmfs/fuzzer/Makefile | 2 +- test/canvas_animate_resize.cpp | 2 +- test/common.py | 3 +- test/pthread/call_sync_on_main_thread.c | 2 +- test/test_browser.py | 276 +++++++++--------- test/test_core.py | 44 ++- test/test_interactive.py | 16 +- test/test_other.py | 65 +++-- test/test_posixtest.py | 2 +- test/test_sockets.py | 4 +- tools/ports/libpng.py | 2 +- tools/ports/sdl2.py | 2 +- tools/ports/sqlite3.py | 2 +- tools/system_libs.py | 4 +- 25 files changed, 225 insertions(+), 233 deletions(-) diff --git a/docs/emcc.txt b/docs/emcc.txt index 6a3b8a3b20f81..37b5347a4cba4 100644 --- a/docs/emcc.txt +++ b/docs/emcc.txt @@ -547,7 +547,7 @@ Options that are modified or new in *emcc* are listed below: "--threadprofiler" [link] Embeds a thread activity profiler onto the generated page. Use this to profile the application usage of pthreads when - targeting multithreaded builds (-sUSE_PTHREADS=1/2). + targeting multithreaded builds (-pthread). "--em-config " [general] Specifies the location of the **.emscripten** diff --git a/emcc.py b/emcc.py index 640e23085bd67..b869ae4bd6fb1 100755 --- a/emcc.py +++ b/emcc.py @@ -1678,7 +1678,7 @@ def setup_pthreads(target): elif settings.LINKABLE: diagnostics.warning('experimental', '-sLINKABLE + pthreads is experimental') if settings.ALLOW_MEMORY_GROWTH: - diagnostics.warning('pthreads-mem-growth', 'USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271') + diagnostics.warning('pthreads-mem-growth', '-pthread + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271') default_setting('DEFAULT_PTHREAD_STACK_SIZE', settings.STACK_SIZE) @@ -2405,7 +2405,7 @@ def phase_linker_setup(options, state, newargs): settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$runtimeKeepalivePush'] else: if settings.PROXY_TO_PTHREAD: - exit_with_error('-sPROXY_TO_PTHREAD requires -sUSE_PTHREADS to work!') + exit_with_error('-sPROXY_TO_PTHREAD requires -pthread work!') settings.JS_LIBRARIES.append((0, 'library_pthread_stub.js')) # TODO: Move this into the library JS file once it becomes possible. diff --git a/site/source/docs/api_reference/fetch.rst b/site/source/docs/api_reference/fetch.rst index 82792076d8e17..156c9a798e0f3 100644 --- a/site/source/docs/api_reference/fetch.rst +++ b/site/source/docs/api_reference/fetch.rst @@ -195,9 +195,9 @@ emscripten_fetch() returns. - **No flags**: Only asynchronous Fetch operations are available. - ``--proxy-to-worker``: Synchronous Fetch operations are allowed for fetches that only do an XHR but do not interact with IndexedDB. - - ``-sUSE_PTHREADS``: Synchronous Fetch operations are available on + - ``-pthread``: Synchronous Fetch operations are available on pthreads, but not on the main thread. - - ``--proxy-to-worker`` + ``-sUSE_PTHREADS``: Synchronous Fetch operations + - ``--proxy-to-worker`` + ``-pthread``: Synchronous Synchronous Fetch operations are available both on the main thread and pthreads. Waitable Fetches @@ -242,9 +242,9 @@ issuing thread can perform some other work until the fetch completes. Waitable fetches are available only in certain build modes: - **No flags** or ``--proxy-to-worker``: Waitable fetches are not available. - - ``-sUSE_PTHREADS``: Waitable fetches are available on pthreads, but not + - ``-pthread``: Waitable fetches are available on pthreads, but not on the main thread. - - ``--proxy-to-worker`` + ``-sUSE_PTHREADS``: Waitable fetches are + - ``--proxy-to-worker`` + ``-pthread``: Waitable fetches are available on all threads. Tracking Progress diff --git a/site/source/docs/compiling/Building-Projects.rst b/site/source/docs/compiling/Building-Projects.rst index 23e92a58d3924..77619501fdf17 100644 --- a/site/source/docs/compiling/Building-Projects.rst +++ b/site/source/docs/compiling/Building-Projects.rst @@ -349,7 +349,7 @@ Emscripten provides the following preprocessor macros that can be used to identi * Likewise, ``__clang_version__`` is present and indicates both Emscripten and LLVM version information. * Emscripten is a 32-bit platform, so ``size_t`` is a 32-bit unsigned integer, ``__POINTER_WIDTH__=32``, ``__SIZEOF_LONG__=4`` and ``__LONG_MAX__`` equals ``2147483647L``. * When targeting SSEx SIMD APIs using one of the command line compiler flags ``-msse``, ``-msse2``, ``-msse3``, ``-mssse3``, or ``-msse4.1``, one or more of the preprocessor flags ``__SSE__``, ``__SSE2__``, ``__SSE3__``, ``__SSSE3__``, ``__SSE4_1__`` will be present to indicate available support for these instruction sets. - * If targeting the pthreads multithreading support with the compiler & linker flag ``-sUSE_PTHREADS``, the preprocessor define ``__EMSCRIPTEN_PTHREADS__`` will be present. + * If targeting the pthreads multithreading support with the compiler & linker flag ``-pthread``, the preprocessor define ``__EMSCRIPTEN_PTHREADS__`` will be present. Using a compiler wrapper diff --git a/site/source/docs/porting/networking.rst b/site/source/docs/porting/networking.rst index 5c43857fb0513..2c81b59a61b79 100644 --- a/site/source/docs/porting/networking.rst +++ b/site/source/docs/porting/networking.rst @@ -73,7 +73,7 @@ The following POSIX sockets functions are currently not proxied (and will not wo - ``poll()``, ``close()`` (use ``shutdown()`` instead), ``select()`` To use POSIX sockets proxying, link the application with flags ``-lwebsocket.js --sPROXY_POSIX_SOCKETS -sUSE_PTHREADS -sPROXY_TO_PTHREAD``. That is, +-sPROXY_POSIX_SOCKETS -pthread -sPROXY_TO_PTHREAD``. That is, POSIX sockets proxying builds on top of the Emscripten WebSockets library, and requires multithreading and proxying the application ``main()`` to a pthread. diff --git a/site/source/docs/porting/simd.rst b/site/source/docs/porting/simd.rst index 02b6baaad1172..6144803c87c3a 100644 --- a/site/source/docs/porting/simd.rst +++ b/site/source/docs/porting/simd.rst @@ -31,7 +31,7 @@ When porting native SIMD code, it should be noted that because of portability co - Cache line prefetch instructions are not available, and calls to these functions will compile, but are treated as no-ops. - - Asymmetric memory fence operations are not available, but will be implemented as fully synchronous memory fences when SharedArrayBuffer is enabled (-sUSE_PTHREADS) or as no-ops when multithreading is not enabled (default, -sUSE_PTHREADS=0). + - Asymmetric memory fence operations are not available, but will be implemented as fully synchronous memory fences when SharedArrayBuffer is enabled (-pthread) or as no-ops when multithreading is not enabled (the default). SIMD-related bug reports are tracked in the `Emscripten bug tracker with the label SIMD `_. diff --git a/site/source/docs/tools_reference/emcc.rst b/site/source/docs/tools_reference/emcc.rst index 2774e12d7b9da..31d7b6bc988a9 100644 --- a/site/source/docs/tools_reference/emcc.rst +++ b/site/source/docs/tools_reference/emcc.rst @@ -494,7 +494,7 @@ Options that are modified or new in *emcc* are listed below: ``--threadprofiler`` [link] - Embeds a thread activity profiler onto the generated page. Use this to profile the application usage of pthreads when targeting multithreaded builds (-sUSE_PTHREADS=1/2). + Embeds a thread activity profiler onto the generated page. Use this to profile the application usage of pthreads when targeting multithreaded builds (-pthread). .. _emcc-config: diff --git a/src/closure-externs/minimal_runtime_worker_externs.js b/src/closure-externs/minimal_runtime_worker_externs.js index 78d326b2f32a8..bc733f3f661ad 100644 --- a/src/closure-externs/minimal_runtime_worker_externs.js +++ b/src/closure-externs/minimal_runtime_worker_externs.js @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -// These externs are needed for MINIMAL_RUNTIME + USE_PTHREADS +// These externs are needed for MINIMAL_RUNTIME + -pthread // This file should go away in the future when worker.js is refactored to live inside the JS module. /** @suppress {duplicate} */ diff --git a/src/library_pthread.js b/src/library_pthread.js index a941a3b5c8bf5..1e831a6c6df53 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -17,10 +17,10 @@ #error "USE_PTHREADS=2 is no longer supported" #endif #if BUILD_AS_WORKER -#error "USE_PTHREADS + BUILD_AS_WORKER require separate modes that don't work together, see https://github.com/emscripten-core/emscripten/issues/8854" +#error "pthreads + BUILD_AS_WORKER require separate modes that don't work together, see https://github.com/emscripten-core/emscripten/issues/8854" #endif #if PROXY_TO_WORKER -#error "--proxy-to-worker is not supported with -sUSE_PTHREADS>0! Use the option -sPROXY_TO_PTHREAD if you want to run the main thread of a multithreaded application in a web worker." +#error "--proxy-to-worker is not supported with -pthread! Use the option -sPROXY_TO_PTHREAD if you want to run the main thread of a multithreaded application in a web worker." #endif #if EVAL_CTORS #error "EVAL_CTORS is not compatible with pthreads yet (passive segments)" diff --git a/system/include/emscripten/em_asm.h b/system/include/emscripten/em_asm.h index b6cb997da3c8c..afae52dbe4a4d 100644 --- a/system/include/emscripten/em_asm.h +++ b/system/include/emscripten/em_asm.h @@ -235,7 +235,7 @@ const char __em_asm_sig_builder<__em_asm_type_tuple >::buffer[] = { __e #define EM_ASM_DOUBLE(code, ...) emscripten_asm_const_double(CODE_EXPR(#code) _EM_ASM_PREP_ARGS(__VA_ARGS__)) // Runs the given JavaScript code synchronously on the main browser thread, and returns no value back. -// Call this function for example to access DOM elements in a pthread when building with -sUSE_PTHREADS. +// Call this function for example to access DOM elements in a pthread when building with -pthread. // Avoid calling this function in performance sensitive code, because this will effectively sleep the // calling thread until the main browser thread is able to service the proxied function call. If you have // multiple MAIN_THREAD_EM_ASM() code blocks to call in succession, it will likely be much faster to diff --git a/system/include/emscripten/threading.h b/system/include/emscripten/threading.h index d336971a9f982..362cd561aa4c4 100644 --- a/system/include/emscripten/threading.h +++ b/system/include/emscripten/threading.h @@ -148,7 +148,7 @@ typedef struct em_queued_call em_queued_call; // pthread), the function // will be proxied to be called by the main thread. // - Calling emscripten_sync_* functions requires that the application was -// compiled with pthreads support enabled (-sUSE_PTHREADS=1/2) and that the +// compiled with pthreads support enabled (-pthread) and that the // browser supports SharedArrayBuffer specification. int emscripten_sync_run_in_main_runtime_thread_(EM_FUNC_SIGNATURE sig, void *func_ptr __attribute__((nonnull)), ...); diff --git a/system/lib/wasmfs/fuzzer/Makefile b/system/lib/wasmfs/fuzzer/Makefile index 62ae6e9c6d441..4ec49eb168ff6 100644 --- a/system/lib/wasmfs/fuzzer/Makefile +++ b/system/lib/wasmfs/fuzzer/Makefile @@ -2,7 +2,7 @@ EMCC = ../../../../emcc SOURCES = fuzzer.cpp random.cpp workload.cpp support/command-line.cpp # Build with WasmFS enabled and pthreads. -EMFLAGS = -sWASMFS -sPROXY_TO_PTHREAD -sUSE_PTHREADS -sALLOW_MEMORY_GROWTH -Werror -Wno-pthreads-mem-growth -I. --profiling-funcs +EMFLAGS = -sWASMFS -sPROXY_TO_PTHREAD -pthread sALLOW_MEMORY_GROWTH -Werror -Wno-pthreads-mem-growth -I. --profiling-funcs CFLAGS = -std=c++17 .PHONY: build diff --git a/test/canvas_animate_resize.cpp b/test/canvas_animate_resize.cpp index c50b8230c71f2..937a4678c9692 100644 --- a/test/canvas_animate_resize.cpp +++ b/test/canvas_animate_resize.cpp @@ -19,7 +19,7 @@ // - If set, manually update CSS pixel size of the canvas. If unset, leave the CSS size to auto and expect the browser to resize the canvas size. #if !defined(TEST_EMSCRIPTEN_SET_MAIN_LOOP) && !defined(__EMSCRIPTEN_PTHREADS__) -#error TEST_EMSCRIPTEN_SET_MAIN_LOOP=false, but blocking main loops require using -sPROXY_TO_PTHREADS= and multithreading (build with -sPROXY_TO_PTHREAD and -sUSE_PTHREADS) +#error TEST_EMSCRIPTEN_SET_MAIN_LOOP=false, but blocking main loops require using -sPROXY_TO_PTHREADS= and multithreading (build with -sPROXY_TO_PTHREAD and -pthread) #endif #if !defined(TEST_EMSCRIPTEN_SET_MAIN_LOOP) && !defined(TEST_EXPLICIT_CONTEXT_SWAP) diff --git a/test/common.py b/test/common.py index c10d78c66ae4c..a8bbec9492583 100644 --- a/test/common.py +++ b/test/common.py @@ -528,8 +528,7 @@ def require_wasm_eh(self): def setup_node_pthreads(self): self.require_node() - self.set_setting('USE_PTHREADS') - self.emcc_args += ['-Wno-pthreads-mem-growth'] + self.emcc_args += ['-Wno-pthreads-mem-growth', '-pthread'] if self.get_setting('MINIMAL_RUNTIME'): self.skipTest('node pthreads not yet supported with MINIMAL_RUNTIME') self.js_engines = [config.NODE_JS] diff --git a/test/pthread/call_sync_on_main_thread.c b/test/pthread/call_sync_on_main_thread.c index 1bc39610d1503..a779edb20e522 100644 --- a/test/pthread/call_sync_on_main_thread.c +++ b/test/pthread/call_sync_on_main_thread.c @@ -23,7 +23,7 @@ int main() char name[7] = "body"; const char *dst = getDomElementContents(name); memset(name, 0, sizeof(name)); // Try to uncover if there might be a race condition and above line was not synchronously processed, and we could take name string away. - int inWorker1 = isThisInWorker(); // Build this application with -sUSE_PTHREADS -sPROXY_TO_PTHREAD for this to return 1, otherwise returns 0. + int inWorker1 = isThisInWorker(); // Build this application with -pthread -sPROXY_TO_PTHREAD for this to return 1, otherwise returns 0. int inWorker2 = isThisInWorkerOnMainThread(); // This should always return 0 int returnedInt = receivesAndReturnsAnInteger(4); printf("text: \"%s\". inWorker1: %d, inWorker2: %d, returnedInt: %d\n", dst, inWorker1, inWorker2, returnedInt); diff --git a/test/test_browser.py b/test/test_browser.py index 3374c8d8a57a8..24bc919e7c8f0 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -1327,7 +1327,7 @@ def test_preinitialized_webgl_context(self): @parameterized({ '': ([],), - 'threads': (['-sUSE_PTHREADS'],), + 'threads': (['-pthread'],), 'closure': (['-sENVIRONMENT=web', '-O2', '--closure=1'],), }) @requires_threads @@ -1607,7 +1607,7 @@ def test_egl(self): @requires_threads @requires_graphics_hardware def test_egl_with_proxy_to_pthread(self): - self._test_egl_base('-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sOFFSCREEN_FRAMEBUFFER') + self._test_egl_base('-pthread', '-sPROXY_TO_PTHREAD', '-sOFFSCREEN_FRAMEBUFFER') def _test_egl_width_height_base(self, *args): self.btest_exit(test_file('test_egl_width_height.c'), args=['-O2', '-lEGL', '-lGL'] + list(args)) @@ -1617,7 +1617,7 @@ def test_egl_width_height(self): @requires_threads def test_egl_width_height_with_proxy_to_pthread(self): - self._test_egl_width_height_base('-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD') + self._test_egl_width_height_base('-pthread', '-sPROXY_TO_PTHREAD') @requires_graphics_hardware def test_egl_createcontext_error(self): @@ -1751,7 +1751,7 @@ def test_glgears(self, extra_args=[]): # noqa def test_glgears_pthreads(self, extra_args=[]): # noqa # test that a program that doesn't use pthreads still works with with pthreads enabled # (regression test for https://github.com/emscripten-core/emscripten/pull/8059#issuecomment-488105672) - self.test_glgears(['-sUSE_PTHREADS']) + self.test_glgears(['-pthread']) @requires_graphics_hardware @parameterized({ @@ -1892,7 +1892,7 @@ def test_emscripten_fs_api2(self): @parameterized({ '': ([],), - 'pthreads': (['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'],), + 'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'],), }) @requires_threads def test_emscripten_main_loop(self, args): @@ -1901,7 +1901,7 @@ def test_emscripten_main_loop(self, args): @parameterized({ '': ([],), # test pthreads + AUTO_JS_LIBRARIES mode as well - 'pthreads': (['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sAUTO_JS_LIBRARIES=0'],), + 'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD', '-sAUTO_JS_LIBRARIES=0'],), }) @requires_threads def test_emscripten_main_loop_settimeout(self, args): @@ -1909,7 +1909,7 @@ def test_emscripten_main_loop_settimeout(self, args): @parameterized({ '': ([],), - 'pthreads': (['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD'],), + 'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD'],), }) @requires_threads def test_emscripten_main_loop_and_blocker(self, args): @@ -1924,7 +1924,7 @@ def test_emscripten_main_loop_and_blocker_exit(self): @parameterized({ '': ([],), 'worker': (['--proxy-to-worker'],), - 'pthreads': (['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD'],) + 'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD'],) }) @requires_threads def test_emscripten_main_loop_setimmediate(self, args): @@ -1971,7 +1971,7 @@ def test_gl_glteximage(self): @parameterized({ '': ([],), - 'pthreads': (['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sOFFSCREEN_FRAMEBUFFER'],), + 'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD', '-sOFFSCREEN_FRAMEBUFFER'],), }) @requires_graphics_hardware @requires_threads @@ -2070,7 +2070,7 @@ def test_cubegeom_regal(self): @requires_threads @requires_graphics_hardware def test_cubegeom_regal_mt(self): - self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-pthread', '-DUSE_REGAL', '-sUSE_PTHREADS', '-sUSE_REGAL', '-lGL', '-lSDL'], also_proxied=False) + self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-pthread', '-DUSE_REGAL', '-pthread', '-sUSE_REGAL', '-lGL', '-lSDL'], also_proxied=False) @requires_graphics_hardware @parameterized({ @@ -2518,8 +2518,8 @@ def test_worker_api_sleep(self): def test_worker_api_with_pthread_compilation_fails(self): self.run_process([EMCC, '-c', '-o', 'hello.o', test_file('hello_world.c')]) - stderr = self.expect_fail([EMCC, 'hello.o', '-o', 'a.js', '-g', '--closure=1', '-sUSE_PTHREADS', '-sBUILD_AS_WORKER']) - self.assertContained("USE_PTHREADS + BUILD_AS_WORKER require separate modes that don't work together, see https://github.com/emscripten-core/emscripten/issues/8854", stderr) + stderr = self.expect_fail([EMCC, 'hello.o', '-o', 'a.js', '-g', '--closure=1', '-pthread', '-sBUILD_AS_WORKER']) + self.assertContained("pthreads + BUILD_AS_WORKER require separate modes that don't work together, see https://github.com/emscripten-core/emscripten/issues/8854", stderr) def test_emscripten_async_wget2(self): self.btest_exit('test_emscripten_async_wget2.cpp') @@ -2620,7 +2620,7 @@ def test_doublestart_bug(self): @parameterized({ '': ([],), 'closure': (['-O2', '-g1', '--closure=1', '-sHTML5_SUPPORT_DEFERRING_USER_SENSITIVE_REQUESTS=0'],), - 'pthread': (['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD'],), + 'pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],), 'legacy': (['-sMIN_FIREFOX_VERSION=0', '-sMIN_SAFARI_VERSION=0', '-sMIN_IE_VERSION=0', '-sMIN_EDGE_VERSION=0', '-sMIN_CHROME_VERSION=0', '-Wno-transpile'],) }) @requires_threads @@ -2641,7 +2641,7 @@ def test_html5_core(self, opts): @requires_threads def test_html5_gamepad(self): - for opts in [[], ['-O2', '-g1', '--closure=1'], ['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']]: + for opts in [[], ['-O2', '-g1', '--closure=1'], ['-pthread', '-sPROXY_TO_PTHREAD']]: print(opts) self.btest_exit(test_file('test_gamepad.c'), args=[] + opts) @@ -2655,7 +2655,7 @@ def test_html5_webgl_create_context_no_antialias(self): @requires_threads @requires_graphics_hardware def test_html5_webgl_create_context(self): - for opts in [[], ['-O2', '-g1', '--closure=1'], ['-sFULL_ES2'], ['-sUSE_PTHREADS']]: + for opts in [[], ['-O2', '-g1', '--closure=1'], ['-sFULL_ES2'], ['-pthread']]: print(opts) self.btest_exit(test_file('webgl_create_context.cpp'), args=opts + ['-lGL']) @@ -2715,7 +2715,7 @@ def test_webgl2_get_buffer_sub_data(self): def test_webgl2_pthreads(self): # test that a program can be compiled with pthreads and render WebGL2 properly on the main thread # (the testcase doesn't even use threads, but is compiled with thread support). - self.btest_exit(test_file('webgl2.cpp'), args=['-sMAX_WEBGL_VERSION=2', '-lGL', '-sUSE_PTHREADS']) + self.btest_exit(test_file('webgl2.cpp'), args=['-sMAX_WEBGL_VERSION=2', '-lGL', '-pthread']) @requires_graphics_hardware def test_webgl2_objects(self): @@ -2723,8 +2723,8 @@ def test_webgl2_objects(self): @requires_graphics_hardware def test_html5_webgl_api(self): - for mode in [['-sOFFSCREENCANVAS_SUPPORT', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD'], - ['-sOFFSCREEN_FRAMEBUFFER', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD'], + for mode in [['-sOFFSCREENCANVAS_SUPPORT', '-pthread', '-sPROXY_TO_PTHREAD'], + ['-sOFFSCREEN_FRAMEBUFFER', '-pthread', '-sPROXY_TO_PTHREAD'], []]: if 'OFFSCREENCANVAS_SUPPORT' in mode and os.getenv('EMTEST_LACKS_OFFSCREEN_CANVAS'): continue @@ -3101,7 +3101,7 @@ def test_sdl2_mouse_offsets(self): @requires_threads def test_sdl2_threads(self): - self.btest_exit('browser/test_sdl2_threads.c', args=['-sUSE_PTHREADS', '-sUSE_SDL=2', '-sPROXY_TO_PTHREAD']) + self.btest_exit('browser/test_sdl2_threads.c', args=['-pthread', '-sUSE_SDL=2', '-sPROXY_TO_PTHREAD']) @requires_graphics_hardware def test_sdl2_glshader(self): @@ -3329,7 +3329,7 @@ def test_asyncify_tricky_function_sig(self): @requires_threads def test_async_in_pthread(self): - self.btest_exit('browser/async.cpp', args=['-sASYNCIFY', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-g']) + self.btest_exit('browser/async.cpp', args=['-sASYNCIFY', '-pthread', '-sPROXY_TO_PTHREAD', '-g']) def test_async_2(self): # Error.stackTraceLimit default to 10 in chrome but this test relies on more @@ -3589,12 +3589,12 @@ def test_dlopen_async(self): self.btest_exit(test_file('other/test_dlopen_async.c'), args=['-sMAIN_MODULE=2']) def test_dlopen_blocking(self): - self.run_process([EMCC, test_file('other/test_dlopen_blocking_side.c'), '-o', 'libside.so', '-sSIDE_MODULE', '-sUSE_PTHREADS', '-Wno-experimental']) + self.run_process([EMCC, test_file('other/test_dlopen_blocking_side.c'), '-o', 'libside.so', '-sSIDE_MODULE', '-pthread', '-Wno-experimental']) # Attempt to use dlopen the side module (without preloading) should fail on the main thread # since the syncronous `readBinary` function does not exist. self.btest_exit(test_file('other/test_dlopen_blocking.c'), assert_returncode=1, args=['-sMAIN_MODULE=2', '-sAUTOLOAD_DYLIBS=0', 'libside.so']) # But with PROXY_TO_PTHEAD it does work, since we can do blocking and sync XHR in a worker. - self.btest_exit(test_file('other/test_dlopen_blocking.c'), args=['-sMAIN_MODULE=2', '-sPROXY_TO_PTHREAD', '-sUSE_PTHREADS', '-Wno-experimental', '-sAUTOLOAD_DYLIBS=0', 'libside.so']) + self.btest_exit(test_file('other/test_dlopen_blocking.c'), args=['-sMAIN_MODULE=2', '-sPROXY_TO_PTHREAD', '-pthread', '-Wno-experimental', '-sAUTOLOAD_DYLIBS=0', 'libside.so']) # verify that dynamic linking works in all kinds of in-browser environments. # don't mix different kinds in a single test. @@ -3752,7 +3752,7 @@ def prep_no_SAB(self): @requires_threads def test_pthread_c11_threads(self): self.btest_exit(test_file('pthread/test_pthread_c11_threads.c'), - args=['-gsource-map', '-std=gnu11', '-xc', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sTOTAL_MEMORY=64mb']) + args=['-gsource-map', '-std=gnu11', '-xc', '-pthread', '-sPROXY_TO_PTHREAD', '-sTOTAL_MEMORY=64mb']) @requires_threads def test_pthread_pool_size_strict(self): @@ -3778,12 +3778,12 @@ def test_pthread_in_pthread_pool_size_strict(self): }) @requires_threads def test_pthread_atomics(self, args): - self.btest_exit(test_file('pthread/test_pthread_atomics.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8', '-g1'] + args) + self.btest_exit(test_file('pthread/test_pthread_atomics.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8', '-g1'] + args) # Test 64-bit atomics. @requires_threads def test_pthread_64bit_atomics(self): - self.btest_exit(test_file('pthread/test_pthread_64bit_atomics.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_64bit_atomics.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test 64-bit C++11 atomics. @parameterized({ @@ -3792,18 +3792,18 @@ def test_pthread_64bit_atomics(self): }) @requires_threads def test_pthread_64bit_cxx11_atomics(self, opt): - for pthreads in [[], ['-sUSE_PTHREADS']]: + for pthreads in [[], ['-pthread']]: self.btest_exit(test_file('pthread/test_pthread_64bit_cxx11_atomics.cpp'), args=opt + pthreads) # Test c++ std::thread::hardware_concurrency() @requires_threads def test_pthread_hardware_concurrency(self): - self.btest_exit(test_file('pthread/test_pthread_hardware_concurrency.cpp'), args=['-O2', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE="navigator.hardwareConcurrency"']) + self.btest_exit(test_file('pthread/test_pthread_hardware_concurrency.cpp'), args=['-O2', '-pthread', '-sPTHREAD_POOL_SIZE="navigator.hardwareConcurrency"']) # Test that we error if not ALLOW_BLOCKING_ON_MAIN_THREAD @requires_threads def test_pthread_main_thread_blocking_wait(self): - self.btest(test_file('pthread/main_thread_wait.cpp'), expected='abort:Blocking on the main thread is not allowed by default.', args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-sALLOW_BLOCKING_ON_MAIN_THREAD=0']) + self.btest(test_file('pthread/main_thread_wait.cpp'), expected='abort:Blocking on the main thread is not allowed by default.', args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE', '-sALLOW_BLOCKING_ON_MAIN_THREAD=0']) # Test that we error or warn depending on ALLOW_BLOCKING_ON_MAIN_THREAD or ASSERTIONS @requires_threads @@ -3816,15 +3816,15 @@ def test_pthread_main_thread_blocking_join(self): }; ''') # Test that we warn about blocking on the main thread in debug builds - self.btest(test_file('pthread/main_thread_join.cpp'), expected='got_warn', args=['-sEXIT_RUNTIME', '-sASSERTIONS', '--pre-js', 'pre.js', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE']) + self.btest(test_file('pthread/main_thread_join.cpp'), expected='got_warn', args=['-sEXIT_RUNTIME', '-sASSERTIONS', '--pre-js', 'pre.js', '-pthread', '-sPTHREAD_POOL_SIZE']) # Test that we do not warn about blocking on the main thread in release builds - self.btest_exit(test_file('pthread/main_thread_join.cpp'), args=['-O3', '--pre-js', 'pre.js', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/main_thread_join.cpp'), args=['-O3', '--pre-js', 'pre.js', '-pthread', '-sPTHREAD_POOL_SIZE']) # Test that tryjoin is fine, even if not ALLOW_BLOCKING_ON_MAIN_THREAD - self.btest_exit(test_file('pthread/main_thread_join.cpp'), assert_returncode=2, args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-g', '-DTRY_JOIN', '-sALLOW_BLOCKING_ON_MAIN_THREAD=0']) + self.btest_exit(test_file('pthread/main_thread_join.cpp'), assert_returncode=2, args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE', '-g', '-DTRY_JOIN', '-sALLOW_BLOCKING_ON_MAIN_THREAD=0']) # Test that tryjoin is fine, even if not ALLOW_BLOCKING_ON_MAIN_THREAD, and even without a pool - self.btest_exit(test_file('pthread/main_thread_join.cpp'), assert_returncode=2, args=['-O3', '-sUSE_PTHREADS', '-g', '-DTRY_JOIN', '-sALLOW_BLOCKING_ON_MAIN_THREAD=0']) + self.btest_exit(test_file('pthread/main_thread_join.cpp'), assert_returncode=2, args=['-O3', '-pthread', '-g', '-DTRY_JOIN', '-sALLOW_BLOCKING_ON_MAIN_THREAD=0']) # Test that everything works ok when we are on a pthread - self.btest_exit(test_file('pthread/main_thread_join.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-sPROXY_TO_PTHREAD', '-sALLOW_BLOCKING_ON_MAIN_THREAD=0']) + self.btest_exit(test_file('pthread/main_thread_join.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE', '-sPROXY_TO_PTHREAD', '-sALLOW_BLOCKING_ON_MAIN_THREAD=0']) # Test the old GCC atomic __sync_fetch_and_op builtin operations. @requires_threads @@ -3834,7 +3834,7 @@ def test_pthread_gcc_atomic_fetch_and_op(self): for debug in [[], ['-g']]: args = opt + debug print(args) - self.btest_exit(test_file('pthread/test_pthread_gcc_atomic_fetch_and_op.cpp'), args=args + ['-sINITIAL_MEMORY=64MB', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_gcc_atomic_fetch_and_op.cpp'), args=args + ['-sINITIAL_MEMORY=64MB', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # 64 bit version of the above test. @also_with_wasm2js @@ -3843,14 +3843,14 @@ def test_pthread_gcc_64bit_atomic_fetch_and_op(self): if not self.is_wasm(): self.skipTest('https://github.com/WebAssembly/binaryen/issues/4358') self.emcc_args += ['-Wno-sync-fetch-and-nand-semantics-changed'] - self.btest_exit(test_file('pthread/test_pthread_gcc_64bit_atomic_fetch_and_op.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_gcc_64bit_atomic_fetch_and_op.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test the old GCC atomic __sync_op_and_fetch builtin operations. @also_with_wasm2js @requires_threads def test_pthread_gcc_atomic_op_and_fetch(self): self.emcc_args += ['-Wno-sync-fetch-and-nand-semantics-changed'] - self.btest_exit(test_file('pthread/test_pthread_gcc_atomic_op_and_fetch.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_gcc_atomic_op_and_fetch.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # 64 bit version of the above test. @also_with_wasm2js @@ -3859,20 +3859,20 @@ def test_pthread_gcc_64bit_atomic_op_and_fetch(self): if not self.is_wasm(): self.skipTest('https://github.com/WebAssembly/binaryen/issues/4358') self.emcc_args += ['-Wno-sync-fetch-and-nand-semantics-changed', '--profiling-funcs'] - self.btest_exit(test_file('pthread/test_pthread_gcc_64bit_atomic_op_and_fetch.cpp'), args=['-sINITIAL_MEMORY=64MB', '-sUSE_PTHREADS', '-O2', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_gcc_64bit_atomic_op_and_fetch.cpp'), args=['-sINITIAL_MEMORY=64MB', '-pthread', '-O2', '-sPTHREAD_POOL_SIZE=8']) # Tests the rest of the remaining GCC atomics after the two above tests. @also_with_wasm2js @requires_threads def test_pthread_gcc_atomics(self): - self.btest_exit(test_file('pthread/test_pthread_gcc_atomics.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_gcc_atomics.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test the __sync_lock_test_and_set and __sync_lock_release primitives. @also_with_wasm2js @requires_threads def test_pthread_gcc_spinlock(self): for arg in [[], ['-DUSE_EMSCRIPTEN_INTRINSICS']]: - self.btest_exit(test_file('pthread/test_pthread_gcc_spinlock.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8'] + arg) + self.btest_exit(test_file('pthread/test_pthread_gcc_spinlock.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8'] + arg) # Test that basic thread creation works. @requires_threads @@ -3880,7 +3880,7 @@ def test_pthread_create(self): def test(args): print(args) self.btest_exit(test_file('pthread/test_pthread_create.cpp'), - args=['-sINITIAL_MEMORY=64MB', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8'] + args, + args=['-sINITIAL_MEMORY=64MB', '-pthread', '-sPTHREAD_POOL_SIZE=8'] + args, extra_tries=0) # this should be 100% deterministic print() # new line test([]) @@ -3892,111 +3892,111 @@ def test(args): # Test that preallocating worker threads work. @requires_threads def test_pthread_preallocates_workers(self): - self.btest_exit(test_file('pthread/test_pthread_preallocates_workers.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=4', '-sPTHREAD_POOL_DELAY_LOAD']) + self.btest_exit(test_file('pthread/test_pthread_preallocates_workers.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=4', '-sPTHREAD_POOL_DELAY_LOAD']) # Test that allocating a lot of threads doesn't regress. This needs to be checked manually! @requires_threads def test_pthread_large_pthread_allocation(self): - self.btest_exit(test_file('pthread/test_large_pthread_allocation.cpp'), args=['-sINITIAL_MEMORY=128MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=50']) + self.btest_exit(test_file('pthread/test_large_pthread_allocation.cpp'), args=['-sINITIAL_MEMORY=128MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=50']) # Tests the -sPROXY_TO_PTHREAD option. @requires_threads def test_pthread_proxy_to_pthread(self): - self.btest_exit(test_file('pthread/test_pthread_proxy_to_pthread.c'), args=['-O3', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']) + self.btest_exit(test_file('pthread/test_pthread_proxy_to_pthread.c'), args=['-O3', '-pthread', '-sPROXY_TO_PTHREAD']) # Test that a pthread can spawn another pthread of its own. @requires_threads def test_pthread_create_pthread(self): for modularize in [[], ['-sMODULARIZE', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html')]]: - self.btest_exit(test_file('pthread/test_pthread_create_pthread.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=2'] + modularize) + self.btest_exit(test_file('pthread/test_pthread_create_pthread.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=2'] + modularize) # Test another case of pthreads spawning pthreads, but this time the callers immediately join on the threads they created. @requires_threads def test_pthread_nested_spawns(self): - self.btest_exit(test_file('pthread/test_pthread_nested_spawns.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=2']) + self.btest_exit(test_file('pthread/test_pthread_nested_spawns.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=2']) # Test that main thread can wait for a pthread to finish via pthread_join(). @requires_threads def test_pthread_join(self): - self.btest_exit(test_file('pthread/test_pthread_join.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_join.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test that threads can rejoin the pool once detached and finished @requires_threads def test_std_thread_detach(self): - self.btest_exit(test_file('pthread/test_std_thread_detach.cpp'), args=['-sUSE_PTHREADS']) + self.btest_exit(test_file('pthread/test_std_thread_detach.cpp'), args=['-pthread']) # Test pthread_cancel() operation @requires_threads def test_pthread_cancel(self): - self.btest_exit(test_file('pthread/test_pthread_cancel.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_cancel.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test that pthread_cancel() cancels pthread_cond_wait() operation @requires_threads def test_pthread_cancel_cond_wait(self): - self.btest_exit(test_file('pthread/test_pthread_cancel_cond_wait.cpp'), assert_returncode=1, args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_cancel_cond_wait.cpp'), assert_returncode=1, args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test pthread_kill() operation @no_chrome('pthread_kill hangs chrome renderer, and keep subsequent tests from passing') @requires_threads def test_pthread_kill(self): - self.btest_exit(test_file('pthread/test_pthread_kill.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_kill.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test that pthread cleanup stack (pthread_cleanup_push/_pop) works. @requires_threads def test_pthread_cleanup(self): - self.btest_exit(test_file('pthread/test_pthread_cleanup.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_cleanup.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Tests the pthread mutex api. @requires_threads def test_pthread_mutex(self): for arg in [[], ['-DSPINLOCK_TEST']]: - self.btest_exit(test_file('pthread/test_pthread_mutex.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8'] + arg) + self.btest_exit(test_file('pthread/test_pthread_mutex.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8'] + arg) @requires_threads def test_pthread_attr_getstack(self): - self.btest_exit(test_file('pthread/test_pthread_attr_getstack.c'), args=['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=2']) + self.btest_exit(test_file('pthread/test_pthread_attr_getstack.c'), args=['-pthread', '-sPTHREAD_POOL_SIZE=2']) # Test that memory allocation is thread-safe. @requires_threads def test_pthread_malloc(self): - self.btest_exit(test_file('pthread/test_pthread_malloc.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_malloc.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Stress test pthreads allocating memory that will call to sbrk(), and main thread has to free up the data. @requires_threads def test_pthread_malloc_free(self): - self.btest_exit(test_file('pthread/test_pthread_malloc_free.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8', '-sINITIAL_MEMORY=256MB']) + self.btest_exit(test_file('pthread/test_pthread_malloc_free.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8', '-sINITIAL_MEMORY=256MB']) # Test that the pthread_barrier API works ok. @requires_threads def test_pthread_barrier(self): - self.btest_exit(test_file('pthread/test_pthread_barrier.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_barrier.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test the pthread_once() function. @requires_threads def test_pthread_once(self): - self.btest_exit(test_file('pthread/test_pthread_once.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_once.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test against a certain thread exit time handling bug by spawning tons of threads. @requires_threads def test_pthread_spawns(self): - self.btest_exit(test_file('pthread/test_pthread_spawns.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8', '--closure=1', '-sENVIRONMENT=web,worker']) + self.btest_exit(test_file('pthread/test_pthread_spawns.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8', '--closure=1', '-sENVIRONMENT=web,worker']) # It is common for code to flip volatile global vars for thread control. This is a bit lax, but nevertheless, test whether that # kind of scheme will work with Emscripten as well. @requires_threads def test_pthread_volatile(self): for arg in [[], ['-DUSE_C_VOLATILE']]: - self.btest_exit(test_file('pthread/test_pthread_volatile.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8'] + arg) + self.btest_exit(test_file('pthread/test_pthread_volatile.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8'] + arg) # Test thread-specific data (TLS). @requires_threads def test_pthread_thread_local_storage(self): - self.btest_exit(test_file('pthread/test_pthread_thread_local_storage.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8', '-sASSERTIONS']) + self.btest_exit(test_file('pthread/test_pthread_thread_local_storage.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8', '-sASSERTIONS']) # Test the pthread condition variable creation and waiting. @requires_threads def test_pthread_condition_variable(self): - self.btest_exit(test_file('pthread/test_pthread_condition_variable.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']) + self.btest_exit(test_file('pthread/test_pthread_condition_variable.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8']) # Test that pthreads are able to do printf. @parameterized({ @@ -4005,37 +4005,37 @@ def test_pthread_condition_variable(self): }) @requires_threads def test_pthread_printf(self, debug): - self.btest_exit(test_file('pthread/test_pthread_printf.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-sLIBRARY_DEBUG=%d' % debug]) + self.btest_exit(test_file('pthread/test_pthread_printf.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE', '-sLIBRARY_DEBUG=%d' % debug]) # Test that pthreads are able to do cout. Failed due to https://bugzilla.mozilla.org/show_bug.cgi?id=1154858. @requires_threads def test_pthread_iostream(self): - self.btest_exit(test_file('pthread/test_pthread_iostream.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/test_pthread_iostream.cpp'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE']) @requires_threads def test_pthread_unistd_io_bigint(self): - self.btest_exit(test_file('unistd/io.c'), args=['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sWASM_BIGINT']) + self.btest_exit(test_file('unistd/io.c'), args=['-pthread', '-sPROXY_TO_PTHREAD', '-sWASM_BIGINT']) # Test that the main thread is able to use pthread_set/getspecific. @also_with_wasm2js @requires_threads def test_pthread_setspecific_mainthread(self): - self.btest_exit(test_file('pthread/test_pthread_setspecific_mainthread.c'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-sUSE_PTHREADS']) + self.btest_exit(test_file('pthread/test_pthread_setspecific_mainthread.c'), args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread']) # Test that pthreads have access to filesystem. @requires_threads def test_pthread_file_io(self): - self.btest_exit(test_file('pthread/test_pthread_file_io.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/test_pthread_file_io.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE']) # Test that the pthread_create() function operates benignly in the case that threading is not supported. @requires_threads def test_pthread_supported(self): - for args in [[], ['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8']]: + for args in [[], ['-pthread', '-sPTHREAD_POOL_SIZE=8']]: self.btest_exit(test_file('pthread/test_pthread_supported.cpp'), args=['-O3'] + args) @requires_threads def test_pthread_dispatch_after_exit(self): - self.btest_exit(test_file('pthread/test_pthread_dispatch_after_exit.c'), args=['-sUSE_PTHREADS']) + self.btest_exit(test_file('pthread/test_pthread_dispatch_after_exit.c'), args=['-pthread']) # Test the operation of Module.pthreadMainPrefixURL variable @requires_threads @@ -4067,7 +4067,7 @@ def test_pthread_custom_pthread_main_url(self): # Test that it is possible to define "Module.locateFile" string to locate where worker.js will be loaded from. create_file('shell.html', read_file(path_from_root('src/shell.html')).replace('var Module = {', 'var Module = { locateFile: function (path, prefix) {if (path.endsWith(".wasm")) {return prefix + path;} else {return "cdn/" + path;}}, ')) - self.compile_btest(['main.cpp', '--shell-file', 'shell.html', '-sWASM=0', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-o', 'test.html'], reporting=Reporting.JS_ONLY) + self.compile_btest(['main.cpp', '--shell-file', 'shell.html', '-sWASM=0', '-pthread', '-sPTHREAD_POOL_SIZE', '-o', 'test.html'], reporting=Reporting.JS_ONLY) shutil.move('test.worker.js', Path('cdn/test.worker.js')) if os.path.exists('test.html.mem'): shutil.copyfile('test.html.mem', Path('cdn/test.html.mem')) @@ -4075,14 +4075,14 @@ def test_pthread_custom_pthread_main_url(self): # Test that it is possible to define "Module.locateFile(foo)" function to locate where worker.js will be loaded from. create_file('shell2.html', read_file(path_from_root('src/shell.html')).replace('var Module = {', 'var Module = { locateFile: function(filename) { if (filename == "test.worker.js") return "cdn/test.worker.js"; else return filename; }, ')) - self.compile_btest(['main.cpp', '--shell-file', 'shell2.html', '-sWASM=0', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-o', 'test2.html'], reporting=Reporting.JS_ONLY) + self.compile_btest(['main.cpp', '--shell-file', 'shell2.html', '-sWASM=0', '-pthread', '-sPTHREAD_POOL_SIZE', '-o', 'test2.html'], reporting=Reporting.JS_ONLY) delete_file('test.worker.js') self.run_browser('test2.html', '/report_result?exit:0') # Test that if the main thread is performing a futex wait while a pthread needs it to do a proxied operation (before that pthread would wake up the main thread), that it's not a deadlock. @requires_threads def test_pthread_proxying_in_futex_wait(self): - self.btest_exit(test_file('pthread/test_pthread_proxying_in_futex_wait.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/test_pthread_proxying_in_futex_wait.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE']) # Test that sbrk() operates properly in multithreaded conditions @requires_threads @@ -4091,44 +4091,44 @@ def test_pthread_sbrk(self): print('aborting malloc=' + str(aborting_malloc)) # With aborting malloc = 1, test allocating memory in threads # With aborting malloc = 0, allocate so much memory in threads that some of the allocations fail. - self.btest_exit(test_file('pthread/test_pthread_sbrk.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8', '-sABORTING_MALLOC=' + str(aborting_malloc), '-DABORTING_MALLOC=' + str(aborting_malloc), '-sINITIAL_MEMORY=128MB']) + self.btest_exit(test_file('pthread/test_pthread_sbrk.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8', '-sABORTING_MALLOC=' + str(aborting_malloc), '-DABORTING_MALLOC=' + str(aborting_malloc), '-sINITIAL_MEMORY=128MB']) # Test that -sABORTING_MALLOC=0 works in both pthreads and non-pthreads builds. (sbrk fails gracefully) @requires_threads def test_pthread_gauge_available_memory(self): for opts in [[], ['-O2']]: - for args in [[], ['-sUSE_PTHREADS']]: + for args in [[], ['-pthread']]: self.btest(test_file('gauge_available_memory.cpp'), expected='1', args=['-sABORTING_MALLOC=0'] + args + opts) # Test that the proxying operations of user code from pthreads to main thread work @disabled('https://github.com/emscripten-core/emscripten/issues/18210') @requires_threads def test_pthread_run_on_main_thread(self): - self.btest_exit(test_file('pthread/test_pthread_run_on_main_thread.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/test_pthread_run_on_main_thread.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE']) # Test how a lot of back-to-back called proxying operations behave. @requires_threads def test_pthread_run_on_main_thread_flood(self): - self.btest_exit(test_file('pthread/test_pthread_run_on_main_thread_flood.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/test_pthread_run_on_main_thread_flood.cpp'), args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE']) # Test that it is possible to asynchronously call a JavaScript function on the main thread. @requires_threads def test_pthread_call_async(self): - self.btest_exit(test_file('pthread/call_async.c'), args=['-sUSE_PTHREADS']) + self.btest_exit(test_file('pthread/call_async.c'), args=['-pthread']) # Test that it is possible to synchronously call a JavaScript function on the main thread and get a return value back. @requires_threads def test_pthread_call_sync_on_main_thread(self): self.set_setting('EXPORTED_FUNCTIONS', '_main,_malloc') - self.btest_exit(test_file('pthread/call_sync_on_main_thread.c'), args=['-O3', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-DPROXY_TO_PTHREAD=1', '--js-library', test_file('pthread/call_sync_on_main_thread.js')]) - self.btest_exit(test_file('pthread/call_sync_on_main_thread.c'), args=['-O3', '-sUSE_PTHREADS', '-DPROXY_TO_PTHREAD=0', '--js-library', test_file('pthread/call_sync_on_main_thread.js')]) + self.btest_exit(test_file('pthread/call_sync_on_main_thread.c'), args=['-O3', '-pthread', '-sPROXY_TO_PTHREAD', '-DPROXY_TO_PTHREAD=1', '--js-library', test_file('pthread/call_sync_on_main_thread.js')]) + self.btest_exit(test_file('pthread/call_sync_on_main_thread.c'), args=['-O3', '-pthread', '-DPROXY_TO_PTHREAD=0', '--js-library', test_file('pthread/call_sync_on_main_thread.js')]) self.btest_exit(test_file('pthread/call_sync_on_main_thread.c'), args=['-Oz', '-DPROXY_TO_PTHREAD=0', '--js-library', test_file('pthread/call_sync_on_main_thread.js')]) # Test that it is possible to asynchronously call a JavaScript function on the main thread. @requires_threads def test_pthread_call_async_on_main_thread(self): - self.btest(test_file('pthread/call_async_on_main_thread.c'), expected='7', args=['-O3', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-DPROXY_TO_PTHREAD=1', '--js-library', test_file('pthread/call_async_on_main_thread.js')]) - self.btest(test_file('pthread/call_async_on_main_thread.c'), expected='7', args=['-O3', '-sUSE_PTHREADS', '-DPROXY_TO_PTHREAD=0', '--js-library', test_file('pthread/call_async_on_main_thread.js')]) + self.btest(test_file('pthread/call_async_on_main_thread.c'), expected='7', args=['-O3', '-pthread', '-sPROXY_TO_PTHREAD', '-DPROXY_TO_PTHREAD=1', '--js-library', test_file('pthread/call_async_on_main_thread.js')]) + self.btest(test_file('pthread/call_async_on_main_thread.c'), expected='7', args=['-O3', '-pthread', '-DPROXY_TO_PTHREAD=0', '--js-library', test_file('pthread/call_async_on_main_thread.js')]) self.btest(test_file('pthread/call_async_on_main_thread.c'), expected='7', args=['-Oz', '-DPROXY_TO_PTHREAD=0', '--js-library', test_file('pthread/call_async_on_main_thread.js')]) # Tests that spawning a new thread does not cause a reinitialization of the global data section of the application memory area. @@ -4137,7 +4137,7 @@ def test_pthread_global_data_initialization(self): mem_init_modes = [[], ['--memory-init-file', '0'], ['--memory-init-file', '1']] for mem_init_mode in mem_init_modes: for args in [['-sMODULARIZE', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html')], ['-O3']]: - self.btest_exit(test_file('pthread/test_pthread_global_data_initialization.c'), args=args + mem_init_mode + ['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/test_pthread_global_data_initialization.c'), args=args + mem_init_mode + ['-pthread', '-sPROXY_TO_PTHREAD', '-sPTHREAD_POOL_SIZE']) @requires_threads @requires_sync_compilation @@ -4145,44 +4145,44 @@ def test_pthread_global_data_initialization_in_sync_compilation_mode(self): mem_init_modes = [[], ['--memory-init-file', '0'], ['--memory-init-file', '1']] for mem_init_mode in mem_init_modes: args = ['-sWASM_ASYNC_COMPILATION=0'] - self.btest_exit(test_file('pthread/test_pthread_global_data_initialization.c'), args=args + mem_init_mode + ['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/test_pthread_global_data_initialization.c'), args=args + mem_init_mode + ['-pthread', '-sPROXY_TO_PTHREAD', '-sPTHREAD_POOL_SIZE']) # Test that emscripten_get_now() reports coherent wallclock times across all pthreads, instead of each pthread independently reporting wallclock times since the launch of that pthread. @requires_threads def test_pthread_clock_drift(self): - self.btest_exit(test_file('pthread/test_pthread_clock_drift.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']) + self.btest_exit(test_file('pthread/test_pthread_clock_drift.cpp'), args=['-O3', '-pthread', '-sPROXY_TO_PTHREAD']) @requires_threads def test_pthread_utf8_funcs(self): - self.btest_exit(test_file('pthread/test_pthread_utf8_funcs.cpp'), args=['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/test_pthread_utf8_funcs.cpp'), args=['-pthread', '-sPTHREAD_POOL_SIZE']) # Test the emscripten_futex_wake(addr, INT_MAX); functionality to wake all waiters @also_with_wasm2js @requires_threads def test_pthread_wake_all(self): - self.btest_exit(test_file('pthread/test_futex_wake_all.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sINITIAL_MEMORY=64MB']) + self.btest_exit(test_file('pthread/test_futex_wake_all.cpp'), args=['-O3', '-pthread', '-sINITIAL_MEMORY=64MB']) # Test that stack base and max correctly bound the stack on pthreads. @requires_threads def test_pthread_stack_bounds(self): - self.btest_exit(test_file('pthread/test_pthread_stack_bounds.cpp'), args=['-sUSE_PTHREADS']) + self.btest_exit(test_file('pthread/test_pthread_stack_bounds.cpp'), args=['-pthread']) # Test that real `thread_local` works. @requires_threads def test_pthread_tls(self): - self.btest_exit(test_file('pthread/test_pthread_tls.cpp'), args=['-sPROXY_TO_PTHREAD', '-sUSE_PTHREADS']) + self.btest_exit(test_file('pthread/test_pthread_tls.cpp'), args=['-sPROXY_TO_PTHREAD', '-pthread']) # Test that real `thread_local` works in main thread without PROXY_TO_PTHREAD. @requires_threads def test_pthread_tls_main(self): - self.btest_exit(test_file('pthread/test_pthread_tls_main.cpp'), args=['-sUSE_PTHREADS']) + self.btest_exit(test_file('pthread/test_pthread_tls_main.cpp'), args=['-pthread']) @requires_threads def test_pthread_safe_stack(self): # Note that as the test runs with PROXY_TO_PTHREAD, we set STACK_SIZE, # and not DEFAULT_PTHREAD_STACK_SIZE, as the pthread for main() gets the # same stack size as the main thread normally would. - self.btest(test_file('core/test_safe_stack.c'), expected='abort:stack overflow', args=['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sSTACK_OVERFLOW_CHECK=2', '-sSTACK_SIZE=64KB']) + self.btest(test_file('core/test_safe_stack.c'), expected='abort:stack overflow', args=['-pthread', '-sPROXY_TO_PTHREAD', '-sSTACK_OVERFLOW_CHECK=2', '-sSTACK_SIZE=64KB']) @parameterized({ 'leak': ['test_pthread_lsan_leak', ['-gsource-map']], @@ -4191,7 +4191,7 @@ def test_pthread_safe_stack(self): @requires_threads @no_firefox('https://github.com/emscripten-core/emscripten/issues/15978') def test_pthread_lsan(self, name, args): - self.btest(test_file('pthread', name + '.cpp'), expected='1', args=['-fsanitize=leak', '-sINITIAL_MEMORY=256MB', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread', name + '.js')] + args) + self.btest(test_file('pthread', name + '.cpp'), expected='1', args=['-fsanitize=leak', '-sINITIAL_MEMORY=256MB', '-pthread', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread', name + '.js')] + args) @parameterized({ # Reusing the LSan test files for ASan. @@ -4200,11 +4200,11 @@ def test_pthread_lsan(self, name, args): }) @requires_threads def test_pthread_asan(self, name, args): - self.btest(test_file('pthread', name + '.cpp'), expected='1', args=['-fsanitize=address', '-sINITIAL_MEMORY=256MB', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread', name + '.js')] + args) + self.btest(test_file('pthread', name + '.cpp'), expected='1', args=['-fsanitize=address', '-sINITIAL_MEMORY=256MB', '-pthread', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread', name + '.js')] + args) @requires_threads def test_pthread_asan_use_after_free(self): - self.btest(test_file('pthread/test_pthread_asan_use_after_free.cpp'), expected='1', args=['-fsanitize=address', '-sINITIAL_MEMORY=256MB', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread/test_pthread_asan_use_after_free.js')]) + self.btest(test_file('pthread/test_pthread_asan_use_after_free.cpp'), expected='1', args=['-fsanitize=address', '-sINITIAL_MEMORY=256MB', '-pthread', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread/test_pthread_asan_use_after_free.js')]) @requires_threads def test_pthread_asan_use_after_free_2(self): @@ -4212,11 +4212,11 @@ def test_pthread_asan_use_after_free_2(self): # of proxy-to-pthread, and also the allocation happens on the pthread # (which tests that it can use the offset converter to get the stack # trace there) - self.btest(test_file('pthread/test_pthread_asan_use_after_free_2.cpp'), expected='1', args=['-fsanitize=address', '-sINITIAL_MEMORY=256MB', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=1', '--pre-js', test_file('pthread/test_pthread_asan_use_after_free_2.js')]) + self.btest(test_file('pthread/test_pthread_asan_use_after_free_2.cpp'), expected='1', args=['-fsanitize=address', '-sINITIAL_MEMORY=256MB', '-pthread', '-sPTHREAD_POOL_SIZE=1', '--pre-js', test_file('pthread/test_pthread_asan_use_after_free_2.js')]) @requires_threads def test_pthread_exit_process(self): - args = ['-sUSE_PTHREADS', + args = ['-pthread', '-sPROXY_TO_PTHREAD', '-sPTHREAD_POOL_SIZE=2', '-sEXIT_RUNTIME', @@ -4236,7 +4236,7 @@ def test_pthread_trap(self): maybeReportResultToServer("unexpected: " + e); }); }''') - args = ['-sUSE_PTHREADS', + args = ['-pthread', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME', '--profiling-funcs', @@ -4249,17 +4249,17 @@ def test_main_thread_em_asm_signatures(self): @requires_threads def test_main_thread_em_asm_signatures_pthreads(self): - self.btest_exit(test_file('core/test_em_asm_signatures.cpp'), assert_returncode=121, args=['-O3', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sASSERTIONS']) + self.btest_exit(test_file('core/test_em_asm_signatures.cpp'), assert_returncode=121, args=['-O3', '-pthread', '-sPROXY_TO_PTHREAD', '-sASSERTIONS']) @requires_threads def test_main_thread_async_em_asm(self): - self.btest_exit(test_file('core/test_main_thread_async_em_asm.cpp'), args=['-O3', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sASSERTIONS']) + self.btest_exit(test_file('core/test_main_thread_async_em_asm.cpp'), args=['-O3', '-pthread', '-sPROXY_TO_PTHREAD', '-sASSERTIONS']) @requires_threads def test_main_thread_em_asm_blocking(self): shutil.copyfile(test_file('browser/test_em_asm_blocking.html'), 'page.html') - self.compile_btest([test_file('browser/test_em_asm_blocking.cpp'), '-O2', '-o', 'wasm.js', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME']) + self.compile_btest([test_file('browser/test_em_asm_blocking.cpp'), '-O2', '-o', 'wasm.js', '-pthread', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME']) self.run_browser('page.html', '/report_result?exit:8') # Test that it is possible to send a signal via calling alarm(timeout), which in turn calls to the signal handler set by signal(SIGALRM, func); @@ -4409,7 +4409,7 @@ def test_small_js_flags(self): @requires_graphics_hardware def test_webgl_offscreen_canvas_in_pthread(self): for args in [[], ['-DTEST_CHAINED_WEBGL_CONTEXT_PASSING']]: - self.btest('gl_in_pthread.cpp', expected='1', args=args + ['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=2', '-sOFFSCREENCANVAS_SUPPORT', '-lGL']) + self.btest('gl_in_pthread.cpp', expected='1', args=args + ['-pthread', '-sPTHREAD_POOL_SIZE=2', '-sOFFSCREENCANVAS_SUPPORT', '-lGL']) # Tests that it is possible to render WebGL content on a on the main thread, after it has once been used to render WebGL content in a pthread first # -DTEST_MAIN_THREAD_EXPLICIT_COMMIT: Test the same (WebGL on main thread after pthread), but by using explicit .commit() to swap on the main thread instead of implicit "swap when rAF ends" logic @@ -4419,13 +4419,13 @@ def test_webgl_offscreen_canvas_in_pthread(self): @disabled('This test is disabled because current OffscreenCanvas does not allow transfering it after a rendering context has been created for it.') def test_webgl_offscreen_canvas_in_mainthread_after_pthread(self): for args in [[], ['-DTEST_MAIN_THREAD_EXPLICIT_COMMIT']]: - self.btest('gl_in_mainthread_after_pthread.cpp', expected='0', args=args + ['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=2', '-sOFFSCREENCANVAS_SUPPORT', '-lGL']) + self.btest('gl_in_mainthread_after_pthread.cpp', expected='0', args=args + ['-pthread', '-sPTHREAD_POOL_SIZE=2', '-sOFFSCREENCANVAS_SUPPORT', '-lGL']) @requires_threads @requires_offscreen_canvas @requires_graphics_hardware def test_webgl_offscreen_canvas_only_in_pthread(self): - self.btest_exit('gl_only_in_pthread.cpp', args=['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-sOFFSCREENCANVAS_SUPPORT', '-lGL', '-sOFFSCREEN_FRAMEBUFFER']) + self.btest_exit('gl_only_in_pthread.cpp', args=['-pthread', '-sPTHREAD_POOL_SIZE', '-sOFFSCREENCANVAS_SUPPORT', '-lGL', '-sOFFSCREEN_FRAMEBUFFER']) # Tests that rendering from client side memory without default-enabling extensions works. @requires_graphics_hardware @@ -4486,7 +4486,7 @@ def test_webgl_timer_query(self): @requires_graphics_hardware def test_webgl_offscreen_framebuffer(self): # Tests all the different possible versions of libgl - for threads in [[], ['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']]: + for threads in [[], ['-pthread', '-sPROXY_TO_PTHREAD']]: for version in [[], ['-sFULL_ES3'], ['-sFULL_ES3']]: args = ['-lGL', '-sOFFSCREEN_FRAMEBUFFER', '-DEXPLICIT_SWAP=1'] + threads + version print('with args: %s' % str(args)) @@ -4537,7 +4537,7 @@ def test_webgl_array_of_structs_uniform(self): @requires_offscreen_canvas @requires_graphics_hardware def test_webgl_offscreen_canvas_in_proxied_pthread(self, asyncify): - cmd = ['-sUSE_PTHREADS', '-sOFFSCREENCANVAS_SUPPORT', '-lGL', '-sGL_DEBUG', '-sPROXY_TO_PTHREAD'] + cmd = ['-pthread', '-sOFFSCREENCANVAS_SUPPORT', '-lGL', '-sGL_DEBUG', '-sPROXY_TO_PTHREAD'] if asyncify: # given the synchronous render loop here, asyncify is needed to see intermediate frames and # the gradual color change @@ -4555,7 +4555,7 @@ def test_webgl_offscreen_canvas_in_proxied_pthread(self, asyncify): def test_webgl_resize_offscreencanvas_from_main_thread(self, args): for args2 in [[], ['-DTEST_SYNC_BLOCKING_LOOP=1']]: for args3 in [[], ['-sOFFSCREENCANVAS_SUPPORT', '-sOFFSCREEN_FRAMEBUFFER']]: - cmd = args + args2 + args3 + ['-sUSE_PTHREADS', '-lGL', '-sGL_DEBUG'] + cmd = args + args2 + args3 + ['-pthread', '-lGL', '-sGL_DEBUG'] print(str(cmd)) self.btest_exit('resize_offscreencanvas_from_main_thread.cpp', args=cmd) @@ -4608,7 +4608,7 @@ def test_fetch_to_memory(self): def test_fetch_from_thread(self, args): shutil.copyfile(test_file('gears.png'), 'gears.png') self.btest_exit('fetch/from_thread.cpp', - args=args + ['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD', '-sFETCH_DEBUG', '-sFETCH', '-DFILE_DOES_NOT_EXIST'], + args=args + ['-pthread', '-sPROXY_TO_PTHREAD', '-sFETCH_DEBUG', '-sFETCH', '-DFILE_DOES_NOT_EXIST'], also_wasm2js=True) @also_with_wasm2js @@ -4630,7 +4630,7 @@ def test_fetch_cached_xhr(self): @requires_threads def test_fetch_response_headers(self): shutil.copyfile(test_file('gears.png'), 'gears.png') - self.btest_exit('fetch/response_headers.cpp', args=['-sFETCH_DEBUG', '-sFETCH', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']) + self.btest_exit('fetch/response_headers.cpp', args=['-sFETCH_DEBUG', '-sFETCH', '-pthread', '-sPROXY_TO_PTHREAD']) # Test emscripten_fetch() usage to stream a XHR in to memory without storing the full file in memory @also_with_wasm2js @@ -4662,7 +4662,7 @@ def test_fetch_xhr_abort(self): @requires_threads def test_fetch_sync_xhr(self): shutil.copyfile(test_file('gears.png'), 'gears.png') - self.btest_exit('fetch/sync_xhr.cpp', args=['-sFETCH_DEBUG', '-sFETCH', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']) + self.btest_exit('fetch/sync_xhr.cpp', args=['-sFETCH_DEBUG', '-sFETCH', '-pthread', '-sPROXY_TO_PTHREAD']) # Tests emscripten_fetch() usage when user passes none of the main 3 flags (append/replace/no_download). # In that case, in append is implicitly understood. @@ -4670,14 +4670,14 @@ def test_fetch_sync_xhr(self): @requires_threads def test_fetch_implicit_append(self): shutil.copyfile(test_file('gears.png'), 'gears.png') - self.btest_exit('fetch/example_synchronous_fetch.c', args=['-sFETCH', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']) + self.btest_exit('fetch/example_synchronous_fetch.c', args=['-sFETCH', '-pthread', '-sPROXY_TO_PTHREAD']) # Tests synchronous emscripten_fetch() usage from wasm pthread in fastcomp. @no_firefox('https://github.com/emscripten-core/emscripten/issues/16868') @requires_threads def test_fetch_sync_xhr_in_wasm(self): shutil.copyfile(test_file('gears.png'), 'gears.png') - self.btest_exit('fetch/example_synchronous_fetch.c', args=['-sFETCH', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']) + self.btest_exit('fetch/example_synchronous_fetch.c', args=['-sFETCH', '-pthread', '-sPROXY_TO_PTHREAD']) # Tests that the Fetch API works for synchronous XHRs when used with --proxy-to-worker. @no_firefox('https://github.com/emscripten-core/emscripten/issues/16868') @@ -4693,18 +4693,18 @@ def test_fetch_sync_xhr_in_proxy_to_worker(self): @requires_threads def test_fetch_sync_fetch_in_main_thread(self): shutil.copyfile(test_file('gears.png'), 'gears.png') - self.btest_exit('fetch/sync_fetch_in_main_thread.cpp', args=['-sFETCH_DEBUG', '-sFETCH', '-sWASM=0', '-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']) + self.btest_exit('fetch/sync_fetch_in_main_thread.cpp', args=['-sFETCH_DEBUG', '-sFETCH', '-sWASM=0', '-pthread', '-sPROXY_TO_PTHREAD']) @requires_threads @disabled('https://github.com/emscripten-core/emscripten/issues/16746') def test_fetch_idb_store(self): - self.btest_exit('fetch/idb_store.cpp', args=['-sUSE_PTHREADS', '-sFETCH', '-sWASM=0', '-sPROXY_TO_PTHREAD']) + self.btest_exit('fetch/idb_store.cpp', args=['-pthread', '-sFETCH', '-sWASM=0', '-sPROXY_TO_PTHREAD']) @requires_threads @disabled('https://github.com/emscripten-core/emscripten/issues/16746') def test_fetch_idb_delete(self): shutil.copyfile(test_file('gears.png'), 'gears.png') - self.btest_exit('fetch/idb_delete.cpp', args=['-sUSE_PTHREADS', '-sFETCH_DEBUG', '-sFETCH', '-sWASM=0', '-sPROXY_TO_PTHREAD']) + self.btest_exit('fetch/idb_delete.cpp', args=['-pthread', '-sFETCH_DEBUG', '-sFETCH', '-sWASM=0', '-sPROXY_TO_PTHREAD']) @requires_threads def test_pthread_locale(self): @@ -4712,7 +4712,7 @@ def test_pthread_locale(self): self.emcc_args.append('-I' + path_from_root('system/lib/pthread')) for args in [ [], - ['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=2'], + ['-pthread', '-sPTHREAD_POOL_SIZE=2'], ]: print("Testing with: ", args) self.btest_exit('pthread/test_pthread_locale.c', args=args) @@ -4726,13 +4726,13 @@ def test_emscripten_set_canvas_element_size(self): # thread to obtain the proper window.devicePixelRatio value). @requires_threads def test_emscripten_get_device_pixel_ratio(self): - for args in [[], ['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']]: + for args in [[], ['-pthread', '-sPROXY_TO_PTHREAD']]: self.btest_exit('emscripten_get_device_pixel_ratio.c', args=args) # Tests that emscripten_run_script() variants of functions work in pthreads. @requires_threads def test_pthread_run_script(self): - for args in [[], ['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']]: + for args in [[], ['-pthread', '-sPROXY_TO_PTHREAD']]: self.btest_exit(test_file('pthread/test_pthread_run_script.cpp'), args=['-O3'] + args) # Tests emscripten_set_canvas_element_size() and OffscreenCanvas functionality in different build configurations. @@ -4741,10 +4741,10 @@ def test_pthread_run_script(self): def test_emscripten_animate_canvas_element_size(self): for args in [ ['-DTEST_EMSCRIPTEN_SET_MAIN_LOOP=1'], - ['-DTEST_EMSCRIPTEN_SET_MAIN_LOOP=1', '-sPROXY_TO_PTHREAD', '-sUSE_PTHREADS', '-sOFFSCREEN_FRAMEBUFFER'], - ['-DTEST_EMSCRIPTEN_SET_MAIN_LOOP=1', '-sPROXY_TO_PTHREAD', '-sUSE_PTHREADS', '-sOFFSCREEN_FRAMEBUFFER', '-DTEST_EXPLICIT_CONTEXT_SWAP=1'], - ['-DTEST_EXPLICIT_CONTEXT_SWAP=1', '-sPROXY_TO_PTHREAD', '-sUSE_PTHREADS', '-sOFFSCREEN_FRAMEBUFFER'], - ['-DTEST_EXPLICIT_CONTEXT_SWAP=1', '-sPROXY_TO_PTHREAD', '-sUSE_PTHREADS', '-sOFFSCREEN_FRAMEBUFFER', '-DTEST_MANUALLY_SET_ELEMENT_CSS_SIZE=1'], + ['-DTEST_EMSCRIPTEN_SET_MAIN_LOOP=1', '-sPROXY_TO_PTHREAD', '-pthread', '-sOFFSCREEN_FRAMEBUFFER'], + ['-DTEST_EMSCRIPTEN_SET_MAIN_LOOP=1', '-sPROXY_TO_PTHREAD', '-pthread', '-sOFFSCREEN_FRAMEBUFFER', '-DTEST_EXPLICIT_CONTEXT_SWAP=1'], + ['-DTEST_EXPLICIT_CONTEXT_SWAP=1', '-sPROXY_TO_PTHREAD', '-pthread', '-sOFFSCREEN_FRAMEBUFFER'], + ['-DTEST_EXPLICIT_CONTEXT_SWAP=1', '-sPROXY_TO_PTHREAD', '-pthread', '-sOFFSCREEN_FRAMEBUFFER', '-DTEST_MANUALLY_SET_ELEMENT_CSS_SIZE=1'], ['-DTEST_EMSCRIPTEN_SET_MAIN_LOOP=1', '-sOFFSCREENCANVAS_SUPPORT'], ]: cmd = ['-lGL', '-O3', '-g2', '--shell-file', test_file('canvas_animate_resize_shell.html'), '-sGL_DEBUG', '--threadprofiler', '-sASSERTIONS'] + args @@ -4759,7 +4759,7 @@ def test_emscripten_animate_canvas_element_size(self): @requires_threads def test_pthread_hello_thread(self, opts): for modularize in [[], ['-sMODULARIZE', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html')]]: - self.btest_exit(test_file('pthread/hello_thread.c'), args=['-sUSE_PTHREADS'] + modularize + opts) + self.btest_exit(test_file('pthread/hello_thread.c'), args=['-pthread'] + modularize + opts) # Tests that a pthreads build of -sMINIMAL_RUNTIME works well in different build modes @parameterized({ @@ -4770,7 +4770,7 @@ def test_pthread_hello_thread(self, opts): 'O3_modularize_MINIMAL_RUNTIME_2': (['-O3', '-sMODULARIZE', '-sEXPORT_NAME=MyModule', '-sMINIMAL_RUNTIME=2'],), }) def test_minimal_runtime_hello_thread(self, opts): - self.btest_exit(test_file('pthread/hello_thread.c'), args=['--closure=1', '-sMINIMAL_RUNTIME', '-sUSE_PTHREADS'] + opts) + self.btest_exit(test_file('pthread/hello_thread.c'), args=['--closure=1', '-sMINIMAL_RUNTIME', '-pthread'] + opts) # Tests memory growth in pthreads mode, but still on the main thread. @parameterized({ @@ -4780,7 +4780,7 @@ def test_minimal_runtime_hello_thread(self, opts): @requires_threads def test_pthread_growth_mainthread(self, emcc_args): self.emcc_args.remove('-Werror') - self.btest_exit(test_file('pthread/test_pthread_memory_growth_mainthread.c'), args=['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=2', '-sALLOW_MEMORY_GROWTH', '-sINITIAL_MEMORY=32MB', '-sMAXIMUM_MEMORY=256MB'] + emcc_args, also_wasm2js=False) + self.btest_exit(test_file('pthread/test_pthread_memory_growth_mainthread.c'), args=['-pthread', '-sPTHREAD_POOL_SIZE=2', '-sALLOW_MEMORY_GROWTH', '-sINITIAL_MEMORY=32MB', '-sMAXIMUM_MEMORY=256MB'] + emcc_args, also_wasm2js=False) # Tests memory growth in a pthread. @parameterized({ @@ -4792,21 +4792,21 @@ def test_pthread_growth_mainthread(self, emcc_args): @requires_threads def test_pthread_growth(self, emcc_args): self.emcc_args.remove('-Werror') - self.btest_exit(test_file('pthread/test_pthread_memory_growth.c'), args=['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=2', '-sALLOW_MEMORY_GROWTH', '-sINITIAL_MEMORY=32MB', '-sMAXIMUM_MEMORY=256MB', '-g'] + emcc_args, also_wasm2js=False) + self.btest_exit(test_file('pthread/test_pthread_memory_growth.c'), args=['-pthread', '-sPTHREAD_POOL_SIZE=2', '-sALLOW_MEMORY_GROWTH', '-sINITIAL_MEMORY=32MB', '-sMAXIMUM_MEMORY=256MB', '-g'] + emcc_args, also_wasm2js=False) # Tests that time in a pthread is relative to the main thread, so measurements # on different threads are still monotonic, as if checking a single central # clock. @requires_threads def test_pthread_reltime(self): - self.btest_exit(test_file('pthread/test_pthread_reltime.cpp'), args=['-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE']) + self.btest_exit(test_file('pthread/test_pthread_reltime.cpp'), args=['-pthread', '-sPTHREAD_POOL_SIZE']) # Tests that it is possible to load the main .js file of the application manually via a Blob URL, and still use pthreads. @requires_threads def test_load_js_from_blob_with_pthreads(self): # TODO: enable this with wasm, currently pthreads/atomics have limitations self.set_setting('EXIT_RUNTIME') - self.compile_btest([test_file('pthread/hello_thread.c'), '-sUSE_PTHREADS', '-o', 'hello_thread_with_blob_url.js'], reporting=Reporting.JS_ONLY) + self.compile_btest([test_file('pthread/hello_thread.c'), '-pthread', '-o', 'hello_thread_with_blob_url.js'], reporting=Reporting.JS_ONLY) shutil.copyfile(test_file('pthread/main_js_as_blob_loader.html'), 'hello_thread_with_blob_url.html') self.run_browser('hello_thread_with_blob_url.html', '/report_result?exit:0') @@ -4906,7 +4906,7 @@ def test_single_file_worker_js(self): @requires_threads def test_pthreads_started_in_worker(self): self.set_setting('EXIT_RUNTIME') - self.compile_btest([test_file('pthread/test_pthread_atomics.cpp'), '-o', 'test.js', '-sINITIAL_MEMORY=64MB', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE=8'], reporting=Reporting.JS_ONLY) + self.compile_btest([test_file('pthread/test_pthread_atomics.cpp'), '-o', 'test.js', '-sINITIAL_MEMORY=64MB', '-pthread', '-sPTHREAD_POOL_SIZE=8'], reporting=Reporting.JS_ONLY) create_file('test.html', '''