diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-04-23 13:45:05 +0200 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2021-05-05 21:14:54 +0200 |
commit | 8a4173987edfeeb7e49c70617d43e3adc911d333 (patch) | |
tree | 24360e0c3fe2b2138f9a291f143f9a6667c53510 /solenv | |
parent | 013ddc4f5307df512767ca23b3922540b2b36d52 (diff) |
WASM: add initial support for Emscripten cross build
- configure with:
- --host=wasm64-local-emscripten
- had to make a few externals optional, so adding:
- --disable-nss
- --disable-cmis
- --disable-curl
Change-Id: I48d1c73d2675ad2e2beaf2c341578199efbd24ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111130
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'solenv')
-rwxr-xr-x | solenv/bin/run-configure | 9 | ||||
-rw-r--r-- | solenv/gbuild/gbuild.mk | 2 | ||||
-rw-r--r-- | solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk | 64 | ||||
-rw-r--r-- | solenv/gbuild/platform/com_GCC_defs.mk | 9 |
4 files changed, 81 insertions, 3 deletions
diff --git a/solenv/bin/run-configure b/solenv/bin/run-configure new file mode 100755 index 000000000000..9758ff1d86c6 --- /dev/null +++ b/solenv/bin/run-configure @@ -0,0 +1,9 @@ +#!/bin/sh + +# We could run emconfigure here, but LO's gbuild should have set up everything +# correctly. If something breaks because of this, we likely have mre problems. +if test "$OS" = "EMSCRIPTEN"; then + export EMMAKEN_JUST_CONFIGURE=1 +fi + +exec "$@" diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk index fa5c767271b7..1afa9e0451af 100644 --- a/solenv/gbuild/gbuild.mk +++ b/solenv/gbuild/gbuild.mk @@ -191,6 +191,7 @@ include $(SRCDIR)/RepositoryExternal.mk $(eval $(call gb_Helper_collect_knownlibs)) gb_Library_DLLPOSTFIX := lo +gb_RUN_CONFIGURE := # Include platform/cpu/compiler specific config/definitions @@ -278,6 +279,7 @@ gb_TEST_ENV_VARS += SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION=1 ifeq (,$(SAL_USE_VCLPLUGIN)) gb_TEST_ENV_VARS += SAL_USE_VCLPLUGIN=svp endif +gb_TEST_ENV_VARS += UNO_HOME=file://$$I/program # This is used to detect whether LibreOffice is being built (as opposed to building # 3rd-party code). Used for tag deprecation for API we want to diff --git a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk new file mode 100644 index 000000000000..3131bbec0959 --- /dev/null +++ b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk @@ -0,0 +1,64 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2)) + +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 TOTAL_MEMORY=1GB -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 +gb_EMSCRIPTEN_LDFLAGS := $(gb_EMSCRIPTEN_CPPFLAGS) --bind -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s FETCH=1 -s ASSERTIONS=2 -s EXIT_RUNTIME=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=["UTF16ToString","stringToUTF16"] +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 + +gb_LinkTarget_CFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS) $(gb_EMSCRIPTEN_QTDEFS) +gb_LinkTarget_CXXFLAGS += $(gb_EMSCRIPTEN_CPPFLAGS) $(gb_EMSCRIPTEN_QTDEFS) $(gb_EMSCRIPTEN_EXCEPT) +gb_LinkTarget_LDFLAGS += $(gb_EMSCRIPTEN_LDFLAGS) $(gb_EMSCRIPTEN_CPPFLAGS) $(gb_EMSCRIPTEN_EXCEPT) + +# Linker and compiler optimize + debug flags are handled in LinkTarget.mk +gb_LINKEROPTFLAGS := +gb_LINKERSTRIPDEBUGFLAGS := +# This maps to g4, AKA sorce maps. The LO default would otherwise be g2! +gb_DEBUGINFO_FLAGS = -g +# We need at least code elimination, otherwise linking OOMs even with 64GB. +# So we "fake" -Og support to mean -O1 for Emscripten and always enable it for debug in configure. +gb_COMPILERDEBUGOPTFLAGS := -O1 +gb_COMPILERNOOPTFLAGS := -O1 -fstrict-aliasing -fstrict-overflow + +# cleanup addition JS and wasm files for binaries +define gb_Executable_Executable_platform +$(call gb_LinkTarget_add_auxtargets,$(2),\ + $(patsubst %.lib,%.wasm,$(3)) \ + $(patsubst %.lib,%.js,$(3)) \ + $(patsubst %.lib,%.worker.js,$(3)) \ +) + +endef + +define gb_CppunitTest_CppunitTest_platform +$(call gb_LinkTarget_add_auxtargets,$(2),\ + $(patsubst %.lib,%.wasm,$(3)) \ + $(patsubst %.lib,%.js,$(3)) \ + $(patsubst %.lib,%.worker.js,$(3)) \ +) + +endef + +gb_SUPPRESS_TESTS := $(true) + +define gb_Library_get_rpath +endef + +define gb_Executable_get_rpath +endef + +# vim: set noet sw=4 ts=4 diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index e07bd2824ff5..fe99e98ea4c4 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -49,6 +49,7 @@ gb_COMPILERDEFS := \ -DBOOST_ERROR_CODE_HEADER_ONLY \ -DBOOST_SYSTEM_NO_DEPRECATED \ -DCPPU_ENV=$(gb_CPPU_ENV) \ + $(if $(filter EMSCRIPTEN,$(OS)),-U_FORTIFY_SOURCE) \ gb_CFLAGS_COMMON := \ -Wall \ @@ -63,7 +64,7 @@ gb_CFLAGS_COMMON := \ -fmessage-length=0 \ -fno-common \ -pipe \ - -fstack-protector-strong \ + $(if $(filter EMSCRIPTEN,$(OS)),-fno-stack-protector,-fstack-protector-strong) \ $(if $(gb_COLOR),-fdiagnostics-color=always) \ gb_CXXFLAGS_COMMON := \ @@ -80,7 +81,7 @@ gb_CXXFLAGS_COMMON := \ -fmessage-length=0 \ -fno-common \ -pipe \ - -fstack-protector-strong \ + $(if $(filter EMSCRIPTEN,$(OS)),-fno-stack-protector,-fstack-protector-strong) \ $(if $(gb_COLOR),-fdiagnostics-color=always) \ ifeq ($(HAVE_WDEPRECATED_COPY_DTOR),TRUE) @@ -109,8 +110,10 @@ endif ifeq ($(DISABLE_DYNLOADING),TRUE) gb_CFLAGS_COMMON += -ffunction-sections -fdata-sections gb_CXXFLAGS_COMMON += -ffunction-sections -fdata-sections +ifneq ($(OS),EMSCRIPTEN) gb_LinkTarget_LDFLAGS += -Wl,--gc-sections endif +endif ifeq ($(COM_IS_CLANG),TRUE) gb_CXXFLAGS_COMMON += \ @@ -143,7 +146,7 @@ endif gb_VISIBILITY_FLAGS_CXX := -fvisibility-inlines-hidden gb_CXXFLAGS_COMMON += $(gb_VISIBILITY_FLAGS_CXX) -gb_LinkTarget_LDFLAGS += -fstack-protector-strong +gb_LinkTarget_LDFLAGS += $(if $(filter EMSCRIPTEN,$(OS)),-fno-stack-protector,-fstack-protector-strong) ifneq ($(gb_ENABLE_PCH),) ifeq ($(COM_IS_CLANG),TRUE) |