On this page

0152: Interpreter FFI host

Status: Proposed — design default, pending the maintainer's confirmation

Context

The interpreter should preserve differential FFI behavior without Rust unsafe or pretending native calls are interpreted. This numbering starts at 0150, leaving 0122–0149 for the owner's in-progress M14 ADRs.

Decision

Amend ADR-0093: harness interp supports FFI externs through a cached compiled C ffi-host helper. Generate it from the same shims and prototype checks as the C backend, compile with the same compiler and flags, and launch it lazily on the first extern call. Use framed pipes with length-prefixed little-endian messages and one helper per interpreter run, preserving shim handle state. If no compiler is available or helper compilation fails, report E0979; if the helper dies, trap as ffi at the call site.

Consequences

FFI programs can have differential behavior tests in both backends. Interpreting FFI requires a C compiler. A crash in native code remains a native crash in the C backend, while helper death is an interpreter trap.

Alternatives considered

An interpreter-only trap would make FFI programs C-only and undermine differential testing. Calling through a compiled plugin offers no clearer contract than the dedicated helper.