Open benoit-pierre opened 2 weeks ago
For now, monolibtic mode is only enabled for Android
I don't mind for Android, but I hope this won't go further - I would like to keep my kobo nightlies with smaller libraries I can quickly compile independantly without having to rebuild the whole thing.
(And on principle, I don't like the idea of a single monolithic library, but what do I know.) Also, I remember that when I tested it months ago on my Kobo, it wasn't at all faster than a current nightly.
Test builds:
No strong opinions about it as long as it stays Android-specific in practice ;).
After fixing the libraries sonames on Android in #1907 (to fix https://github.com/koreader/koreader/issues/12348), the dynamic linker on API level 18 (and 19 too I assume) craps out during symbol resolution (cf. comment).
The only way I could get around those type of issues on my meson branch was to bundle (almost) everything into one big library, and this PR does just that.
At first I tried a partial solution, not bundling in native Lua modules, but of course this just resulted in the dynamic loader having another symbol resolution fit when attempting to load
common/ssl.so
… So you get the full monty, native Lua modules included, no shared objects inassets.7z
. The final list of native libraries is:For now, monolibtic mode is only enabled for Android (but I tested the emulator and kindlepw2 builds too).
On Android, there's no need for the
sdcv
andlibs
symlinks in the application files directory anymore: both executable and libraries are directly loaded from the application native libraries directory (fixing this corner case).Implementation
utils/gen_linker_exports.sh
and our FFI cdecls to only keep what we needffi.loadlib(…)
instead offfi.load
to load our libraries (and a custom package loader to handle bundled native Lua modules)android-luajit-launcher
: https://github.com/koreader/android-luajit-launcher/compare/master...benoit-pierre:android-luajit-launcher:monolibticffi.loadlib
moduleApart from a host of commits to facilitate bundling everything, another big change is the
ffi.loadlib
helper, replacingffi.load
andutil.ffiLoadCandidates
for loading our libraries.Example use:
On Linux, the code will attempt to load
libSDL2-2.0.so.0
inlibs/
and then from the system, thenlibSDL2-2.0.so
if that failed, and fallback to tryinglibSDL2.so
.In monolibtic mode, loading a bundled library will
ffi.load
the monolibtic library. A custom package loader handle therequire("libs/libkoreader-lfs")
case.Code size
Impact on code size (bss+data+text, ignoring executables and the cURL library):
Impact on memory use: a slight increase at startup (starting with the FM, +0-2 MB), but a reduction after opening a few documents of different types (-2-8 MB).
TODO
If the solution is accepted, split the change into smaller PRs for merging: preliminary cleanups,
ffi.loadlib
module / helper, FFI cdecls cleanups, cURL static build, other static libraries support, final monolitic commit.This change is