Skip to content

Generate the app driver table when an opt-in built-in NIF is enabled (MOB-394) - #141

Merged
GenericJam merged 2 commits into
masterfrom
mob-394-driver-tab-tflite
Oct 15, 2026
Merged

GenericJam merged 2 commits into
masterfrom
mob-394-driver-tab-tflite

Conversation

@GenericJam

Copy link
Copy Markdown
Owner

Part of MOB-394 (with GenericJam/mob_new#103).

A blank app with nx_tflite_mob in deps had no priv/generated/driver_tab_*, so it linked mob's core table, which has no TFLite entry. With the mob_new template linking libtflite_nif.a, the app launched but NxTfliteMob.NIF failed to load (dlopen failed: library "libtflite_nif.so" not found): the static NIF was linked but never registered.

regen_driver_tab!/0 created an app table only when a plugin contributed NIFs. It now also does when any guarded built-in of MobDev.StaticNifs.default_nifs/0 is enabled, using the same dep checks the native build uses to compile/link it (tflite_in_project?, nxeigen_in_project?, emlx_in_project?). NxEigen is covered by the same rule; no separate fix needed.

Tests: a host Mix project with an nx_tflite_mob path dep gets tables containing tflite_nif_nif_init (fails on master: no table created); a host with no opt-in NIF gets none; the guard→module mapping.

Device proof: see MOB-394 (Android emulator + iOS sim, NxTfliteMob.load_module + call).

GenericJam and others added 2 commits October 15, 2026 13:30
…(MOB-394)

A blank app with nx_tflite_mob in deps had no priv/generated/driver_tab_*,
so it linked against mob's core table, which carries no TFLite entry: the
template linked libtflite_nif.a, but NxTfliteMob.NIF never registered and
loaded as `dlopen failed: library "libtflite_nif.so" not found`.
regen_driver_tab! created an app table only when a plugin contributed NIFs.

It now also creates one when any guarded built-in of
StaticNifs.default_nifs/0 is enabled, judged by the same dep checks the
native build uses to compile and link it (tflite_in_project?,
nxeigen_in_project?, emlx_in_project?). NxEigen is covered by the same rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-394 review)

mob's core iOS table already registers emlx_nif and EMLX is iOS-only, so a
generated table added nothing and would make app build files from mob_new
<=0.3.15 (no tflite_static option) fail to compile it. The NxEigen rule is
now exercised by a host with an nx_eigen dep instead of an injected
predicate; scratch hosts are removed on test exit even when an assertion
fails.
@GenericJam

Copy link
Copy Markdown
Owner Author

Review: Codex hit its usage limit (until 5:26 PM), so a reviewer subagent reviewed instead. Round 1: MERGE with two findings (drop EMLX from the trigger: core iOS table already registers it and old app build files lack tflite_static; test the real guard→dep mapping end to end). Both fixed in b10415c; re-review: MERGE, no findings.

Fail-before/pass-after: with the trigger reverted to plugins-only, the TFLite and NxEigen host tests fail (no table written); with the fix, 236/236 in native_build_test.exs.

Device proof (blank host from mob_new#103 + this branch as a path dep, nx_tflite_mob 0.0.4): mix mob.deploy --native printed driver_tab created: priv/generated/driver_tab_{android,ios}.zig; MobileNet v1 0.25/128 load_module + call on zeros returned {:ok, 4004, 0.0251…} on an iOS 27 sim (iPhone 18 Pro) and an arm64 Android 15 emulator.

@GenericJam
GenericJam merged commit 36045e7 into master Oct 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant