Skip to content
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

Shipping NIF with the release #168

Open
tduccuong opened this issue Jan 14, 2025 · 1 comment
Open

Shipping NIF with the release #168

tduccuong opened this issue Jan 14, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@tduccuong
Copy link

Host

Tell us about your Host OS (the machine you're building burrito apps on)

Host OS: Debian 12
Host CPU: x86_64

Please run zig version in your Burrito project directory and write the version here: 0.13.0

Please run elixir -v in your Burrito project directory and write the version here: 1.14..2


Target

Host OS: Armbian 24.11.1 noble
Host CPU: aarch64
Host LibC and Version


I need to support the Brotli compression in my app. I use this NIF-based library for that. On the dev env, everything works fine, I could brotli:encode and brotli:decode data. But when running the Burrito release, I got this error:

** (UndefinedFunctionError) function :brotli_nif.decoder_create/0 is undefined (module :brotli_nif is not available)
        (brotli 0.3.2) :brotli_nif.decoder_create()

The Brotli's .so and .beam files are there in the release package:

root@mymachine:~# ll /root/.local/share/.burrito/myapp_erts-13.2.2.2_1.0.0/lib/brotli-0.3.2/ebin/
total 20
-rw-r--r-- 1 root root  531 Jan 14 19:38 brotli.app
-rw-r--r-- 1 root root 1436 Jan 14 19:38 brotli.beam
-rw-r--r-- 1 root root  856 Jan 14 19:38 brotli_decoder.beam
-rw-r--r-- 1 root root 1372 Jan 14 19:38 brotli_encoder.beam
-rw-r--r-- 1 root root 1664 Jan 14 19:38 brotli_nif.beam

root@mymachine:~# ll /root/.local/share/.burrito/myapp_erts-13.2.2.2_1.0.0/lib/brotli-0.3.2/priv
total 812
-rwxr-xr-x 1 root root 831448 Jan 14 19:38 brotli.so

Did I miss a step in the release making process? or can you please advise?

Thanks a lot!

@tduccuong tduccuong added the bug Something isn't working label Jan 14, 2025
@doawoo
Copy link
Contributor

doawoo commented Jan 15, 2025

The package in question erl-brotli does not appear to use Elixir Make (or mix) - which is the only method we support for automatically re-compiling NIFs for target platforms.

Recompiling NIFs is a very involved and complicated process, and having a one-size-fits-all solution is difficult.

I recommend pre-compiling the NIFs for your target platform, storing them somewhere common, then using a custom pre/post build step to copy them into the proper location before Burrito packs up the release. See the README file for details on how to use custom steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants