-
Notifications
You must be signed in to change notification settings - Fork 41
Description
I'm in the process of integrating an OTP-27 runtime for native targets like osx, ios, android, ... based on elixir-desktop
including wasmex would be very interesting to run eg. electricsql's wasi pglite. or other wasm packages related to sensors, ai, ...
I did some poc integration with pglite based on a preview build and could at least read imports / exports. their api is not exposed yet. Resp. only for the browser / node.js wasm targets.
The size of the libwasmex static lib is kind of a problem. Are there any ways to reduce the size? Eg. disable nonessential features of wasmtime?
before stripping:
-rw-r--r-- 1 runner staff 471M Mar 18 22:01 /Users/runner/work/elixir-desktop-runtimes/elixir-desktop-runtimes/_build/nifs/libwasmex.a
-rw-r--r-- 1 runner staff 2.1M Mar 18 21:58 /Users/runner/work/elixir-desktop-runtimes/elixir-desktop-runtimes/_build/nifs/sqlite3_nif.a
after stripping:
-rw-r--r-- 1 runner staff 148M Mar 18 22:01 /Users/runner/work/elixir-desktop-runtimes/elixir-desktop-runtimes/_build/nifs/libwasmex.a
-rw-r--r-- 1 runner staff 2.0M Mar 18 22:01 /Users/runner/work/elixir-desktop-runtimes/elixir-desktop-runtimes/_build/nifs/sqlite3_nif.a
This is how I build the static lib. The rustflags are there to enable OTP to statically link multiple rust nifs ( avoid duplicate symbols related to std lib duplicate symbol '__ZN3std9panicking11EMPTY_PANIC17h38cb21ffaeece953E' / duplicate symbol '_rust_eh_personality' )
CARGO_CMD="cargo rustc --crate-type staticlib --target=${{matrix.platform.rust_target}} --features rustler/staticlib -- -C opt-level=z -C codegen-units=1"
git clone --depth 1 https://github.com/adiibanez/wasmex.git --branch static-no-precompiled
cd wasmex
cd native/wasmex
# N rust lib, exclude std lib
RUSTFLAGS="-C target-feature=-crt-static -C link-arg=-nostdlib -C panic=abort" \
$CARGO_CMD