Native Linux executables, one ownership rule, a faster compiler
Nine days of work on fid, the self-hosted compiler. The v0.8.0-unstable installer was built on Nov 10 and holds the work up to that day; everything after it is on the main branch. The stable v1.0.0 release is still planned for December. The full suite was last run on Nov 2 with the frozen Rust compiler and has not been rerun with fid; each change below was checked with its own tests.
Native backends
- Linux without a C compiler:
fid emit --target x86_64-linux,aarch64-linuxorriscv64-linuxwrites a static ELF executable. One machine layer serves the three targets, with its own register allocator and a runtime built on system calls (threads, tasks, channels, sockets, processes). On Nov 9, 272, 273 and 271 of 317 suite programs matched the interpreter (ARM64 and RISC-V under QEMU). - Windows: the native backend has a linear-scan register allocator for integer and
xmmregisters, tasks switch on their own stacks, and sockets wait through IOCP.fid emit --natputs Windows on the same machine layer as Linux (opt-in; 301 of 338 suite programs). - Native
async/awaitworks: it broke in builds of Nov 9 afternoon and was fixed the same evening. - Bare metal (Nov 15):
fid emit --bareand--bootwrite an x86-64 Multiboot kernel that boots under QEMU; 10 of 10 bare tests pass. - WebAssembly (Nov 15):
fid wasmmodules validate and run under WASI; 316 of 344 suite programs matchfid run. - macOS (Nov 15): native Mach-O executables are written and checked for structure. They have not been run on a Mac.
fid ccompile --targetcross-compiles through C withzig ccforaarch64-linux,riscv64-linux,x86_64-macos,aarch64-macosandwasm32-wasi.
Memory and values
- One ownership rule (proposal 0004): a variable owns its value and the value is dropped at the end of its scope; keeping a value takes an owner; parameters are borrowed. Strings,
Vecbuffers and Boxes are reference-counted. - Value semantics:
var b = aon aVec,HashMaporstrgives an independent value, shared until the first write. Since Nov 15, copying a struct also separates itsVecfields. &v[i]and&mut v[i]are the element’s address, so writes through them reach the container.- A leak gate (
scripts/leak-check.sh) checks that test programs free every block.
The language
- Literals of generic structs of your own work (Nov 15):
Pair { first: 1, second: "a" }. - Match exhaustiveness covers generic enums such as
Option<T>and no longer counts a guarded arm as covering anything. --borrowck=warnprints its warnings, and the borrow checker follows casts and nested field writes.- A match guard on a
@secretvalue taints its arm, and file and socket writes are sinks. 5e3and2E-3lex as floats.
The optimizer and its checks
- A rule-based mid-end with an e-graph, constant propagation, loop-invariant code motion and tail recursion into loops, plus an IR verifier that can run after every pass.
- The 108 integer rewrite rules are proved with z3, and the instruction encoders are checked against clang’s assembler (1,181 forms, no mismatch).
tests/conformance/adds 104 programs, each checking one rule of the language reference.
Speed
- The compiler’s C is split into units and built at
-O2. Compiling itself to C takes about 40 s (Nov 15), down from about 133 s on Nov 6. - The fixpoint was verified again on Nov 8 (stage 2 == stage 3, 67 MB of C). Later changes were checked on one-stage builds.
- A CI workflow builds a change’s compiler and its base commit’s on one runner and compares the benchmarks.
Standard library and tools
- 163 modules. New: brotli and zstd decoders,
decimal,protobuf,tz(the IANA database),wss, Unicode normalization (NFC, NFD, NFKC, NFKD), a set of OS-development modules (elf,acpi,pci,virtio,multiboot,fdt,uart,pmm,slab),safetensors,bpeandinferfor model inference, andgltfandtiledloaders. fid lint --perfwarns about loop hazards, andfid explain file.fdlists which run-time checks the compiler removed or kept, and why (--alloc: the allocation sites and why each is on the heap).- The repository gained a book, a cookbook and guides for readers coming from Rust, Go, Zig and C.
Still open
The full suite has not been run with fid as the compiler under test. Native code is slower than code built through C. A Vec passed to a spawned call is shared with the caller, and writes from both threads are not detected. macOS output has not been run on a Mac, SPIR-V output does not validate, and build --native (the old PIR path) crashes. The current list is on the Feature Status page.