blob: 6e74599eb3ae14e4ce96f297e1758306eac2a207 [file] [log] [blame] [view]
Hosseind19299f2021-10-10 19:59:20 +02001# Support for Emscripten Cross Build
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +02002
Andrea Gelminib926ba62023-02-13 12:23:32 +01003This subdirectory provides support for building LibreOffice as WASM, with the Emscripten toolchain.
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +02004
Tor Lillqvist187d3b62023-02-06 11:57:15 +02005You can build LibreOffice for WASM for two separate purposes: 1)
6Either to produce a WASM binary of LibreOffice as such, using Qt5 for
7its GUI, or 2) just compiling LibreOffice core ("LibreOffice
8Technology") to WASM without any UI for use in other software that
9provides the UI, like Collabora Online built as WASM.
Tor Lillqvist6f6b8792023-02-02 13:38:02 +020010
11The first purpose was the original reason for the WASM port and this
12document was originally written with that in mind. For the second
13purpose, look towards the end of the document for the section
14"Building headless LibreOffice as WASM for use in another product".
15
16## Status of LibreOffice as WASM with Qt
Hosseind19299f2021-10-10 19:59:20 +020017
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010018The build generates a Writer-only LO build. You should be able to run either
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020019
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010020 $ emrun --serve_after_close instdir/program/qt_soffice.html
21 $ emrun --serve_after_close workdir/LinkTarget/Executable/qt_vcldemo.html
22 $ emrun --serve_after_close workdir/LinkTarget/Executable/qt_wasm-qt5-mandelbrot.html
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020023
Hosseind19299f2021-10-10 19:59:20 +020024REMINDER: Always start new tabs in the browser, reload might fail / cache!
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010025INFO: latest browser won't work anymore with 0.0.0.0 and need 127.0.0.1.
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020026
Hosseind19299f2021-10-10 19:59:20 +020027## Setup for the LO WASM build (with Qt)
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020028
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010029We're using Qt 5.15.2 with Emscripten 2.0.31. There are a bunch of Qt patches
30to fix the most grave bugs. Also newer Emscripten versions have various bugs
31with the FS image support.
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020032
Hosseind19299f2021-10-10 19:59:20 +020033- See below under Docker build for another build option
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020034
Hosseind19299f2021-10-10 19:59:20 +020035### Setup emscripten
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020036
Hosseind19299f2021-10-10 19:59:20 +020037<https://emscripten.org/docs/getting_started/index.html>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020038
Hosseind19299f2021-10-10 19:59:20 +020039 git clone https://github.com/emscripten-core/emsdk.git
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010040 ./emsdk install 2.0.31
41 ./emsdk activate --embedded 2.0.31
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020042
Hosseind19299f2021-10-10 19:59:20 +020043Example `bashrc` scriptlet:
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020044
Hosseind19299f2021-10-10 19:59:20 +020045 EMSDK_ENV=$HOME/Development/libreoffice/git_emsdk/emsdk_env.sh
46 [ -f "$EMSDK_ENV" ] && \. "$EMSDK_ENV" 1>/dev/null 2>&1
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020047
Hosseind19299f2021-10-10 19:59:20 +020048### Setup Qt
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020049
Hosseind19299f2021-10-10 19:59:20 +020050<https://doc.qt.io/qt-5/wasm.html>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020051
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010052Most of the information from <https://doc.qt.io/qt-6/wasm.html> is still valid for Qt5;
53generally the Qt6 WASM documentation is much better, because it incorporated many
54information from the Qt Wiki.
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020055
Andrea Gelmini5ef2a7d2022-01-21 12:30:42 +010056FWIW: Qt 5.15 LTS is not maintained publicly and Qt WASM has quite a few bugs. Most
Tor Lillqvist52c37442022-12-14 21:38:08 +020057WASM fixes from Qt 6 are needed for Qt 5.15 too. Allotropia offers a Qt repository
58with the necessary patches cherry-picked.
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010059
Tor Lillqvist52c37442022-12-14 21:38:08 +020060 git clone https://github.com/allotropia/qt5.git
Hosseind19299f2021-10-10 19:59:20 +020061 cd qt5
Tor Lillqvist52c37442022-12-14 21:38:08 +020062 git checkout v5.15.2+wasm
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010063 ./init-repository --module-subset=qtbase
Tor Lillqvist52c37442022-12-14 21:38:08 +020064 ./configure -xplatform wasm-emscripten -feature-thread -prefix <whatever>
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010065 make -j<CORES> module-qtbase
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020066
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010067Optionally you can add the configure flag "-compile-examples". But then you also have to
68patch at least mkspecs/wasm-emscripten/qmake.conf with EXIT_RUNTIME=0, otherwise they will
69fail to run. In addition, building with examples will break with some of them, but at that
70point Qt already works and also most examples.
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020071Building with examples will break with some of them, but at that point Qt already works.
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010072Or just skip them. Other interesting flags might be "-nomake tests -no-pch -ccache".
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020073
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010074Linking takes quite a long time, because emscripten-finalize rewrites the whole WASM files
75with some options. This way the LO WASM needs at least 64GB RAM. For faster link times add
76"-s WASM_BIGINT=1", change to ASSERTIONS=1 nd use -g3 to prevent rewriting the WASM file
77and generating source maps (see emscripten.py, finalize_wasm, and avoid modify_wasm = True).
78This is just needed for Qt examples, as LO already uses the correct flags!
Hosseind19299f2021-10-10 19:59:20 +020079
Andrea Gelmini5ef2a7d2022-01-21 12:30:42 +010080The install is not really needed, as LO currently just uses qtbase on its own. You can do
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020081
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010082 make -j<CORES> install
83or
84 make -j8 -C qtbase/src install_subtargets
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020085
Hosseind19299f2021-10-10 19:59:20 +020086Current Qt fails to start the demo webserver: <https://bugreports.qt.io/browse/QTCREATORBUG-24072>
87
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010088Use `emrun --serve_after_close` to run Qt WASM demos.
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020089
Hosseind19299f2021-10-10 19:59:20 +020090### Setup LO
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020091
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +010092`autogen.sh` is patched to use emconfigure. That basically sets various
93environment vars, especially `EMMAKEN_JUST_CONFIGURE`, which will create the
94correct output file names, checked by `configure` (`a.out`).
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +020095
Jan-Marek Glogowski79365d62022-03-26 20:46:56 +010096There's a distro config for WASM, but it just provides --host=wasm32-local-emscripten, which
97should be enough setup. The build itself is a cross build and the cross-toolset just depends
98on a minimal toolset (gcc, libc-dev, flex, bison); all else is build from source, because the
99final result is not depending on the build system at all.
Thorsten Behrensd7e5d192021-04-25 16:02:10 +0200100
101Recommended configure setup is thusly:
102
Hosseind19299f2021-10-10 19:59:20 +0200103* grab defaults
104 `--with-distro=LibreOfficeWASM32`
Thorsten Behrensd7e5d192021-04-25 16:02:10 +0200105
Hosseind19299f2021-10-10 19:59:20 +0200106* local config
107 `QT5DIR=/dir/of/git_qt5/qtbase`
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200108
Hosseind19299f2021-10-10 19:59:20 +0200109* if you want to use ccache on both sides of the build
110 `--with-build-platform-configure-options=--enable-ccache`
111 `--enable-ccache`
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200112
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +0100113FWIW: it's also possible to build an almost static Linux LibreOffice by just using
114--disable-dynloading --enable-customtarget-components. System externals are still
115linked dynamically, but everything else is static.
116
Jan-Marek Glogowski79365d62022-03-26 20:46:56 +0100117#### Experimental (AKA currently broken) WASM exception + SjLj build
118
119You can build LO with WASM exceptions, which should be "much" faster then the JS
120based Emscripten EH handling. For setjmp / longjmp (SjLj) used by the PNG and JPEG
121libraries error handling, this needs Emscripten 3.1.3+. That builds, but execution
122still fails early with a signature mismatch call to Task::UpdateMinPeriod in LO's
Andrea Gelmini3bfea3c2022-03-30 20:13:29 +0200123job scheduler code. Unfortunately the build also needs a Qt build with
Jan-Marek Glogowski79365d62022-03-26 20:46:56 +0100124"-s SUPPORT_LONGJMP=wasm", which is incompatible with the JS EH + SjLj.
125
126The LO configure flag is simply an additional --enable-wasm-exceptions. Qt5 can
127be patched in qtbase/mkspecs/wasm-emscripten/qmake.conf with the addition of
128
129 QMAKE_CFLAGS += -s SUPPORT_LONGJMP=wasm
130 QMAKE_CXXFLAGS += -s SUPPORT_LONGJMP=wasm
131
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +0100132### "Deploying" soffice.wasm
133
134 tar -chf wasm.tar --xform 's/.*program/lo-wasm/' instdir/program/soffice.* \
135 instdir/program/qt*
136
Andrea Gelmini5ef2a7d2022-01-21 12:30:42 +0100137Your HTTP server needs to provide additional headers:
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +0100138* add_header Cross-Origin-Opener-Policy same-origin
139* add_header Cross-Origin-Embedder-Policy require-corp
140
141The default html to use should be qt_soffice.html
142
143### Debugging setup
144
145Since a few months you can use DWARF information embedded by LLVM into the WASM
146to debug WASM in Chrome. You need to enable an experimental feature and install
147an additional extension. The whole setup is described in:
148
149https://developer.chrome.com/blog/wasm-debugging-2020/
150
151This way you don't need source maps (much faster linking!) and can resolve local
152WASM variables to C++ names!
153
154Per default, the WASM debug build splits the DWARF information into an additional
155WASM file, postfixed '.debug.wasm'.
156
Hosseind19299f2021-10-10 19:59:20 +0200157### Using Docker to cross-build with emscripten
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200158
159If you prefer a controlled environment (sadly emsdk install/activate
160is _not_ stable over time, as e.g. nodejs versions evolve), that is
161easy to replicate across different machines - consider the docker
162images we're providing.
163
164Config/setup file see
Hosseind19299f2021-10-10 19:59:20 +0200165<https://git.libreoffice.org/lode/+/ccb36979563635b51215477455953252c99ec013>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200166
167Run
168
Hosseind19299f2021-10-10 19:59:20 +0200169 docker-compose build
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200170
171in the lode/docker dir to get the container prepared. Run
172
Jan-Marek Glogowski12a6b57c2022-01-10 04:50:03 +0100173 PARALLELISM=4 BUILD_OPTIONS= BUILD_TARGET=build docker-compose run --rm \
174 -e PARALLELISM -e BUILD_TARGET -e BUILD_OPTIONS builder
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200175
Hosseind19299f2021-10-10 19:59:20 +0200176to perform an actual `srcdir != builddir` build; the container mounts
177checked-out git repo and output dir via `docker-compose.yml` (so make
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200178sure the path names there match your setup):
179
180The lode setup expects, inside the lode/docker subdir, the following directories:
181
Hosseind19299f2021-10-10 19:59:20 +0200182- core (`git checkout`)
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200183- workdir (the output dir - gets written into)
Hosseind19299f2021-10-10 19:59:20 +0200184- cache (`ccache tree`)
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200185- tarballs (external project tarballs gets written and cached there)
186
187
Hosseind19299f2021-10-10 19:59:20 +0200188## Ideas for an UNO bridge implementation
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200189
Hosseind19299f2021-10-10 19:59:20 +0200190My post to Discord #emscripten:
191
192"I'm looking for a way to do an abstract call
Andrea Gelmini5f102422021-05-05 23:38:21 +0200193from one WASM C++ object to another WASM C++ object, so like FFI / WebIDL,
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200194just within WASM. All my code is C++ and normally I have bridge code, with
195assembler to implement the function call /RTTI and exception semantics of the
196specified platform. Code is at
Hosseind19299f2021-10-10 19:59:20 +0200197<https://cgit.freedesktop.org/libreoffice/core/tree/bridges/source/cpp_uno>.
198I've read a bit about `call_indirect` and stuff, but I don't have yet a good
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200199idea, how I could implement this (and there is an initial feature/wasm branch
200for the interested). I probably need some fixed lookup table, like on iOS,
201because AFAIK you can't dynamically generate code in WASM. So any pointers or
202ideas for an implementation? I can disassemble some minimalistic WASM example
Hosseind19299f2021-10-10 19:59:20 +0200203and read clang code for `WASM_EmscriptenInvoke`, but if there were some
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200204standalone code or documentation I'm missing, that would be nice to know."
205
206We basically would go the same way then the other backends. Write the bridge in
207C++, which is probably largely boilerplate code, but the function call in WAT
Hosseind19299f2021-10-10 19:59:20 +0200208(<https://github.com/WebAssembly/wabt>) based on the LLVM WASM calling
209conventions in `WASM_EmscriptenInvoke`. I didn't get a reply to that question for
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200210hours. Maybe I'll open an Emscripten issue, if we really have to implement
211this.
212
Hosseind19299f2021-10-10 19:59:20 +0200213WASM dynamic dispatch:
214
215- <https://fitzgeraldnick.com/2018/04/26/how-does-dynamic-dispatch-work-in-wasm.html>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200216
Hosseind19299f2021-10-10 19:59:20 +0200217## Tools for problem diagnosis
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200218
Hosseind19299f2021-10-10 19:59:20 +0200219* `nm -s` should list the symbols in the archive, based on the index generated by ranlib.
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200220 If you get linking errors that archive has no index.
221
222
Hosseind19299f2021-10-10 19:59:20 +0200223## Emscripten filesystem access with threads
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200224
Hosseind19299f2021-10-10 19:59:20 +0200225This is closed, but not really fixed IMHO:
226
227- <https://github.com/emscripten-core/emscripten/issues/3922>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200228
Hosseind19299f2021-10-10 19:59:20 +0200229## Dynamic libraries `/` modules in emscripten
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200230
Hosseind19299f2021-10-10 19:59:20 +0200231There is a good summary in:
232
233- <https://bugreports.qt.io/browse/QTBUG-63925>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200234
235Summary: you can't use modules and threads.
236
Hosseind19299f2021-10-10 19:59:20 +0200237This is mentioned at the end of:
238
239- <https://github.com/emscripten-core/emscripten/wiki/Linking>
240
241The usage of `MAIN_MODULE` and `SIDE_MODULE` has other problems, a major one IMHO is symbol resolution at runtime only.
242So this works really more like plugins in the sense of symbol resolution without dependencies `/` rpath.
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200243
Andrea Gelmini5f102422021-05-05 23:38:21 +0200244There is some clang-level dynamic-linking in progress (WASM dlload). The following link is already a bit old,
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200245but I found it a god summary of problems to expect:
Hosseind19299f2021-10-10 19:59:20 +0200246
247- <https://iandouglasscott.com/2019/07/18/experimenting-with-webassembly-dynamic-linking-with-clang/>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200248
249
Hosseind19299f2021-10-10 19:59:20 +0200250## Mixed information, links, problems, TODO
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200251
Hosseind19299f2021-10-10 19:59:20 +0200252More info on Qt WASM emscripten pthreads:
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200253
Hosseind19299f2021-10-10 19:59:20 +0200254- <https://wiki.qt.io/Qt_for_WebAssembly#Multithreading_Support>
255
256WASM needs `-pthread` at compile, not just link time for atomics support. Alternatively you can provide
257`-s USE_PTHREADS=1`, but both don't seem to work reliable, so best provide both.
258<https://github.com/emscripten-core/emscripten/issues/10370>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200259
260The output file must have the prefix .o, otherwise the WASM files will get a
Hosseind19299f2021-10-10 19:59:20 +0200261`node.js` shebang (!) and ranlib won't be able to index the library (link errors).
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200262
263Qt with threads has further memory limit. From Qt configure:
Hosseind19299f2021-10-10 19:59:20 +0200264````
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200265Project MESSAGE: Setting PTHREAD_POOL_SIZE to 4
266Project MESSAGE: Setting TOTAL_MEMORY to 1GB
Hosseind19299f2021-10-10 19:59:20 +0200267````
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200268
Hosseind19299f2021-10-10 19:59:20 +0200269You can actually allocate 4GB:
270
271- <https://bugzilla.mozilla.org/show_bug.cgi?id=1392234>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200272
273LO uses a nested event loop to run dialogs in general, but that won't work, because you can't drive
274the browser event loop. like VCL does with the system event loop in the various VCL backends.
275Changing this will need some major work (basically dropping Application::Execute).
276
277But with the know problems with exceptions and threads, this might change:
Hosseind19299f2021-10-10 19:59:20 +0200278
279- <https://github.com/emscripten-core/emscripten/pull/11518>
280- <https://github.com/emscripten-core/emscripten/issues/11503>
281- <https://github.com/emscripten-core/emscripten/issues/11233>
282- <https://github.com/emscripten-core/emscripten/issues/12035>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200283
284We're also using emconfigure at the moment. Originally I patched emscripten, because it
Andrea Gelmini5f102422021-05-05 23:38:21 +0200285wouldn't create the correct a.out file for C++ configure tests. Later I found that
Hosseind19299f2021-10-10 19:59:20 +0200286the `emconfigure` sets `EMMAKEN_JUST_CONFIGURE` to work around the problem.
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200287
Hosseind19299f2021-10-10 19:59:20 +0200288ICU bug:
289
290- <https://github.com/emscripten-core/emscripten/issues/10129>
291
292Alternative, probably:
293
294- <https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Intl>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200295
296There is a wasm64, but that still uses 32bit pointers!
297
Hosseind19299f2021-10-10 19:59:20 +0200298Old outdated docs:
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200299
Hosseind19299f2021-10-10 19:59:20 +0200300- <https://wiki.documentfoundation.org/Development/Emscripten>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200301
Hosseind19299f2021-10-10 19:59:20 +0200302Reverted patch:
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200303
Hosseind19299f2021-10-10 19:59:20 +0200304- <https://cgit.freedesktop.org/libreoffice/core/commit/?id=0e21f6619c72f1e17a7b0a52b6317810973d8a3e>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200305
Hosseind19299f2021-10-10 19:59:20 +0200306Generally <https://emscripten.org/docs/porting>:
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200307
Hosseind19299f2021-10-10 19:59:20 +0200308- <https://emscripten.org/docs/porting/guidelines/api_limitations.html#api-limitations>
309- <https://emscripten.org/docs/porting/files/file_systems_overview.html#file-system-overview>
310- <https://emscripten.org/docs/porting/pthreads.html>
311- <https://emscripten.org/docs/porting/emscripten-runtime-environment.html>
312
313This will be interesting:
314
315- <https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-an-event-loop>
316
317This didn't help much yet:
318
319- <https://github.com/emscripten-ports>
320
321Emscripten supports standalone WASI binaries:
322
323- <https://github.com/emscripten-core/emscripten/wiki/WebAssembly-Standalone>
324- <https://www.qt.io/qt-examples-for-webassembly>
325- <http://qtandeverything.blogspot.com/2017/06/qt-for-web-assembly.html>
326- <http://qtandeverything.blogspot.com/2020/>
327- <https://emscripten.org/docs/api_reference/Filesystem-API.html>
328- <https://discuss.python.org/t/add-a-webassembly-wasm-runtime/3957/12>
329- <http://git.savannah.gnu.org/cgit/config.git>
330- <https://webassembly.org/specs/>
331- <https://developer.chrome.com/docs/native-client/>
332- <https://emscripten.org/docs/getting_started/downloads.html>
333- <https://github.com/openpgpjs/openpgpjs/blob/master/README.md#getting-started>
334- <https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API>
335- <https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-intro.md>
336- <https://www.ip6.li/de/security/x.509_kochbuch/openssl-fuer-webassembly-compilieren>
337- <https://emscripten.org/docs/introducing_emscripten/about_emscripten.html#about-emscripten-porting-code>
338- <https://emscripten.org/docs/compiling/Building-Projects.html>
Jan-Marek Glogowski3dd7e772021-04-23 14:04:06 +0200339
Tor Lillqvist6f6b8792023-02-02 13:38:02 +0200340## Building headless LibreOffice as WASM for use in another product
341
342### Set up Emscripten
343
344Follow the instructions in the first part of this document.
345
346### No Qt needed.
347
Tor Lillqvist187d3b62023-02-06 11:57:15 +0200348You don't need any dependencies other than those that normally are
349downloaded and compiled when building LibreOffice.
Tor Lillqvist6f6b8792023-02-02 13:38:02 +0200350
351### Set up LO
352
353For instance, this autogen.input works for me:
354
355`--disable-debug`
356`--enable-sal-log`
357`--disable-crashdump`
358`--host=wasm32-local-emscripten`
359`--disable-gui`
360`--with-main-module=writer`
361
Tor Lillqvist297c71c2023-02-13 11:04:30 +0200362For building LO core for use in COWASM, it is known to work to use
363Emscripten 3.1.30 (and not just 2.0.31 which is what the LO+Qt5 work
364has been using).
365
Tor Lillqvist6f6b8792023-02-02 13:38:02 +0200366### That's all
367
368After all, in this case you are building LO core headless for it to be used by other software.
Tor Lillqvist187d3b62023-02-06 11:57:15 +0200369
370Note that a soffice.wasm will be built, but that is just because of
371how the makefilery has been set up. We do need the soffice.data file
372that contains the in-memory file system needed by the LibreOffice
373Technology core code during run-time, though. That is at the moment
374built as a side-effect when building soffice.wasm.