Skip to content

Add precompiled NIF artifacts via rustler_precompiled (#27)#49

Open
kipcole9 wants to merge 2 commits intoelixir-nx:mainfrom
elixir-image:precompiled-nifs-pr
Open

Add precompiled NIF artifacts via rustler_precompiled (#27)#49
kipcole9 wants to merge 2 commits intoelixir-nx:mainfrom
elixir-image:precompiled-nifs-pr

Conversation

@kipcole9
Copy link
Copy Markdown

Add precompiled NIF artifacts via rustler_precompiled (#27). This is intended to make installation easier for most users while preserving the manual build process option for anyone that wants it.

Consumers on aarch64/x86_64 macOS, aarch64/x86_64 Linux glibc, and
x86_64 Windows MSVC no longer need a Rust toolchain — Ortex downloads
a prebuilt NIF from the GitHub release. Source build remains the
fallback for unlisted targets and via ORTEX_BUILD=true.

@lawik requested Nerves cross-compilation support too and I'm
willing to tackle that if this PR is accepted.

Changes

  • lib/ortex/native.ex: use RustlerPrecompiled (handles both download
    and force_build paths). Ortex.Util.copy_ort_libs still runs after
    source build to stage libonnxruntime when the toolchain produces a
    dynamically-linked NIF.
  • mix.exs: add :rustler_precompiled, make :rustler optional, ship
    CHANGELOG.md and the checksum file in the package.
  • .github/workflows/release.yml: matrix builds 5 targets × 2 NIF
    versions on tag push via philss/rustler-precompiled-action,
    uploads to a draft release.
  • .github/workflows/ci.yml: forces source build via ORTEX_BUILD=true
    so PR validation isn't dependent on release artifacts existing. Preserves
    the existing behaviour.
  • checksum-Elixir.Ortex.Native.exs, RELEASE.md, CHANGELOG.md,
    README.md: pinned-checksums placeholder, release runbook,
    changelog entry, precompile target list and source-build
    instructions.

Verified end-to-end on Debian Bookworm with no Rust toolchain via a
mix deps.compile + tinymodel.onnx inference test in Docker.

Updated Release process

Since we generate precompiled artefacts on tag push, the release process is a bit different and documented in RELEASE.md. It follows the standard process for other rustler_precompiled projects. In short:

  1. Bump version
  2. Tag and push the tag (triggers workflows/release.yml)
  3. Promote the draft release to published in Github after the artefacts are built.
  4. Generate the checksum file with ORTEX_BUILD=true mix rustler_precompiled.download Ortex.Native --all
  5. Commit the checksum file and force-move the tag.

Consumers on aarch64/x86_64 macOS, aarch64/x86_64 Linux glibc, and
x86_64 Windows MSVC no longer need a Rust toolchain — Ortex downloads
a prebuilt NIF from the GitHub release. Source build remains the
fallback for unlisted targets and via ORTEX_BUILD=true.

* lib/ortex/native.ex: use RustlerPrecompiled (handles both download
  and force_build paths). Ortex.Util.copy_ort_libs still runs after
  source build to stage libonnxruntime when the toolchain produces a
  dynamically-linked NIF.
* mix.exs: add :rustler_precompiled, make :rustler optional, ship
  CHANGELOG.md and the checksum file in the package.
* .github/workflows/release.yml: matrix builds 5 targets × 2 NIF
  versions on tag push, custom packaging step bundles libonnxruntime
  when present (no-op for static-linked builds), uploads to a draft
  release.
* .github/workflows/ci.yml: forces source build via ORTEX_BUILD=true
  so PR validation isn't dependent on release artifacts existing.
* checksum-Elixir.Ortex.Native.exs, RELEASE.md, CHANGELOG.md,
  README.md: pinned checksums, release runbook, changelog entry,
  precompile target list and source-build instructions.

Verified end-to-end on Debian Bookworm with no Rust toolchain via a
mix deps.compile + tinymodel.onnx inference test in Docker.
Consumers on aarch64/x86_64 macOS, aarch64/x86_64 Linux glibc, and
x86_64 Windows MSVC no longer need a Rust toolchain — Ortex downloads
a prebuilt NIF from the GitHub release. Source build remains the
fallback for unlisted targets and via ORTEX_BUILD=true.

* lib/ortex/native.ex: use RustlerPrecompiled (handles both download
  and force_build paths). Ortex.Util.copy_ort_libs still runs after
  source build to stage libonnxruntime when the toolchain produces a
  dynamically-linked NIF.
* mix.exs: add :rustler_precompiled, make :rustler optional, ship
  CHANGELOG.md and the checksum file in the package.
* .github/workflows/release.yml: matrix builds 5 targets × 2 NIF
  versions on tag push via philss/rustler-precompiled-action,
  uploads to a draft release.
* .github/workflows/ci.yml: forces source build via ORTEX_BUILD=true
  so PR validation isn't dependent on release artifacts existing.
* checksum-Elixir.Ortex.Native.exs, RELEASE.md, CHANGELOG.md,
  README.md: pinned-checksums placeholder, release runbook,
  changelog entry, precompile target list and source-build
  instructions.

Verified end-to-end on Debian Bookworm with no Rust toolchain via a
mix deps.compile + tinymodel.onnx inference test in Docker.
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