[codex] Support project extra static libraries#24
Conversation
0b9b842 to
92ad577
Compare
92ad577 to
83c5462
Compare
GenericJam
left a comment
There was a problem hiding this comment.
Reviewed the diff end-to-end. LGTM — approving.
Verified the one risky change (target_arch: :ios → p at native_build.ex:3543): traced on_platform?/2. archs: [:ios] expands to {:ios_sim, :ios_device} and still intersects the singleton platform_archs(:ios_sim), so broad iOS entries keep matching both — no regression. The change's only effect is that archs: [:ios_device] entries become disjoint from {:ios_sim} and correctly stop leaking into simulator args. The per-arch singleton seam was already there for this.
Rest checks out: extra_static_libs is per-platform keyed; the -D<module>_static=true comprehension runs over the already platform-filtered entries (the non-matching-ABI test pins this); validation rejects broad arch keys and non-string paths. CI green, security scans pass, device-verified on real arm64 hardware.
Non-blocking follow-ups (fine to land as-is):
- No test covers the iOS sim-vs-device filtering — the riskiest behavioral change here is correct-by-logic but untested. A small
project_nif_zig_args(:ios_sim)vs(:ios_device)case asserting a device-only entry doesn't leak into sim would lock it in. zigler_module_root/2uses a broadPath.wildcard(cwd <> "/**/" <> basename)— if two files share the basename it takes the first match. It falls back gracefully, so low risk, but worth a comment.- A guarded entry that applies to an ABI but has no
extra_static_libsarchive for it would surface as undefined symbols at app-link. Consider validating "guard present + applicable ABI ⇒ archive present", or documenting the contract.
Ships the merged #24: per-ABI external static-archive linking for project NIFs that declare extern symbols without host-linking their backing archive, plus Zigler 0.16 staged-build flags. Patch release so downstream apps pick it up. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Adds a project-side
:extra_static_libshook to:static_nifsentries so Mob apps can link external per-ABI static archives alongside project NIF archives.Why
Some project NIFs intentionally declare
externsymbols and do not host-link their backing archive. That avoids the host/device archive mismatch during hostmix compile, then lets the native app link resolve those symbols against the correct per-ABI archive.The immediate use case is a Ghostty VT NIF in a Mob app:
extern ghostty_terminal_*.alibghostty-vt.afor the active ABIChanges
MobDev.StaticNifsentry validation with:extra_static_libs.:ios_sim,:ios_device,:android_arm64,:android_arm32,:android_x86_64) instead of broad keys like:androidor:all.-Dproject_rust_libs=static-library argument, after project Rust/Zig NIF archives.-D<module>_static=truefor guarded project NIFs on only the ABIs where the entry applies.erts_include,erl_nif_header,erl_nif_win_path,zigler_priv, andmodule_root.match_dot: true, avoiding a fallback that would load the host NIF while derivingmodule_root.Validation
asdf exec mix format lib/mob_dev/static_nifs.ex lib/mob_dev/native_build.ex test/mob_dev/static_nifs_test.exs test/mob_dev/native_build_test.exsasdf exec mix test test/mob_dev/static_nifs_test.exs test/mob_dev/native_build_test.exsdevide_mob, pinned this branch plus the Zigler static-NIF branch and ran:asdf exec mix compileasdf exec mix android.native --device R52W90AW7ENasdf exec mix mob.connect --no-iex --device R52W90AW7EN_ghostty_*symbol warning while re-driving Zigler's staged build.arm64-v8a) tablet, remote NIF smoke passed:nif_new(80, 24, 1000)nif_vt_write("REMOTE_VT_OK 42")nif_snapshot("plain") == "REMOTE_VT_OK 42"