config_host.mk.in                              |    1 
 configure.ac                                   |   37 +++----------------------
 solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk |   15 ----------
 static/README.wasm.md                          |   21 --------------
 unotest/source/embindtest/embindtest.js        |   18 ++----------
 5 files changed, 11 insertions(+), 81 deletions(-)

New commits:
commit 22ce8ed05be37d676739a578b05cc5217109fd87
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Tue May 28 15:16:32 2024 +0200
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Wed May 29 08:01:38 2024 +0200

    Emscripten: Unconditional --enable-wasm-exceptions
    
    (...which will be beneficial, in turn, to implement exception handling in 
the
    work-in-progress bridges/source/cpp_uno/gcc3_wasm UNO bridge).
    
    As per
    
<https://developer.mozilla.org/en-US/docs/WebAssembly#browser_compatibility>,
    Wasm exceptions appear to be supported by most if not all relevant engines 
by
    now.
    
    * Lets see whether the "Note that to really use WASM exceptions everywhere" 
for
    external libraries in solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk does 
have
    any practical consequences (but ignoring it for now).
    
    * This change depends on the preceding 
77129fbb74bcefde4551d494f029169e7c6026e3
    "Emscripten: Add hack to prepare for --enable-wasm-exceptions" to work 
around
    the issue that was mentioned in static/README.wasm.md.
    
    * In unotest/source/embindtest/embindtest.js, getExceptionMessage started to
    work now, no longer exhibiting the RuntimeError that had been documented 
there
    for non-Wasm-based exceptions.
    
    Change-Id: Ifa2165b62208cc927844684911ddf21a4a2b624f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168169
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/config_host.mk.in b/config_host.mk.in
index 92ae275b43d5..334d9fd53f16 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -230,7 +230,6 @@ export ENABLE_SKIA=@ENABLE_SKIA@
 export ENABLE_SKIA_DEBUG=@ENABLE_SKIA_DEBUG@
 export ENABLE_SYMBOLS_FOR=@ENABLE_SYMBOLS_FOR@
 export ENABLE_VALGRIND=@ENABLE_VALGRIND@
-export ENABLE_WASM_EXCEPTIONS=@ENABLE_WASM_EXCEPTIONS@
 export ENABLE_WASM_STRIP_ACCESSIBILITY=@ENABLE_WASM_STRIP_CALC@
 export ENABLE_WASM_STRIP_BASIC_DRAW_MATH_IMPRESS=@ENABLE_WASM_STRIP@
 export ENABLE_WASM_STRIP_WRITER=@ENABLE_WASM_STRIP_WRITER@
diff --git a/configure.ac b/configure.ac
index 22c95079f2d8..900f8227c01f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1431,9 +1431,9 @@ dnl 
===================================================================
 dnl Sanity checks for Emscripten SDK setup
 dnl ===================================================================
 
-EMSCRIPTEN_MIN_MAJOR=2
-EMSCRIPTEN_MIN_MINOR=0
-EMSCRIPTEN_MIN_TINY=32
+EMSCRIPTEN_MIN_MAJOR=3
+EMSCRIPTEN_MIN_MINOR=1
+EMSCRIPTEN_MIN_TINY=3
 
EMSCRIPTEN_MIN_VERSION="${EMSCRIPTEN_MIN_MAJOR}.${EMSCRIPTEN_MIN_MINOR}.${EMSCRIPTEN_MIN_TINY}"
 
 if test "$_os" = "Emscripten"; then
@@ -2148,13 +2148,6 @@ AC_ARG_WITH(main-module,
         Default value is 'writer'.]),
 ,)
 
