Skip to content

Commit

Permalink
Switch from -sUSE_PTHREAD to the standard -pthread. NFC (emscript…
Browse files Browse the repository at this point in the history
…en-core#18917)

We already supported this flag, but this change mostly updates all
or tests and documentation to refer exclusively to that latter.
  • Loading branch information
sbc100 authored and impact-maker committed Mar 17, 2023
1 parent ed28077 commit 916b0ea
Show file tree
Hide file tree
Showing 25 changed files with 225 additions and 233 deletions.
2 changes: 1 addition & 1 deletion docs/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path>"
[general] Specifies the location of the **.emscripten**
Expand Down
4 changes: 2 additions & 2 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions site/source/docs/api_reference/fetch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion site/source/docs/compiling/Building-Projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion site/source/docs/porting/networking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion site/source/docs/porting/simd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/emscripten-core/emscripten/issues?q=is%3Aopen+is%3Aissue+label%3ASIMD>`_.

Expand Down
2 changes: 1 addition & 1 deletion site/source/docs/tools_reference/emcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion src/closure-externs/minimal_runtime_worker_externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} */
Expand Down
4 changes: 2 additions & 2 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
2 changes: 1 addition & 1 deletion system/include/emscripten/em_asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const char __em_asm_sig_builder<__em_asm_type_tuple<Args...> >::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
Expand Down
2 changes: 1 addition & 1 deletion system/include/emscripten/threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)), ...);

Expand Down
2 changes: 1 addition & 1 deletion system/lib/wasmfs/fuzzer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/canvas_animate_resize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion test/pthread/call_sync_on_main_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 916b0ea

Please sign in to comment.