wasm: support enabling JSPI via QT_EMSCRIPTEN_ASYNCIFY=2

Emscripten has deprecated the "asyncify 2" naming in favor of
"-sJSPI", but for now extending the existing asyncify option makes
sense for Qt since JSPI is not widely supported yet.

There's no difference between these on the C++ code level,
and we can set QT_HAVE_EMSCRIPTEN_ASYNCIFY for JSPI as well.

Change-Id: I371dfb761e8de3cb7f3273a685bb4219e984e84c
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
This commit is contained in:
Morten Sørvig 2024-07-15 14:21:18 +02:00 committed by Morten Johan Sørvig
parent 804fae2e46
commit 7a21ba15ed
2 changed files with 14 additions and 3 deletions

View File

@ -72,6 +72,12 @@ function (qt_internal_setup_wasm_target_properties wasmTarget)
target_link_options("${wasmTarget}" INTERFACE "SHELL:-s ASYNCIFY" "-Os") target_link_options("${wasmTarget}" INTERFACE "SHELL:-s ASYNCIFY" "-Os")
target_compile_definitions("${wasmTarget}" INTERFACE QT_HAVE_EMSCRIPTEN_ASYNCIFY) target_compile_definitions("${wasmTarget}" INTERFACE QT_HAVE_EMSCRIPTEN_ASYNCIFY)
elseif ("QT_EMSCRIPTEN_ASYNCIFY=2" IN_LIST QT_QMAKE_DEVICE_OPTIONS)
# Enable JSPI (also known as asyncify 2). Unlike asyncify 1 this
# is supported natively by the browsers, and does not require
# enabling optimizations.
target_link_options("${wasmTarget}" INTERFACE "SHELL:-s JSPI")
target_compile_definitions("${wasmTarget}" INTERFACE QT_HAVE_EMSCRIPTEN_ASYNCIFY)
endif() endif()
# Set ASYNCIFY_IMPORTS unconditionally in order to support enabling asyncify at link time. # Set ASYNCIFY_IMPORTS unconditionally in order to support enabling asyncify at link time.

View File

@ -8,10 +8,10 @@ include(../clang.conf)
load(device_config) load(device_config)
load(emcc_ver) load(emcc_ver)
# Support enabling asyncify by configuring with "-device-option QT_EMSCRIPTEN_ASYNCIFY=1" # Support enabling asyncify by configuring with "-device-option QT_EMSCRIPTEN_ASYNCIFY"
!isEmpty(QT_EMSCRIPTEN_ASYNCIFY): { !isEmpty(QT_EMSCRIPTEN_ASYNCIFY): {
!equals(QT_EMSCRIPTEN_ASYNCIFY, 1):!equals(QT_EMSCRIPTEN_ASYNCIFY, 0): \ !equals(QT_EMSCRIPTEN_ASYNCIFY, 2):!equals(QT_EMSCRIPTEN_ASYNCIFY, 1):!equals(QT_EMSCRIPTEN_ASYNCIFY, 0): \
message(Error: The value for QT_EMSCRIPTEN_ASYNCIFY must be 0 or 1) message(Error: The value for QT_EMSCRIPTEN_ASYNCIFY must be 0, 1, or 2)
equals(QT_EMSCRIPTEN_ASYNCIFY, 1): { equals(QT_EMSCRIPTEN_ASYNCIFY, 1): {
QMAKE_CFLAGS += -DQT_HAVE_EMSCRIPTEN_ASYNCIFY QMAKE_CFLAGS += -DQT_HAVE_EMSCRIPTEN_ASYNCIFY
QMAKE_CXXFLAGS += -DQT_HAVE_EMSCRIPTEN_ASYNCIFY QMAKE_CXXFLAGS += -DQT_HAVE_EMSCRIPTEN_ASYNCIFY
@ -23,6 +23,11 @@ load(emcc_ver)
# are omitted. Enable optimizations also for debug builds. # are omitted. Enable optimizations also for debug builds.
QMAKE_LFLAGS_DEBUG += -Os QMAKE_LFLAGS_DEBUG += -Os
} }
equals(QT_EMSCRIPTEN_ASYNCIFY, 2): {
QMAKE_CFLAGS += -DQT_HAVE_EMSCRIPTEN_ASYNCIFY
QMAKE_CXXFLAGS += -DQT_HAVE_EMSCRIPTEN_ASYNCIFY
QMAKE_LFLAGS += -s JSPI
}
} }
# Declare async functions # Declare async functions