-AC_ARG_ENABLE(wasm-exceptions,
-    AS_HELP_STRING([--enable-wasm-exceptions],
-        [Build with native WASM exceptions (AKA -fwasm-exceptions),
-        matter of fact, this is currently not finished by any implementation)
-        (see https://webassembly.org/roadmap/ for the current state]),
-,)
-
 AC_ARG_ENABLE(xmlhelp,
     AS_HELP_STRING([--disable-xmlhelp],
         [Disable XML help support]),
@@ -3249,23 +3242,6 @@ if test "$enable_wasm_strip" = "yes"; then
     AC_DEFINE(ENABLE_WASM_STRIP_SCEXPORTS)
 fi
 
-EMSCRIPTEN_NEH_MAJOR=3
-EMSCRIPTEN_NEH_MINOR=1
-EMSCRIPTEN_NEH_TINY=3
-EMSCRIPTEN_NEH_VERSION="${EMSCRIPTEN_NEH_MAJOR}.${EMSCRIPTEN_NEH_MINOR}.${EMSCRIPTEN_NEH_TINY}"
-
-if test "$enable_wasm_exceptions" = yes; then
-    AC_MSG_CHECKING([if Emscripten version is at least $EMSCRIPTEN_NEH_VERSION 
for SjLj + native EH])
-    check_semantic_version_three_prefixed EMSCRIPTEN NEH
-    if test $? -ne 0; then
-        AC_MSG_ERROR([no, found $EMSCRIPTEN_VERSION])
-    else
-        AC_MSG_RESULT([yes ($EMSCRIPTEN_VERSION)])
-    fi
-    ENABLE_WASM_EXCEPTIONS=TRUE
-fi
-AC_SUBST(ENABLE_WASM_EXCEPTIONS)
-
 # Whether to build "avmedia" functionality or not.
 
 if test "$enable_avmedia" = yes; then
@@ -6407,7 +6383,7 @@ if test -z "$enable_pch"; then
         enable_pch=no
     fi
 fi
-if test "$enable_pch" != no -a "$_os" = Emscripten -a 
"$ENABLE_WASM_EXCEPTIONS" = TRUE; then
+if test "$enable_pch" != no -a "$_os" = Emscripten; then
     AC_MSG_ERROR([PCH currently isn't supported for Emscripten with native EH 
(nEH) because of missing Sj/Lj support with nEH in clang.])
 fi
 if test "$enable_pch" != "no" -a "$_os" != "WINNT" -a "$GCC" != "yes" ; then
@@ -13368,12 +13344,9 @@ then
             AC_MSG_ERROR([No Qt5 WASM libQt5Gui.a in ${qt5_libdir}])
         fi
         QT5_WASM_SJLJ="`${EMSDK_LLVM_NM} "${qt5_libdir}"/libQt5Gui.a 
2>/dev/null | $GREP emscripten_longjmp`"
-        if test "$ENABLE_WASM_EXCEPTIONS" = TRUE -a -n "$QT5_WASM_SJLJ"; then
+        if test -n "$QT5_WASM_SJLJ"; then
             AC_MSG_ERROR(['emscripten_longjmp' symbol found in libQt5Gui.a 
(missing '-s SUPPORT_LONGJMP=wasm'). See static/README.wasm.md.])
         fi
-        if test "$ENABLE_WASM_EXCEPTIONS" != TRUE -a -z "$QT5_WASM_SJLJ"; then
-            AC_MSG_ERROR(['emscripten_longjmp' symbol not found in 
libQt5Gui.a. You probably use an incompatible Qt build with '-s 
SUPPORT_LONGJMP=wasm'.])
-        fi
     fi
 
     QT5_CFLAGS="-I$qt5_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT 
-DQT_NO_VERSION_TAGGING"
diff --git a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk 
b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
index 7cd4d3c6fa02..fb186a5fe7c0 100644
--- a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
+++ b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
@@ -11,7 +11,7 @@ include $(GBUILDDIR)/platform/unxgcc.mk
 
 gb_RUN_CONFIGURE := $(SRCDIR)/solenv/bin/run-configure
 # avoid -s SAFE_HEAP=1 - c.f. gh#8584 this breaks source maps
-gb_EMSCRIPTEN_CPPFLAGS := -pthread -s USE_PTHREADS=1 -D_LARGEFILE64_SOURCE 
-D_LARGEFILE_SOURCE
+gb_EMSCRIPTEN_CPPFLAGS := -pthread -s USE_PTHREADS=1 -D_LARGEFILE64_SOURCE 
-D_LARGEFILE_SOURCE -s SUPPORT_LONGJMP=wasm
 gb_EMSCRIPTEN_LDFLAGS := $(gb_EMSCRIPTEN_CPPFLAGS)
 
 # Initial memory size and worker thread pool
@@ -24,26 +24,13 @@ gb_EMSCRIPTEN_LDFLAGS += --bind -s FORCE_FILESYSTEM=1 -s 
WASM_BIGINT=1 -s ERROR_
 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
 
 gb_Executable_EXT := .html
-ifeq ($(ENABLE_WASM_EXCEPTIONS),TRUE)
-# Note that to really use WASM exceptions everywhere, you most probably want 
to also use
-# CC=emcc -pthread -s USE_PTHREADS=1 -fwasm-exceptions -s SUPPORT_LONGJMP=wasm
-# and CXX=em++ -pthread -s USE_PTHREADS=1 -fwasm-exceptions -s 
SUPPORT_LONGJMP=wasm
-# in your autogen.input. Otherwise these flags won't propagate to all external 
libraries, I fear.
 gb_EMSCRIPTEN_EXCEPT = -fwasm-exceptions -s SUPPORT_LONGJMP=wasm
-gb_EMSCRIPTEN_CPPFLAGS += -s SUPPORT_LONGJMP=wasm
-else
-gb_EMSCRIPTEN_EXCEPT = -s DISABLE_EXCEPTION_CATCHING=0
-endif
 
 gb_CXXFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS)
 
-ifeq ($(ENABLE_WASM_EXCEPTIONS),TRUE)
 # Here we don't use += because gb_LinkTarget_EXCEPTIONFLAGS from 
com_GCC_defs.mk contains -fexceptions and
 # gb_EMSCRIPTEN_EXCEPT already has -fwasm-exceptions
 gb_LinkTarget_EXCEPTIONFLAGS = $(gb_EMSCRIPTEN_EXCEPT)
-else
-gb_LinkTarget_EXCEPTIONFLAGS += $(gb_EMSCRIPTEN_EXCEPT)
-endif
 
 gb_LinkTarget_CFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS)
 gb_LinkTarget_CXXFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS) $(gb_EMSCRIPTEN_EXCEPT)
diff --git a/static/README.wasm.md b/static/README.wasm.md
index 97be5a14123b..5a247b085a0d 100644
--- a/static/README.wasm.md
+++ b/static/README.wasm.md
@@ -63,7 +63,7 @@ With "-opensource -confirm-license" you agree to the open 
source license.
     cd qt5
     git checkout v5.15.2+wasm
     ./init-repository --module-subset=qtbase
-    ./configure -opensource -confirm-license -xplatform wasm-emscripten 
-feature-thread -prefix <whatever>
+    ./configure -opensource -confirm-license -xplatform wasm-emscripten 
-feature-thread -prefix <whatever> QMAKE_CFLAGS+=-sSUPPORT_LONGJMP=wasm 
QMAKE_CXXFLAGS+=-sSUPPORT_LONGJMP=wasm
     make -j<CORES> module-qtbase
 
 Optionally you can add the configure flag "-compile-examples". But then you 
also have to
@@ -116,25 +116,6 @@ FWIW: it's also possible to build an almost static Linux 
LibreOffice by just usi
 --disable-dynloading --enable-customtarget-components. System externals are 
still
 linked dynamically, but everything else is static.
 
-#### Experimental (AKA currently broken) WASM exception + SjLj build
-
-You can build LO with WASM exceptions, which should be "much" faster then the 
JS
-based Emscripten EH handling. For setjmp / longjmp (SjLj) used by the PNG and 
JPEG
-libraries error handling, this needs Emscripten 3.1.3+. That builds, but 
execution
-still fails early with a signature mismatch call to Task::UpdateMinPeriod in 
LO's
-job scheduler code (concretely: the call to 
`pSchedulerData->mpTask->UpdateMinPeriod` in
-`Scheduler::CallbackTaskScheduling` in vcl/source/app/scheduler.cxx being a 
pure virtual call on a
-destroyed `desktop::Desktop::m_firstRunTimer` instance, because 
`desktop::Desktop aDesktop` in
-`soffice_main` in desktop/source/app/sofficemain.cxx gets destroyed early, for 
unclear reasons).
-Unfortunately the build also needs a Qt build with
-"-s SUPPORT_LONGJMP=wasm", which is incompatible with the JS EH + SjLj.
-
-The LO configure flag is simply an additional --enable-wasm-exceptions. Qt5 can
-be patched in qtbase/mkspecs/wasm-emscripten/qmake.conf with the addition of
-
-    QMAKE_CFLAGS += -s SUPPORT_LONGJMP=wasm
-    QMAKE_CXXFLAGS += -s SUPPORT_LONGJMP=wasm
-
 ### "Deploying" soffice.wasm
 
     tar -chf wasm.tar --xform 's/.*program/lo-wasm/' instdir/program/soffice.* 
\
diff --git a/unotest/source/embindtest/embindtest.js 
b/unotest/source/embindtest/embindtest.js
index 87d3d2fc281c..cdd214f08fd5 100644
--- a/unotest/source/embindtest/embindtest.js
+++ b/unotest/source/embindtest/embindtest.js
@@ -635,20 +635,10 @@ Module.addOnPostRun(function() {
         test.throwRuntimeException();
         console.assert(false);
     } catch (e) {
-        incrementExceptionRefcount(e);
-            //TODO, needed when building with JS-based -fexceptions, see
-            // <https://github.com/emscripten-core/emscripten/issues/17115> 
"[EH] Fix inconsistency
-            // of refcounting in Emscripten EH vs. Wasm EH"
-        //TODO: The recommended way to obtain the exception's type and message 
would reportedly
-        // (<https://emscripten.org/docs/porting/exceptions.html#
-        // handling-c-exceptions-from-javascript>) be
-        //   const [type, message] = getExceptionMessage(e);
-        // but that causes a "RuntimeError: memory access out of bounds" from 
within
-        // getExceptionMessage -> getExceptionMessageCommon -> 
__get_exception_message at least with
-        // emsdk 3.1.46:
-        console.assert(e.name === 'com::sun::star::uno::RuntimeException');
-        console.assert(e.message === undefined); //TODO
-        //TODO: console.assert(e.Message.startsWith('test'));
+        const [type, message] = getExceptionMessage(e);
+        console.assert(type === 'com::sun::star::uno::RuntimeException');
+        console.assert(message === undefined); //TODO
+        //TODO: verify css.uno.RuntimeException's Message startsWith('test')
         decrementExceptionRefcount(e);
     }
     const obj = {

Reply via email to