RepositoryFixes.mk | 4 ---- config_host.mk.in | 1 + config_host/config_emscripten.h.in | 2 ++ configure.ac | 17 +++++++++++++++++ desktop/Executable_soffice_bin.mk | 6 ++++-- desktop/source/app/appinit.cxx | 9 +++++++++ instsetoo_native/CustomTarget_emscripten-install.mk | 3 +-- solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk | 8 +++++--- solenv/gbuild/platform/unxgcc.mk | 4 ++-- 9 files changed, 41 insertions(+), 13 deletions(-)
New commits: commit 2257282a4cac8245c8055df0329dd9c918751207 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Wed Oct 9 19:00:21 2024 +0200 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Mon Oct 14 08:06:04 2024 +0200 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.bergm...@allotropia.de> Tested-by: Jenkins (cherry picked from commit 33aa490cd6c18474f83ddd2b5f91ffc5c42a34d9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174679 Tested-by: allotropia jenkins <jenk...@allotropia.de> diff --git a/config_host.mk.in b/config_host.mk.in index a2a7f7b21c41..c95e9141f04f 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -167,6 +167,7 @@ export ENABLE_DEBUG=@ENABLE_DEBUG@ 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@ diff --git a/config_host/config_emscripten.h.in b/config_host/config_emscripten.h.in index 24d1a9ca5dd8..d8121613a934 100644 --- a/config_host/config_emscripten.h.in +++ b/config_host/config_emscripten.h.in @@ -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: */ diff --git a/configure.ac b/configure.ac index 8b3db0f48339..712cefcca6e8 100644 --- a/configure.ac +++ b/configure.ac @@ -2144,6 +2144,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], @@ -4114,6 +4123,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) diff --git a/desktop/Executable_soffice_bin.mk b/desktop/Executable_soffice_bin.mk index fcf16e041fb9..a791e8f362e4 100644 --- a/desktop/Executable_soffice_bin.mk +++ b/desktop/Executable_soffice_bin.mk @@ -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 \ - -sPROXY_TO_PTHREAD=1 \ - $(if $(DISABLE_GUI),,-sOFFSCREENCANVAS_SUPPORT=1 -sOFFSCREENCANVASES_TO_PTHREAD=\#qtcanvas) \ + $(if $(ENABLE_EMSCRIPTEN_PROXY_TO_PTHREAD), \ + -sPROXY_TO_PTHREAD=1 \ + $(if $(DISABLE_GUI),, \ + -sOFFSCREENCANVAS_SUPPORT=1 -sOFFSCREENCANVASES_TO_PTHREAD=\#qtcanvas)) \ )) ifeq ($(ENABLE_QT6),TRUE) $(eval $(call gb_Executable_add_ldflags,soffice_bin, \ diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index ad2c25f64dab..f1c821a5297e 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -55,6 +55,7 @@ #include <emscripten/threading.h> #include <emscripten/val.h> #include <bindings_uno.hxx> +#include <config_emscripten.h> #endif using namespace ::com::sun::star::uno; @@ -97,12 +98,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() { diff --git a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk index 2b55b4ba1218..4951bb1cae03 100644 --- a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk +++ b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk @@ -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 commit 596a79e798c8faa3e91a9696ea5d5939e0ed9e3c Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Wed Oct 9 16:18:35 2024 +0200 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Mon Oct 14 08:05:51 2024 +0200 Emscripten: For executables, only build .js files, not .html files ...as for the by-default --enable-qt5 case we generate an additional qt_soffice.html anyway (and for a --disable-gui --disable-qt5 build, client code probably wants to embed the results into its own HTML document and wouldn't rely on an soffice.html); this simplifies the build infrastructure a little Change-Id: Ib50799b5dd2fcfeb680f257f46ff65775dcddd71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174725 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> (cherry picked from commit ce8ac330eb4d995f29be4a4e12ef5f63481dcd03) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174678 Tested-by: allotropia jenkins <jenk...@allotropia.de> diff --git a/RepositoryFixes.mk b/RepositoryFixes.mk index 2139b2f823ff..4cacbbce35b9 100644 --- a/RepositoryFixes.mk +++ b/RepositoryFixes.mk @@ -35,12 +35,8 @@ ifeq ($(OS),MACOSX) gb_Executable_FILENAMES := $(patsubst soffice_bin:soffice_bin,soffice_bin:soffice,$(gb_Executable_FILENAMES)) else ifeq ($(OS),EMSCRIPTEN) -ifeq ($(ENABLE_QT6),TRUE) gb_Executable_FILENAMES := $(patsubst soffice_bin:soffice_bin%,soffice_bin:soffice.js,$(gb_Executable_FILENAMES)) else -gb_Executable_FILENAMES := $(patsubst soffice_bin:soffice_bin%,soffice_bin:soffice.html,$(gb_Executable_FILENAMES)) -endif -else gb_Executable_FILENAMES := $(patsubst soffice_bin:soffice_bin%,soffice_bin:soffice.bin,$(gb_Executable_FILENAMES)) endif endif diff --git a/instsetoo_native/CustomTarget_emscripten-install.mk b/instsetoo_native/CustomTarget_emscripten-install.mk index f4e63f729ab6..b81d510523a7 100644 --- a/instsetoo_native/CustomTarget_emscripten-install.mk +++ b/instsetoo_native/CustomTarget_emscripten-install.mk @@ -20,8 +20,7 @@ emscripten_install_files := \ soffice.wasm \ soffice.worker.js \ $(if $(ENABLE_SYMBOLS_FOR),soffice.wasm.dwp) \ - $(if $(DISABLE_GUI), \ - soffice.html, \ + $(if $(DISABLE_GUI),, \ qt_soffice.html \ qtloader.js \ qtlogo.svg) \ diff --git a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk index 227ef83990de..2b55b4ba1218 100644 --- a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk +++ b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk @@ -30,7 +30,7 @@ ifeq ($(ENABLE_EMSCRIPTEN_PROXY_POSIX_SOCKETS),TRUE) gb_EMSCRIPTEN_LDFLAGS += -sPROXY_POSIX_SOCKETS -lwebsocket.js endif -gb_Executable_EXT := .html +gb_Executable_EXT := .js gb_EMSCRIPTEN_EXCEPT = -fwasm-exceptions -s SUPPORT_LONGJMP=wasm gb_CXXFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS) @@ -77,7 +77,6 @@ define gb_Executable_Executable_platform $(call gb_LinkTarget_add_auxtargets,$(2),\ $(patsubst %.lib,%.linkdeps,$(3)) \ $(patsubst %.lib,%.wasm,$(3)) \ - $(patsubst %.lib,%.js,$(3)) \ $(patsubst %.lib,%.worker.js,$(3)) \ $(patsubst %.lib,%.wasm.dwp,$(3)) \ ) @@ -88,7 +87,6 @@ define gb_CppunitTest_CppunitTest_platform $(call gb_LinkTarget_add_auxtargets,$(2),\ $(patsubst %.lib,%.linkdeps,$(3)) \ $(patsubst %.lib,%.wasm,$(3)) \ - $(patsubst %.lib,%.js,$(3)) \ $(patsubst %.lib,%.worker.js,$(3)) \ $(patsubst %.lib,%.wasm.dwp,$(3)) \ ) diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk index 0e4f01b4249e..1c289b193d4e 100644 --- a/solenv/gbuild/platform/unxgcc.mk +++ b/solenv/gbuild/platform/unxgcc.mk @@ -171,7 +171,7 @@ $(call gb_Helper_abbreviate_dirs,\ ) \ -o $(1) \ $(if $(SOVERSIONSCRIPT),&& ln -sf ../../program/$(notdir $(1)) $(ILIBTARGET)) \ - $(if $(filter EMSCRIPTEN,$(OS)),$(if $(filter TRUE,$(HAVE_EXTERNAL_DWARF)),&& emdwp -e $(patsubst %.html,%.wasm,$(1)) -o $(patsubst %.html,%.wasm.dwp,$(1)))) \ + $(if $(filter EMSCRIPTEN,$(OS)),$(if $(filter TRUE,$(HAVE_EXTERNAL_DWARF)),&& emdwp -e $(patsubst %$(gb_Executable_EXT),%.wasm,$(1)) -o $(patsubst %$(gb_Executable_EXT),%.wasm.dwp,$(1)))) \ $(if $(call gb_LinkTarget__WantLock,$(2)),; RC=$$? ; rm -f $(gb_LinkTarget__Lock); if test $$RC -ne 0; then exit $$RC; fi)) $(if $(filter Library,$(TARGETTYPE)), $(call gb_Helper_abbreviate_dirs,\ @@ -182,7 +182,7 @@ $(if $(filter Library,$(TARGETTYPE)), $(call gb_Helper_abbreviate_dirs,\ $(WORKDIR)/LinkTarget/$(2).exports,$(1)))) $(if $(and $(filter CppunitTest Executable,$(TARGETTYPE)),$(filter EMSCRIPTEN,$(OS))), \ $(if $(filter TRUE,$(ENABLE_QT5)), \ - sed -e 's/@APPNAME@/$(subst $(gb_Executable_EXT),,$(notdir $(1)))/' $(QT5_PLATFORMS_SRCDIR)/wasm_shell.html > $(dir $(1))qt_$(notdir $(1)) && \ + sed -e 's/@APPNAME@/$(subst $(gb_Executable_EXT),,$(notdir $(1)))/' $(QT5_PLATFORMS_SRCDIR)/wasm_shell.html > $(dir $(1))qt_$(basename $(notdir $(1))).html && \ cp $(QT5_PLATFORMS_SRCDIR)/qtlogo.svg $(QT5_PLATFORMS_SRCDIR)/qtloader.js $(dir $(1)) && \ ,$(if $(filter TRUE,$(ENABLE_QT6)), \ sed -e 's/@APPNAME@/$(basename $(notdir $(1)))/g' -e 's/@APPEXPORTNAME@/$(basename $(notdir $(1)))_entry/g' -e 's/@PRELOAD@//g' -e 's/}$(CLOSE_PAREN);$$/}$(CLOSE_PAREN); window.Module = instance;/' $(QT6_PLATFORMS_SRCDIR)/wasm_shell.html > $(dir $(1))qt_$(basename $(notdir $(1))).html && \