-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Libzim wasm compilation #548
Conversation
fc4b1e5
to
8203d99
Compare
@mgautierfr Do we have a test output blog to share with @Jaifroid to be tested? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I skimmed over the emsdk
related stuff since I have no experience with emscripten.
kiwixbuild/dependencies/lzma.py
Outdated
archive = Remotefile('xz-5.2.7.tar.gz', | ||
'06327c2ddc81e126a6d9a78b0be5014b976a2c0832f492dcfc4755d7facf6d33', | ||
'https://altushost-swe.dl.sourceforge.net/project/lzmautils/xz-5.2.7.tar.gz' | ||
archive = Remotefile('xz-5.2.6.tar.gz', | ||
'a2105abee17bcd2ebd15ced31b4f5eda6e17efd6b10f921a01cda4a44c91b3a0', | ||
'https://altushost-swe.dl.sourceforge.net/project/lzmautils/xz-5.2.6.tar.gz' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it doesn't make sense to include in the PR the commit that switches lzma to 5.2.7 (and the commit message of this commit must be slightly updated)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to make the fallback to 5.2.6
explicit. Ideally, we would move to 5.2.7
but we don't because of compilation issue. By using two commits, it is explicit (and as we will have to update lzma at a moment, better have too much information)
@mgautierfr Does it implement what is requested in #503 |
kiwixbuild/platforms/wasm.py
Outdated
def configure_prefix(self): | ||
return "emconfigure" | ||
|
||
@property | ||
def make_prefix(self): | ||
return "emmake" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand how these prefixes are supposed to work, but my impression was that both prefixes should be simply "em".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact they are not prefix but wrapper (and I will rename them)
They are tools provided by emsdk to run configure. Something like emconfigure source/configure --options
where we would simply run source/configure --options
in other case.
They "simply" set the environment before running the real command.
This way, we can use small wrapper tools from sdk to run configure and make.
On top of using a more recent version (which is good it itself), version 5.2.7 use a autotools version which knows about wasm.
This way, we can see the applied patch in the log.
It implement everything but the compilation of the wrapper (which should be made in https://github.com/openzim/javascript-libzim ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There is few mistake in the packaging of the wasm dependencies (needed by the CI on libzim side). I move this PR to draft while I'm fixing it. |
`icu4c_wasm.patch` is build by : - Copying config.sub from liblzma source as new version of config.sub there knows about wasm architecture. - Copying `mh-linux` on `mh-unknown` as specified in (origin) `mh-unknown`. This is because icu4c configure doesn't detect `emscripten` platform and "fallback" to `mh-unknown`.
Version 5.2.7 include this commit https://git.tukaani.org/?p=xz.git;a=commit;h=31d80c6b261b24220776dfaeb8a04f80f80e0a24 With this change, compiling libzim mixed (libzim dynamic and dependencies, so lzma, statically) fails at libzim linking with a `src/libzim.so.8.0.1: version node not found for symbol lzma_get_progress@XZ_5.2.2` error message. This can be "workaround" by passing `--disable-symbol-versions` to configure script but then, it is the compilation of kiwix-desktop in native_dyn which falling with ``` /usr/bin/ld: /usr/lib64/libsystemd.so.0: undefined reference to `lzma_code@XZ_5.0' /usr/bin/ld: /usr/lib64/libsystemd.so.0: undefined reference to `lzma_end@XZ_5.0' /usr/bin/ld: /usr/lib64/libsystemd.so.0: undefined reference to `lzma_stream_decoder@XZ_5.0' /usr/bin/ld: /usr/lib64/libxml2.so.2: undefined reference to `lzma_auto_decoder@XZ_5.0' /usr/bin/ld: /usr/lib64/libxml2.so.2: undefined reference to `lzma_properties_decode@XZ_5.0' ``` Probably because some native dependencies (Qt ?) use versionned symbols. This have to be fixed somehow but until then, let's go back to 5.2.6
There is no need to be specific here, we are already in INSTALL_DIR which contains only things specific to our platform.
We need to be able to test our generated artefacts before we merge the branches.
@Jaifroid Here is a test wasm libzim http://tmp.kiwix.org/ci/wasm/libzim_wasm-emscripten-2022-11-16.tar.gz. Would you be able please to test it? Once this PR will be merged, it will be in nightly/release folders. |
OK, great, yes I'll test and report back. Many thanks! |
@kelson42 The file you attached only seems to contain source code (see screenshot). I can't find the wasm in it.... The file should have a file extension |
This is |
Ah, I was looking for a file ending |
This is disturbing for me as well as |
Hmm. Seems I can't test properly without the JavaScript that should be produced by Emscripten along with the WASM. Normally they are produced together at compile time. Do we have that? If I just drop the WASM in to the current test implementation, I get the following: |
@mgautierfr macOS CI does not pass!!! |
@kelson42 it's the same concurrency test we talk about last week |
@rgaudin One test is failing, looks different to me to what we have at libzim/libkiwix level, will let you handle it. |
Nothing I can do. Leaving it to @mgautierfr |
So far, it was generated through the (dirty) Makefile from https://github.com/openzim/javascript-libzim It's true that it's currently not possible for us to test this file alone. I'll elaborate in https://github.com/openzim/javascript-libzim/ |
It is true :) The purpose of this PR is to build libzim (and only libzim) for wasm "architecture". The wrapper need to be compiled in https://github.com/openzim/javascript-libzim. It is a the same thing than libzim compile on android platform without the jni wrapper. A necessary but not sufficient step. I propose we merge this PR as it is and move the work on javascript-libzim. If (when) something has to be changed here, we will see then. |
@mgautierfr So, IMO we are good to merge, module the macOS CI problem. Any idea what goes wrong there? |
Let's merge this PR. |
So, I tried testing an Emscripten compile/bind (with I guess this means that #552 would need to be completed. I don't know if there's another way to link up the dependencies, assuming it is a dependency issue. |
Yes (And please continue the discussion there)
You need the dependencies to link with them. No other choices :) |
Fixes #503
This PR add support to wasm (for libzim).
It it still WIP has I need to check everything is working for other platform (and on the CI)
compilation of libzim for wasm is working (on my computer) but generated binary has not been tested.