-
Hi https://github.com/elixir-desktop/exqlite Works just fine as statically linked nif. I posted some infos about my issue and about the attempts at replicating what exqlite does: #686 The relevant parts about the static nif are somewhere here https://github.com/elixir-desktop/exqlite/blob/main/c_src/sqlite3_nif.c I totally agree with @filmor that this is not the standard approach of loading a nif. But there aren't many options on mobile targets. Any ideas / recommendations? My activities are based on the elixir-desktop project, there are OTP-27 builds for macos, ios. Android is available too but currently disabled as I was focusing on ios. Can provide infos and example projects if anyone want's to take it for a spin. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 34 replies
-
Well, having now looked at the code it looks less involved than I'd have expected. Effectively, we have to
This is just for the Rust side of things. I don't have a good idea how to handle the |
Beta Was this translation helpful? Give feedback.
-
I fixed the lib selection but still see an error Undefined symbols for architecture arm64: |
Beta Was this translation helpful? Give feedback.
-
I hit another road block regarding using more than one static rustler nif. ld: warning: object file (/Users/runner/work/elixir-desktop-runtimes/elixir-desktop-runtimes/_build/nifs/libwasmex.a54) was built for newer 'macOS' version (14.5) than being linked (14.0) Are you aware of any cargo build flags or other approaches that would allow 2 rustler nifs to be included in a otp build? CARGO_CMD="cargo rustc --crate-type staticlib --features rustler/staticlib --release --target=${{matrix.platform.rust_target}} -- -C opt-level=z -C codegen-units=1 -v" https://www.amyspark.me/blog/posts/2024/01/10/stripping-rust-libraries.html |
Beta Was this translation helpful? Give feedback.
-
@filmor lto=off works. I could also remove any panic=aborts and only use -C link-arg=-nostdlib to include more than one rustler lib. using --release in the cargo command breaks OTP builds CARGO_OPTIMIZATION_FLAGS="-C lto=off -C embed-bitcode=no -C opt-level=z -C codegen-units=1 -C strip=symbols -C link-arg=-Wl,-dead_strip -C link-arg=-Wl,--gc-sections" before stripping: after stripping: 60M _build/nifs/libwasmex.a thats approx 3x the size I saw for the rustler libs compared to using lto=fat Would be interested in hearing how you would "you can strip/LTO/optimize the actual OTP build". I did some attempts with Regarding the perl script I'm not sure I understand what role that would cover. |
Beta Was this translation helpful? Give feedback.
-
If erlang/otp#9625 (or something like it) is merged, maybe the best option becomes to
I'll test this approach. |
Beta Was this translation helpful? Give feedback.
-
This is now merged in |
Beta Was this translation helpful? Give feedback.
This is now merged in
rustler
. Still lacks documentation, will follow up on that in the next weeks before cutting a release.