Skip to content

M0 Stage 2: Native dependencies #3

Description

@tlkahn

Stage 2: Native dependencies

Attach the two native dependencies to their owning modules: vendored jinja_cpp built from source for chat, and Homebrew mlx-c plus Apple frameworks for mlxbridge. C linking is per-module so consumers inherit transitively; no other module touches native deps directly.

Epic: #1

Depends on: Stage 1 (modules must exist to attach native deps)

Phase 2.1: Vendor jinja_cpp

  • 2.1.1 Copy jinja_cpp sources from mlx-serve/lib/jinja_cpp into vendor/jinja_cpp/ (sources only, no prebuilt libjinja.a)
  • 2.1.2 Build the vendored sources with -std=c++17 in build.zig and attach them to the chat module only, so consumers inherit the link transitively
  • 2.1.3 Smoke check: chat compiles and links against jinja_cpp via one trivial extern call exercised in a test block
  • 2.1.4 Record upstream provenance in vendor/jinja_cpp/README.md: the engine is llama.cpp's in-tree Jinja engine (common/jinja/, introduced in implement new jinja template engine ggml-org/llama.cpp#18462, the PR that replaced minja), plus mlx-serve's C wrapper (jinja_wrapper.{h,cpp}); note the upstream path so fixes can be synced

Note (evaluated 2026-07-05): google/minja was considered as an alternative and rejected. The vendored jinja_cpp IS minja's successor: llama.cpp replaced minja with this engine in Jan 2026 (PR #18462) and actively maintains it, while minja's primary author left Google and its README warns about maintenance status. Keeping jinja_cpp also preserves the existing 3-function C API and format-corpus validation.

Phase 2.2: Homebrew mlx gates

  • 2.2.1 Port the brew version-gate logic from the old repo's build.zig: require mlx-c >= 0.6.0 and mlx >= 0.31.2, fail configuration with a clear actionable message when missing or outdated
  • 2.2.2 Link mlx-c plus Metal/Foundation/IOKit/CoreFoundation frameworks to the mlxbridge module only (per-module linkSystemLibrary/framework attachment)
  • 2.2.3 Smoke check: mlxbridge declares one trivial mlx-c extern and a gated test proves the symbol resolves at link time

Acceptance

  • vendor/jinja_cpp builds from source with no prebuilt artifacts checked in
  • Missing or outdated brew mlx/mlx-c fails configuration with an actionable error message

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestm0-skeletonM0 skeleton milestone work

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions