Native Backend
Choose between the Rust and Cranelift backends when compiling to native.
When compiling Tish to a native binary (tish compile --target native), you can select the native backend with --native-backend.
Backends
When to use each
Rust backend (default)
Use when your program:
- Imports native modules (
import { Egui } from 'tish:egui'or@scope/pkg) - Needs the full Rust ecosystem
- Uses any
tish:*or@scope/imports
tish compile main.tish -o app
# or explicitly:
tish compile main.tish -o app --native-backend rustCranelift backend
Use when your program:
- Has no native imports (pure Tish + file imports only)
- Benefits from a faster build (no cargo invocation)
- Does not need
tish:*or@scope/pkgmodules
tish compile main.tish -o app --native-backend craneliftIf your program uses native imports, the Cranelift backend will error:
Cranelift backend does not support native imports (tish:*, @scope/pkg). Use --native-backend rust.
Known limitations (Cranelift)
The Cranelift backend compiles bytecode to native via Cranelift JIT. Only a subset of Tish constructs are known to work reliably. Some constructs (e.g. nested loops, objects, optional chaining, spread, template literals, higher-order methods with certain patterns) may cause stack-underflow or scope bugs. The integration test suite uses a curated list of 17 core tests that pass. For full compatibility, use the Rust backend (--native-backend rust).
Target and feature flags
--native-backend applies only when --target native (the default). Other targets (js, wasm, wasi) ignore it.
For WebAssembly targets, see WASM Targets.
Feature flags (--feature http, etc.) apply to both backends when compiling to native.