Make --disable-emscripten-proxy-to-pthread configurable

...as is convenient for some experiments

Change-Id: I74aedb38ecc0f7b5a0d913799f649dce77dc7bba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174753
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Stephan Bergmann 2024-10-09 19:00:21 +02:00
parent e9dcbf84f9
commit 33aa490cd6
6 changed files with 37 additions and 2 deletions

View file

@ -176,6 +176,7 @@ ENABLE_DOTNET=@ENABLE_DOTNET@
SYSTEM_DRAGONBOX=@SYSTEM_DRAGONBOX@
SYSTEM_FROZEN=@SYSTEM_FROZEN@
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@
export ENABLE_EOT=@ENABLE_EOT@
export ENABLE_EVOAB2=@ENABLE_EVOAB2@

View file

@ -11,4 +11,6 @@
#define HAVE_EMSCRIPTEN_PROXY_POSIX_SOCKETS 0
#define HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD 0
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

View file

@ -2167,6 +2167,15 @@ AC_ARG_WITH(main-module,
Default value is 'writer'.]),
,)
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.]),,
enable_emscripten_proxy_to_pthread=yes)
else
enable_emscripten_proxy_to_pthread=
fi
if test "$_os" = Emscripten; then
AC_ARG_ENABLE(emscripten-proxy-posix-sockets,
AS_HELP_STRING([--enable-emscripten-proxy-posix-sockets],
@ -4177,6 +4186,14 @@ AC_SUBST(ENABLE_WASM_STRIP)
AC_SUBST(ENABLE_WASM_STRIP_WRITER)
AC_SUBST(ENABLE_WASM_STRIP_CALC)
if test "$enable_emscripten_proxy_to_pthread" = yes; then
ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD=TRUE
AC_DEFINE(HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD)
else
ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD=
fi
AC_SUBST(ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD)
if test "$enable_emscripten_proxy_posix_sockets" = yes; then
ENABLE_EMSCRIPTEN_PROXY_POSIX_SOCKETS=TRUE
AC_DEFINE(HAVE_EMSCRIPTEN_PROXY_POSIX_SOCKETS)

View file

@ -63,8 +63,10 @@ $(call gb_Executable_get_linktarget_target,soffice_bin): \
$(eval $(call gb_Executable_add_ldflags,soffice_bin,\
-s EXPORTED_FUNCTIONS=@$(gb_CustomTarget_workdir)/desktop/soffice_bin-emscripten-exports/exports -Wl$(COMMA)--whole-archive $(call gb_StaticLibrary_get_target,unoembind) -Wl$(COMMA)--no-whole-archive \
$(if $(ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD), \
-sPROXY_TO_PTHREAD=1 \
$(if $(DISABLE_GUI),,-sOFFSCREENCANVAS_SUPPORT=1 -sOFFSCREENCANVASES_TO_PTHREAD=\#qtcanvas) \
$(if $(DISABLE_GUI),, \
-sOFFSCREENCANVAS_SUPPORT=1 -sOFFSCREENCANVASES_TO_PTHREAD=\#qtcanvas)) \
))
ifeq ($(ENABLE_QT6),TRUE)
$(eval $(call gb_Executable_add_ldflags,soffice_bin, \

View file

@ -54,6 +54,7 @@
#include <emscripten/threading.h>
#include <emscripten/val.h>
#include <bindings_uno.hxx>
#include <config_emscripten.h>
#endif
using namespace ::com::sun::star::uno;
@ -94,12 +95,20 @@ EM_JS(void, setupMainChannel, (), {
});
extern "C" void resolveUnoMain(pthread_t id) {
#if HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD
EM_ASM({
const sofficeMain = PThread.pthreads[$0];
const channel = new MessageChannel();
sofficeMain.postMessage({cmd:"LOWA-channel"}, [channel.port2]);
Module.uno_main$resolve(channel.port1);
}, id);
#else
EM_ASM({
const channel = new MessageChannel();
postMessage({cmd:"LOWA-channel"}, [channel.port2]);
Module.uno_main$resolve(channel.port1);
}, id);
#endif
}
void initUno() {

View file

@ -17,6 +17,10 @@ gb_EMSCRIPTEN_LDFLAGS := $(gb_EMSCRIPTEN_CPPFLAGS)
# Initial memory size
gb_EMSCRIPTEN_LDFLAGS += -s TOTAL_MEMORY=1GB
ifeq ($(ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD),)
gb_EMSCRIPTEN_LDFLAGS += -sPTHREAD_POOL_SIZE=6
endif
# Double the main thread stack size, but keep the default value for other threads:
gb_EMSCRIPTEN_LDFLAGS += -sSTACK_SIZE=131072 -sDEFAULT_PTHREAD_STACK_SIZE=65536