Experimental native-object CLI

This tutorial covers the experimental relocatable native-object backend, not a complete OS, kernel or executable compiler. Alpha.5 separately provides a limited Linux native-exe path.

A small call graph

Save this function-only source as calls.srp in a fresh directory. The output filename must not already exist.

Scarp
pure funcra add_one(value: integer) -> integer {
    return value + 1;
}

pure funcra evaluate(value: integer) -> integer {
    return add_one(value);
}
sh
scarp native-object --json x86_64-none bounded-entry evaluate 1000 512 calls.srp -o calls.o

The source name evaluate selects the entry; the exported object symbol is scarp_bounded_integer_entry, not evaluate. JSON is emitted to stdout after successful object publication. calls.o is a relocatable ELF64 object, not something to execute directly.

Modes and limits

Mode Use Exported symbol
checked Standalone pure integer function, forward scalar flow scarp_checked_integer_function
bounded Standalone function with loops and a work allowance scarp_bounded_integer_function
bounded-entry Named entry, same-file nonrecursive calls, work and stack allowances scarp_bounded_integer_entry

The explicit target is x86_64-none. Both allowances are unsigned 32-bit decimal values. The stack budget is measured below the aligned caller stack pointer before CALL; external argument slots and caller alignment padding are separate.

Diagnostics and output

Success exits 0, invalid arguments or targets exit 2, and source, compilation or file-output failures exit 1. Existing files or symlinks are not replaced. The destination parent must exist and support hard links.

JSON includes schema_version, target, mode, symbol, max_work, peak_stack_bytes, max_active_frames and failure_spans. Failure spans are UTF-8 byte offsets, not character positions.

Troubleshooting

Use the reported peak_stack_bytes as the minimum accepted stack allowance for this exact source and selected entry. Re-emitting with that exact budget preserves the object bytes; one byte less must be rejected. This does not include external caller argument slots or interrupt frames.

A target such as x86_64 is invalid; use the explicit x86_64-none target. A missing source, unsupported source construct, or pre-existing destination does not produce a replacement object. JSON failure_spans include comments and original line endings in their byte offsets, so retain the exact source file and JSON report.

What is not supported

External calls, heap-backed values, general aggregate parameters/results and executable linking remain outside this object command; bounded native recursion is available in the underlying Rust API. Alpha.3 adds private flat integer/Boolean aggregate stack locals and concrete integer generic specialization. Use scarp exec for interpreter execution.

Current reference · Immutable native-object contract · Release.

Native ABI and host testing · Native value layout.

For alpha.3 additions and their limits, see generics and strings and native aggregate locals.

See the separate alpha.5 Linux native-executable contract.

Search documentation

Tips: use "exact phrase", -exclude, title:term, body:term, or section:guide. Search stays on this device.