summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-11-04 17:46:47 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-11-04 20:47:05 +0100
commitf510ce620fba08e6aa8bc40af2e47f0b51caa66d (patch)
tree864acbcb920529e4e0e673ba7d7055e54a3decb7
parent060d2fe39f27ffbb0e843de5031f6806c9abfce8 (diff)
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>
-rw-r--r--config_host.mk.in1
-rw-r--r--config_host/config_emscripten.h.in2
-rw-r--r--configure.ac16
-rw-r--r--solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk4
-rw-r--r--vcl/qt5/QtInstance.cxx3
5 files changed, 25 insertions, 1 deletions
diff --git a/config_host.mk.in b/config_host.mk.in
index 20c027405df2..78874b1ee149 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -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@
diff --git a/config_host/config_emscripten.h.in b/config_host/config_emscripten.h.in
index d8121613a934..c42a43c31e76 100644
--- a/config_host/config_emscripten.h.in
+++ b/config_host/config_emscripten.h.in
@@ -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
diff --git a/configure.ac b/configure.ac
index b1bdb7ef6030..01cb56658cff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2181,6 +2181,14 @@ AC_ARG_WITH(main-module,
,)
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],
[Experimentally disable use of the Emscripten -sPROXY_TO_PTHREAD feature.]),,
@@ -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)
diff --git a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
index 4426deba0d02..4165281d1c09 100644
--- a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
+++ b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
@@ -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
diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx
index fe6fd90d0bea..b6b31366abfa 100644
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -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
}