config_host.mk.in                              |    1 +
 configure.ac                                   |   15 +++++++++++++++
 solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk |    9 +++++++--
 vcl/Library_vcl.mk                             |   16 ++++++++++++++--
 4 files changed, 37 insertions(+), 4 deletions(-)

New commits:
commit ae22f7d06246ee21f9c8e9f35f4477e88843c58b
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Sat Oct 2 12:43:07 2021 +0200
Commit:     Jan-Marek Glogowski <glo...@fbihome.de>
CommitDate: Wed Jan 19 16:13:14 2022 +0100

    WASM add option to build with native exceptions
    
    Currently disabled, as literally no runtime has a working
    implementation. It also currently conflicts with LLVM's SjLj
    (AKA setjmp / longjump) when generating WASM bytecode, but
    the only offending code doesn't use exceptions, so this can
    be avoided in general.
    
    Change-Id: I2b338f3529e7350d54a7950772c6e7aae2282fe7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128600
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de>

diff --git a/config_host.mk.in b/config_host.mk.in
index 6eae920612f0..89b433e47168 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -210,6 +210,7 @@ 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=@ENABLE_WASM_STRIP@
 export ENABLE_WERROR=@ENABLE_WERROR@
 export ENABLE_Z7_DEBUG=@ENABLE_Z7_DEBUG@
diff --git a/configure.ac b/configure.ac
index be3e9072195a..0b3dbd5e42fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1990,6 +1990,13 @@ AC_ARG_ENABLE(wasm-strip,
         [Strip the static build like for WASM/emscripten platform.]),
 ,)
 
+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]),
@@ -3008,6 +3015,11 @@ if test "$enable_wasm_strip" = "yes"; then
     test "${with_locales+set}" = set || with_locales=en
 fi
 
+if test "$enable_wasm_exceptions" = yes; then
+    ENABLE_WASM_EXCEPTIONS=TRUE
+fi
+AC_SUBST(ENABLE_WASM_EXCEPTIONS)
+
 # Whether to build "avmedia" functionality or not.
 
 if test "$enable_avmedia" = yes; then
@@ -6029,6 +6041,9 @@ 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
+    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
     AC_MSG_ERROR([Precompiled header not yet supported for your 
platform/compiler])
 fi
diff --git a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk 
b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
index 68ad8ec4be69..f0063f7c07b1 100644
--- a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
+++ b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
@@ -31,11 +31,16 @@ 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 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG 
-DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
 
 gb_Executable_EXT := .html
-gb_EMSCRIPTEN_EXCEPT := -s DISABLE_EXCEPTION_CATCHING=0
+ifeq ($(ENABLE_WASM_EXCEPTIONS),TRUE)
+gb_EMSCRIPTEN_EXCEPT = -fwasm-exceptions
+else
+gb_EMSCRIPTEN_EXCEPT = -s DISABLE_EXCEPTION_CATCHING=0
+endif
 
 gb_CXXFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS)
+gb_LinkTarget_EXCEPTIONFLAGS += $(gb_EMSCRIPTEN_EXCEPT)
 gb_LinkTarget_CFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS) $(gb_EMSCRIPTEN_QTDEFS)
-gb_LinkTarget_CXXFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS) $(gb_EMSCRIPTEN_QTDEFS) 
$(gb_EMSCRIPTEN_EXCEPT)
+gb_LinkTarget_CXXFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS) $(gb_EMSCRIPTEN_QTDEFS)
 gb_LinkTarget_LDFLAGS += $(gb_EMSCRIPTEN_LDFLAGS) $(gb_EMSCRIPTEN_CPPFLAGS) 
$(gb_EMSCRIPTEN_EXCEPT)
 
 # Linker and compiler optimize + debug flags are handled in LinkTarget.mk
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 7664927c257a..4c3abf6f08e9 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -93,6 +93,20 @@ $(eval $(call gb_Library_use_externals,vcl,\
     mdds_headers \
 ))
 
+# WASM LLVM doesn't support native EH + SjLj (setjump / longjump) used by 
libjpeg / libpng.
+# This otherwise breaks the PCH generation, so just move the files for that 
case.
+ifeq (EMSCRIPTEN_TRUE,$(OS)_$(ENABLE_WASM_EXCEPTIONS))
+$(eval $(call gb_Library_add_cxxobjects,vcl,\
+    vcl/source/filter/jpeg/jpegc \
+    vcl/source/filter/png/PngImageReader \
+))
+else
+$(eval $(call gb_Library_add_exception_objects,vcl,\
+    vcl/source/filter/jpeg/jpegc \
+    vcl/source/filter/png/PngImageReader \
+))
+endif
+
 $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/rendercontext/drawmode \
     vcl/skia/SkiaHelper \
@@ -459,7 +473,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/filter/ixpm/xpmread \
     vcl/source/filter/jpeg/Exif \
     vcl/source/filter/jpeg/jpeg \
-    vcl/source/filter/jpeg/jpegc \
     vcl/source/filter/jpeg/JpegReader \
     vcl/source/filter/jpeg/JpegWriter \
     vcl/source/filter/jpeg/JpegTransform \
@@ -470,7 +483,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/filter/wmf/wmf \
     vcl/source/filter/wmf/wmfexternal \
     vcl/source/filter/wmf/wmfwr \
-    vcl/source/filter/png/PngImageReader \
     vcl/source/filter/png/pngwrite \
     vcl/source/font/DirectFontSubstitution \
     vcl/source/font/Feature \

Reply via email to