Docs/Toolchain/Backends & Targets
Backends & Targets
Which backends Fid has, what each needs, and which platforms are supported today. No LLVM anywhere.
~3 min read
On this page
Supported platforms
| Platform | What works |
|---|---|
| Windows x64 | Interpreter, C backend, native .exe (PE) |
| Linux x64 | Interpreter, C backend |
Partly tested: native Linux executables for x86-64, ARM64 and RISC-V (fid emit --target), and Linux ARM64 and RISC-V through C with a cross-compiler. Experimental: macOS, WebAssembly, SPIR-V and bare metal.
Backends
| Backend | Command | Needs | Status |
|---|---|---|---|
| Interpreter | fid run | Nothing | Supported |
| C | fid ccompile, fid build (outside Windows) | A C compiler (zig cc, clang, gcc, MSVC cl, tcc) | Supported. --target aarch64-linux, riscv64-linux, x86_64-macos, aarch64-macos or wasm32-wasi cross-compiles with zig cc |
| PE | fid emit, fid build (Windows) | Nothing | Supported on Windows x64 |
| ELF64 | fid emit --target x86_64-linux, aarch64-linux, riscv64-linux | Nothing | Partly tested: static executables; 272, 273 and 271 of 317 suite programs match the interpreter (Nov 9, ARM64 and RISC-V under QEMU) |
| Mach-O | fid emit --target aarch64-macos, x86_64-macos | Nothing | Experimental: executables are written and checked for structure, not yet run on a Mac |
| WASM | fid wasm | Nothing | Experimental: modules validate and run under WASI; 316 of 344 suite programs match fid run (Nov 15) |
| SPIR-V | fid gpu --target spirv | Nothing | Experimental: output does not validate |
| Bare metal | fid emit --bare, fid emit --boot | Nothing | Experimental: an x86-64 Multiboot kernel that boots under QEMU (10 of 10 bare tests, Nov 15) |
The native emitters encode machine code and write the executable file themselves: no assembler, no linker. fid build --native, fid build-x86 and fid codegen belong to an older native path through PIR that crashes or writes wrong output; use fid emit.
The v0.8.0 installer was built on Nov 10: the Mach-O, WebAssembly and bare-metal results above are on the main branch only.
The native optimizer
fid emit runs an IR optimizer before encoding: inlining of small functions, constant folding and propagation, dead code removal, loop-invariant code motion and rewrite rules (the integer rules are proved with z3). Registers are assigned by a linear-scan allocator, integer and xmm. The Linux targets and fid emit --nat on Windows share one machine layer with its own register allocator.
Generated code is still slower than through C: fib(40) took 1.34 s native, 0.81 s through C and 0.53 s in Rust (Nov 2). All results are on Benchmarks.
Speed
Fid skips LLVM, which trades optimization maturity for a toolchain Fid controls end to end. The compiler (about 210K lines) compiles itself to C in about 40 s when it is built at -O2 (Nov 15); on Nov 6 the same job took about 133 s. The frozen Rust compiler takes about 21 s.
The repository has bench/run.sh (Fid against Rust, Zig, C++ and Go on four programs) and bench/check.sh, which fails when a benchmark slows down past a set limit. A CI workflow builds the base commit’s compiler and the change’s on one runner and compares them.
Good to know: the core library is type-checked once per compiler and
core.fdversion (a stamp in the temp directory skips it on later builds;FIDES_CHECK_CORE=1forces the check), and the build cache in.fidcache/keeps at most 64 files or 1 GB.