Add experimental support for Emscripten JSPI

...which I've seen fundamentally working when building with recent emsdk against
recent Qt6 trunk (and including <https://github.com/qt/qtbase/pull/108> "Update
the check for WebAssembly JSPI support") and running on recent Chrome (with JSPI
enabled under <chrome://flags/>)

Change-Id: I98c11c5ee7e95b135ddc33c95c95752055ecd4c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176031
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
This commit is contained in:
Stephan Bergmann 2024-11-04 17:46:47 +01:00
parent 060d2fe39f
commit f510ce620f
5 changed files with 25 additions and 1 deletions

View file

@ -176,6 +176,7 @@ export ENABLE_DEBUG=@ENABLE_DEBUG@
ENABLE_DOTNET=@ENABLE_DOTNET@
SYSTEM_DRAGONBOX=@SYSTEM_DRAGONBOX@
SYSTEM_FROZEN=@SYSTEM_FROZEN@
export ENABLE_EMSCRIPTEN_JSPI=@ENABLE_EMSCRIPTEN_JSPI@
export ENABLE_EMSCRIPTEN_PROXY_POSIX_SOCKETS=@ENABLE_EMSCRIPTEN_PROXY_POSIX_SOCKETS@
export ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD=@ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD@
export ENABLE_EPOXY=@ENABLE_EPOXY@

View file

@ -9,6 +9,8 @@
#pragma once
#define HAVE_EMSCRIPTEN_JSPI 0
#define HAVE_EMSCRIPTEN_PROXY_POSIX_SOCKETS 0
#define HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD 0

View file

@ -2180,6 +2180,14 @@ AC_ARG_WITH(main-module,
Default value is 'writer'.]),
,)
if test "$_os" = Emscripten; then
AC_ARG_ENABLE(emscripten-jspi,
AS_HELP_STRING([--enable-emscripten-jspi],
[Experimentally enable use of the Emscripten -sJSPI feature.]))
else
enable_emscripten_jspi=
fi
if test "$_os" = Emscripten; then
AC_ARG_ENABLE(emscripten-proxy-to-pthread,
AS_HELP_STRING([--disable-emscripten-proxy-to-pthread],
@ -4199,6 +4207,14 @@ AC_SUBST(ENABLE_WASM_STRIP)
AC_SUBST(ENABLE_WASM_STRIP_WRITER)
AC_SUBST(ENABLE_WASM_STRIP_CALC)
if test "$enable_emscripten_jspi" = yes; then
ENABLE_EMSCRIPTEN_JSPI=TRUE
AC_DEFINE(HAVE_EMSCRIPTEN_JSPI)
else
ENABLE_EMSCRIPTEN_JSPI=
fi
AC_SUBST(ENABLE_EMSCRIPTEN_JSPI)
if test "$enable_emscripten_proxy_to_pthread" = yes; then
ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD=TRUE
AC_DEFINE(HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD)

View file

@ -30,6 +30,10 @@ gb_EMSCRIPTEN_LDFLAGS += -sSTACK_SIZE=131072 -sDEFAULT_PTHREAD_STACK_SIZE=65536
gb_EMSCRIPTEN_LDFLAGS += --bind -s FORCE_FILESYSTEM=1 -s WASM_BIGINT=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s FETCH=1 -s ASSERTIONS=1 -s EXIT_RUNTIME=0 -s EXPORTED_RUNTIME_METHODS=["UTF16ToString","stringToUTF16","UTF8ToString","ccall","cwrap","addOnPreMain","addOnPostRun","registerType","throwBindingError"$(if $(ENABLE_QT6),$(COMMA)"FS"$(COMMA)"callMain"$(COMMA)"specialHTMLTargets")]
gb_EMSCRIPTEN_QTDEFS := -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
ifeq ($(ENABLE_EMSCRIPTEN_JSPI),TRUE)
gb_EMSCRIPTEN_LDFLAGS += -sJSPI
endif
ifeq ($(ENABLE_EMSCRIPTEN_PROXY_POSIX_SOCKETS),TRUE)
gb_EMSCRIPTEN_LDFLAGS += -sPROXY_POSIX_SOCKETS -lwebsocket.js
endif

View file

@ -53,6 +53,7 @@
#include <vclpluginapi.h>
#include <tools/debug.hxx>
#include <comphelper/flagguard.hxx>
#include <config_emscripten.h>
#include <config_vclplug.h>
#include <dndhelper.hxx>
#include <vcl/qt/QtUtils.hxx>
@ -298,7 +299,7 @@ QtInstance::QtInstance(std::unique_ptr<QApplication>& pQApp)
#ifndef EMSCRIPTEN
m_bSupportsOpenGL = true;
#else
#elif !HAVE_EMSCRIPTEN_JSPI
ImplGetSVData()->maAppData.m_bUseSystemLoop = true;
#endif
}