Skip to content

BuildLang 1.15.0

Latest

Choose a tag to compare

@HarperZ9 HarperZ9 released this 14 Nov 07:13
· 140 commits to main since this release
189164e

buildc can now write a runnable x86-64 executable and a binary WebAssembly module by itself, with no C compiler, assembler or linker. Both targets are experimental and cover a subset of the language; a program outside the subset is refused by name and no file is written. The C backend remains the only primary backend. In the language, a type's drop now runs, a handler clause can resume at the perform site, a range of a vector is a view, Option has its combinators, a failed unwrap or assert! stops the program, and a long list of programs that passed the check and then failed in the C compiler or ran wrong now build and run right. port translates a C subset to BuildLang in one step, and the five Build suite packages now live in this repository under suite/.

Tests: CI ran the suite on Linux and Windows on the release head. No local full-suite run was made for this release.

Experimental: x86-64 executables with no outside toolchain (#283)

  • buildc main.bld --target x86_64-native -o main.exe writes a runnable x86-64 executable: a PE32+ file on Windows, an ELF64 file on Linux. --target x86_64-windows and --target x86_64-linux choose the format. The compiler lowers its mid-level form to machine code, writes a small runtime as machine code and writes the file; no C compiler, assembler or linker runs.
  • Supported: integers up to 64 bits and bool, arithmetic including wrapping_*, comparisons, locals, if, while, loop, break, continue, calls and recursion (up to 4 arguments on Windows, 6 on Linux), and println/print with plain {} holes.
  • Refused by name, with no file written: floats, i128, structs, arrays, Vec, String values, eprintln, checked and saturating operations, asserts, indirect calls, runtime and extern calls, and format width and flags.
  • Checked by compiler/tests/native_exe.rs: nine programs are built with this target and their output and exit code compared with the C backend's, 9 of 9 equal on Windows x64. A planted fault (one flipped byte in the digit routine) makes the comparison fail. The ELF path was written on Windows; CI's Linux job is where it runs.
  • buildlang/docs/guide/native-targets.md has a table of constructs for the C, wasm and x86-64 executable targets.

Experimental: WebAssembly binary modules and libraries (#279, #280, #281)

  • buildc FILE.bld --target wasm (or wasm32) writes a binary WebAssembly module, encoded by the compiler itself. --target wat or -o NAME.wat writes the text form. The module exports main and memory, prints through host imports env.print_i64, env.print_u64, env.print_f64, env.print_bool and env.print_str, and runs in Node or a browser without WASI.
  • Every function body is a dispatch loop over its basic blocks, so any control flow lowers. Before, the wasm target wrote text only and a while loop whose header was not the first block compiled wrong.
  • Fixed arrays, Vec values, strings and structs lower into linear memory: arrays on a shadow stack that traps on overflow, a bump-allocated heap that grows the memory, and Vec and string handles. Index, get, set and pop trap out of bounds.
  • buildc lib.bld --target wasm builds a package as a library: the module exports every function it defines plus memory, __alloc and __str_new, and use dependencies resolve from the registry. compiler/wasm/loader.js (no dependencies) loads a module and builds and reads strings, byte vectors and vectors of handles.
  • Checked in Node by compiler/tests/wasm_node.rs against the C backend's output. The registry's sha256 package, unmodified, gives the digests Node's crypto gives for 3, 43 and 1000 bytes, and merkle gives the RFC 6962 roots for 1, 2, 3, 7 and 16 leaves.
  • Refused: array parameters and returns, field writes through a pointer, enum variants, globals, indirect calls, format! conversions other than %s and %Nx, and any runtime builtin without a wasm helper. No f64 program has been compared with the C backend, and print_f64 uses JavaScript number formatting, which differs from C's. The canonical-record, readability and color packages do not build for wasm yet.

Language

  • A type with impl Drop has its drop run: at scope end in reverse declaration order, on every loop iteration, on early return, and on reassignment. A moved value is not dropped. A struct with fields that have drop runs its own, then its fields' in declaration order. Moving such a field out of a value that is itself dropped is refused at check time. Not done yet, each a missing drop and never a double one: break, continue and ? leaving a block, a temporary never bound to a name, a let assigned later, enum and tuple fields, and a program that stops on a trap. (#277)
  • A handler clause whose every exit is resume(value) in tail position runs at the perform site: perform returns the value and the code after it runs. A clause with no resume ends the handle, as before. Any other resume is refused at check time with BL0383. Limits: 8 resuming clauses per handle, and captured locals are read-only inside one. A handle with two or more clauses now matches its clauses; before, none matched. (#278)
  • &v[a..b] on a Vec is a &[T] view with len, indexing and for, for a..b, ..b, a.., .. and a..=b. Before, it compiled as one element. An out-of-range view stops the program with exit code 101. Limit: a view returned from a function into that function's frame is not refused yet. (#278)
  • Option has map, and_then, unwrap_or, is_some and is_none. (#272)
  • s.parse::<T>() returns a Result and follows Rust's rules, and to_string() works on a bool. unwrap, expect and unwrap_err on the wrong case stop the program with exit code 101 and a message on stderr. Before, None.unwrap() read an empty slot, printed 0 and exited 0. (#274)
  • assert!, assert_eq!, assert_ne!, their debug_ forms, unreachable!, todo! and unimplemented! stop the program when they fail or are reached. Before, they were dropped with no diagnostic. A macro the compiler cannot lower is now a compile error that names it. (#242)
  • env!("NAME") is a compile-time string read from the compiler's environment; a variable that is not set is a compile error. The value is copied into the generated C and the binary, so it is not a place for a secret. (#243)
  • len() and is_empty() work on a fixed array, and for x in s works over a slice. (#275)
  • A fixed array passed by value and declared mut no longer writes into the caller's array. A global can be stored into, borrowed and sliced with bounds checks (TABLE.a = 5, G[i] = v), and static mut T: [u32; 3] = [7, 8, 9] keeps its initializer. A method with &mut self called on a field, an element or a mutable global now writes where the value lives; before, it wrote to a copy. (#255)

port: a C subset to BuildLang in one step (#258, #260, #262, #266)

  • port reads a C program and writes the same program in BuildLang with one command and no model in the loop. The tool is itself a BuildLang program under port/. A program that uses anything outside the subset is refused with each line listed, and nothing is written.
  • Covered: integer and float arithmetic, loops, recursion, arrays, formatted output, switch without fall-through, and numeric #define. Refused: structs, pointer parameters, a case that falls through, and macros with parameters.
  • port/check.sh, run by the port workflow: 5 of 5 corpus programs print what gcc's build prints, byte for byte, and 2 of 2 programs outside the subset are refused at their recorded lines.

The Build suite in suite/ (#256, #276, #282)

  • build-engine, build-ui, build-finance, build-oracle and build-ecosystem moved into suite/ with their history. Each keeps its own licence (FSL-1.1-MIT), version and changelog, and the suite workflow runs each package's tests. These are Python packages; this release publishes none of them to a package index.
  • build-finance gains an offline paper kernel (build_finance/live_paper) that replays local, schema-checked events with model inference disabled, and build-engine gains capital-replay, which replays a local fixture and can write a receipt. (#276)
  • build-finance gains one order gate: a kill switch (an in-process flag and a HALT file), enforced stops on every buy, and order ids derived from the order's content so a repeat returns the first result. Tested with an in-memory fake broker only; the live broker adapter and the GUI path were not run. It makes no claim about profit or accuracy. (#282)

Fixes

  • A slice is a value in the emitted C: a &[T] or &mut [T] parameter, return value, local, struct field or Vec element is its BlSlice_T struct {ptr, len} carried by value. Before, the view was the address of a struct built in the frame that created it, so a function returning &v[1..3] returned the address of its own dead frame, and a call in a loop reused one struct for every iteration. Hand-written C that includes the emitted file and calls a function taking a slice passes the struct, not its address (saxpy(2.5f, sa, sb, so)). extern "C" exports still refuse a &[T] parameter with BL0901; pass a pointer and a length, as docs/C-ABI.md shows. Tests: tests/features/slice_return_outlives_callee.bld, slice_views_kept_across_loop.bld, slice_return_fn_value_and_discard.bld, slice_empty_literal.bld, slice_struct_field.bld.
  • &[] where a &[T] is expected (a let annotation, a return, an argument) is the empty view {NULL, 0}. Before, it lowered to an i32.
  • A range of a slice or a fixed array is a view: &s[1..], &s[..2], &s[1..=2], &a[2..], and for x in &a[..3], so total(tail(tail(&a))) works. The range is checked against the length and stops the program with exit code 101 when it is out of bounds. Before, the range lowered as an element index and the C read an undeclared temporary. Test: tests/features/slice_range_views.bld.
  • A vector can hold slices: let mut keep: Vec<&[i32]> = Vec::new(); keep.push(&v[i..i + 2]);. Before, the check refused the element type.
  • A function can return a closure: fn adder(k: i32) -> impl Fn(i32) -> i32 { move |x: i32| -> i32 { x + k } }, then let f = adder(4); f(5). The function returns the captured values as one struct, and a call through the result calls the closure's function with them, so nothing is allocated. The closure has to be the last expression of the body. Not done yet: passing a returned closure on to another function, storing one in a struct field, and returning one from a return statement. Test: tests/features/closure_returned_forms.bld.
  • A closure or a function can be passed to a generic parameter: fn apply<F: Fn(i32) -> i32>(f: F, v: i32) -> i32 { f(v) } called with |x: i32| -> i32 { x + k }, with a closure held in a variable, or with a function's name. The callee is specialised for the closure, and the values the closure captured travel as extra arguments, so nothing is allocated. The closure can be passed on to another generic function. Before, the check refused every one of these. Test: tests/features/closure_generic_forms.bld.
  • Which locals hold a closure is now tracked for each function. Before, the record was shared by every function, so a local in one function could be read as a closure from another with the same number.
  • pop works on a vector of strings: let last: String = v.pop();. An empty vector gives an empty string. Before, the check refused it, because the runtime had no such function.
  • A type alias works in compiled code: type Meters = f64;, type Point = P;, in a let, a signature, a struct literal and a format argument. Before, the check refused a value of an aliased type in println!. Limit: only aliases declared at the top level of the file.
  • A trait's default methods reach every type that implements the trait: with trait Named { fn base(&self) -> i32; fn twice(&self) -> i32 { self.base() * 2 } }, a.twice() works for an impl Named for A that writes only base, and an impl that writes its own twice keeps it. Before, the check refused the call. Limit: only traits declared at the top level of the file.
  • A function with a value can end in a loop that only leaves through return: fn f(n: i32) -> i32 { loop { return n + 1; } }, also as a method. Before, the check passed and the C compiler stopped on a returned unit value. A body that reaches its end with no value now stops the program there. Known gap: the check still accepts a body ending in a while, or in a loop left by a plain break, where it should refuse it.
  • A constant or static can be named like a C macro or a platform type: EOF, NULL, TRUE, INFINITY, errno, and LONG and IN on Windows. Before, 9 of 11 such names tried on Windows passed the check and failed in the C compiler. Every global the program defines is now written to C under its own prefixed name; a foreign static keeps the name of its C symbol. Tests: tests/features/global_named_like_c_header.bld.
  • A constant or static whose initializer is an expression now holds its value. Before, only a literal, a negated literal or another constant's name was evaluated; anything else left the C global at zero with no diagnostic, so const N: i32 = 3 + 4; read as 0, as did 1 << 40, 3 as f64, (4), 17 % 5 and 0xF0 | 0x0F. Arithmetic, bit operations, shifts, comparisons, !, parentheses and as casts between number types are now evaluated at compile time, in a const, a static and an associated constant. An initializer that cannot be evaluated, such as a function call or a division by zero, is a compile error that names the constant. Tests: tests/features/const_expressions.bld.
  • A string constant holds its text: const NAME: &str = "abc";, and the same with String or static. Before, the global was a null string, and printing it crashed or printed (null). Tests: tests/features/const_strings.bld.
  • A bool constant prints true or false and a char constant prints its character. Before, println!("{}", B) with const B: bool = true; crashed, and a char constant printed its code.
  • String methods work on a borrowed string: fn n(s: &str) -> usize { s.len() }, and trim, starts_with, ends_with, contains and the rest. Before, the check refused them. r + s with r a borrowed string joins the two.
  • A generic function called with a computed argument now gets that argument's type. Before, pick(1.0 + 0.5, 2.5, true) passed the check, built, and printed 1: an argument that was a call, a field, an index, a negation, a cast or a method result was typed i32 and truncated. Tests: tests/features/generic_*.bld.
  • let P { x, y } = p; builds and runs. Before, a struct pattern in let passed the check and failed in the C compiler.
  • == and != on a struct compare field by field, with string fields compared by contents. On an enum they compare the tag and then the data of the variant both values hold. Both passed the check before and failed in the C compiler. Limit: an enum variant that holds a string, a struct or a collection is not covered yet.
  • A function held in a struct field can be called: (ops.apply)(21), also after the struct is destructured. Before, the call's result was typed i32, so a function returning a string failed in the C compiler after a passing check.
  • An associated constant is usable: impl P { const DIM: i32 = 3; } and P::DIM. Before, the check passed and the C compiler reported P_DIM undeclared.
  • A program can define a function named like a C library or runtime function: log, read, write, open, close, time, print, printf, strlen, sqrt and the rest of a list of 274 names. Before, 33 of 58 ordinary names tried either failed in the C compiler or silently called the library function (fn print(x: i32) -> i32 { x + 1 } called as print(2) printed 20). Such a function is now lowered under its own C name, and calls and references follow it. Limit: exit is still treated as the built-in by the check.
  • Two handle expressions in one function build. Before, both used the same C labels and the C compiler stopped with "duplicate label".
  • tests/features holds one small program per language feature with its expected output, and compiler/tests/feature_matrix.rs runs them all. tests/features/GAPS.txt lists the features that do not work yet; the test fails when a listed gap starts working, so the list stays true.
  • A struct literal with a fixed-array field beside other fields now holds the values written. Before, P { tag: 7, w: [1, 2, 3], z: -9 } built and ran with the array's address in w[0] and every later field shifted, with no diagnostic. The C backend builds such a struct one field at a time. Tests: compiler/tests/struct_array_fields.rs, with matrix programs for every integer width, five array lengths and three field positions whose expected output is written by compiler/tests/fixtures/struct_arrays/gen_matrix.py.
  • A store into an element of an array that is a struct field or an element of another array now reaches the array: q.w[1] = 42, self.w[i] = v, o.arr[i].w[j] += 1, grid[i][j] = v, xs[i].y = v with xs: &mut [S], and v[i].w[j] = x with a vector of structs. Before, the store went to a temporary copy and was lost. Whole-array stores such as s.w = [4, 5, 6] compile; before, the C compiler rejected them.
  • Every index in a store or borrow through a place is bounds-checked. Before, arr[9].y = v on an array of two structs wrote past the array with no trap; &mut a[i] was unchecked as well. An index out of range now stops the program with exit code 101 and the message other index checks print.
  • An array field borrowed as a slice is the field itself, with its length: sum(&s.bits) and fill(&mut s.bits) read and write the struct. The same holds for an element of an array of arrays and for an array returned by a call.
  • A &Vec<T> or &[T; N] the function already holds can be passed on to a &[T] parameter, also as &*v. Before, the reference itself was passed, the callee read a vector handle or the first bytes of the array as a slice, and the program printed wrong values or crashed. Same family as the &v fix below. Tests: compiler/tests/vec_ref_as_slice.rs.
  • S { a: 9, ..base } takes every field it does not write from base. Before, the ..base part was ignored and those fields read as zero: T { b: 20, ..t } with t = T { a: 1, b: 2, c: 3 } printed 0 20 0. Same test file as the struct literals.
  • Two constants or statics of one name in one module are reported by buildc check with BL0380, on the line of the second, naming the line of the first. Before, the check passed and the C compiler stopped with "redefinition". Tests: compiler/tests/duplicate_consts.rs.
  • The minimum of a signed integer type can be written as a negated literal: -128_i8, -32768_i16, -2147483648_i32, -9223372036854775808_i64, the isize and i128 minimums, and the unsuffixed forms under a type annotation. Before, the literal was range-checked before the minus sign applied and was rejected. Tests: compiler/tests/signed_min_literals.rs.
  • Three shapes that compiled to wrong code are now compile errors with a fix hint, until they are supported: a tuple or an enum variant that holds a fixed array, a field store into a global struct (G.a = 5 was dropped), and an element store into an array that is a call result.
  • &v with v: Vec<T> passed to a &[T] or &mut [T] parameter now passes a slice of the vector's elements. Before, the vector handle itself was passed, the callee read it as a slice, and the program crashed at run time; the type check and the C compiler both accepted it. The slice is built at the call from the vector's buffer and length, so a &mut [T] callee writes into the vector. A vector held in a struct field (&bag.items) and a binding let s: &[T] = &v; take the same view. A vector of another element type is refused with an error that names both types. Not covered: a vector reached through an index or a call result, and method-call arguments. The type check still treats Vec<T> as an unknown type, so it does not catch a vector passed to an unrelated parameter type.
  • let s: &[T] = &a; with a a fixed array now binds a slice with the array's length. Before, the slice had length 0: a loop over it ran no times and any index was reported out of bounds.
  • A borrowed string on the left of a comparison now compares contents. Before, fn is_x(cmd: &str) -> bool { cmd == "x" } passed the type check and then failed in the C compiler ("invalid operands to binary =="), and fn same(a: &str, b: &str) -> bool { a == b } built and compared the two addresses, so equal strings at different addresses were unequal. ==, !=, <, <=, > and >= now load through the reference when it comes from a & parameter, a let with a & annotation, a &expr initializer, a copy of one of those, or a &expr operand. Two raw pointers still compare addresses. Limit: a reference read from a struct field, a function return value or a pattern binding is not tracked, so comparing two of those still compares addresses.
  • A const or static declared later in the source than a function that uses it now keeps its declared type in that function. Before, the C backend stored BASE + 8_u64 with const BASE: u64 = 0x80000000_u64; at the end of the file in an int32_t temporary, so the result was sign-extended to ffffffff80000008 with no diagnostic. Globals are now registered before any function body is lowered. Packages are joined in file-name order, so the bug depended on file names. Test: compiler/tests/global_decl_order.rs.
  • TICKS + 1 with static mut TICKS: u64 called the 32-bit signed add helper, because the C backend took the helper width from the literal when the other operand was a global. It now takes it from the global, so the counter passes 2^32. Same test file.
  • ptr::read_volatile(p) and ptr::write_volatile(p, v) now compile for a raw pointer to any integer width. The spellings std::ptr::, core::ptr::, ptr_read_volatile and ptr_write_volatile are accepted too. Each lowers to one C volatile access, so a status register read in a loop condition is read on every iteration. Before, both failed to compile. The method form p.read_volatile() does not exist yet. Test: compiler/tests/lowlevel_access.rs.
  • asm! is no longer dropped. Before, unsafe { asm!("hlt"); } built with an empty function body. A call with string-literal templates only, such as asm!("cli", "hlt"), now lowers to __asm__ __volatile__(...) with one template per line. A call with operands or options is a compile error that names the line and says operands are not supported yet. Same test file.
  • Only the C backend lowers volatile access and asm!. Every other target now refuses a program that uses them with an error, instead of emitting a call to a function that does not exist.

Registry

  • emu-rv64 0.1.0 (AGPL-3.0-only): the core of a RISC-V machine emulator in pure .bld. It decodes, encodes and executes the 52 instructions of RV64I, the 64-bit base integer set, against caller-supplied registers and memory, with one serial output device. The step function is total and deterministic, and a step that fails changes nothing. It is checked by 61 hand-computed instruction cases, two short programs, a bit-serial reference model that shares no code with the core, a seeded differential fuzz run, encode and decode round trips, and six planted-defect controls that both checks must refuse. No other emulator was used. It has no control and status registers, traps, interrupts or timer yet, and no kernel has run on it.
  • emu-rv64 0.2.0 (AGPL-3.0-only): the emulator core can now take a trap. It adds the six Zicsr instructions, the machine-mode control and status registers mstatus, misa, mie, mtvec, mscratch, mepc, mcause, mtval and mip, seven synchronous trap causes, and MRET. A new constructor, emu_new_machine(), selects the trap profile; emu_new() keeps the 0.1.0 behaviour, and the 0.1.0 checks print the same bytes on the new build. The trap profile is checked by 59 hand-computed cases, a hand-assembled trap-handler program, a second reference model compared on every register and CSR after every step, round trips, and six more planted-defect controls. No interrupt is delivered and there is no timer yet.
  • emu-rv64 0.3.0 (AGPL-3.0-only): the emulator core can now be interrupted. The trap profile gains a timer device, mtime and mtimecmp at the addresses the QEMU virt machine uses, where mtime counts steps and no host clock is read, so a run repeats exactly. It delivers the machine timer, software and external interrupts before the fetch, in direct or vectored mode, and WFI retires as a no-op. It is checked by 56 more hand-computed cases, a hand-assembled timer program whose 99 interrupts in 10000 steps were worked out by hand and whose whole-state hash is equal across two runs, a third reference model compared on every register, CSR and timer register after every step of a stream with frequent interrupts, five rules judged without a model, and seven more planted-defect controls. The report profile and the earlier checks print the same bytes. Its interrupt rules were written from memory and then compared with the machine-level chapter of the privileged manual, which states each of them; the WFI word and the two timer addresses are still unconfirmed, as the package's Limits say. WFI does not wait, there is no interrupt controller, and no kernel has run on it.
  • emu-rv64 0.4.0 (AGPL-3.0-only): the emulator can now run a program from a file and show that the run repeats. A flat image, raw bytes with no header, is loaded at 0x80000000 into zeroed memory with the machine in its reset state; a missing file, an empty file and an image larger than memory are each refused with their own message and exit status. run IMAGE STEPS runs the image and prints the counters and a hash of the whole state. replay IMAGE STEPS runs it twice from scratch, records the state hash after every 1000 steps and at the end, and exits with status 1 at the first checkpoint where the two runs differ. The committed image tests/timer.img (88 bytes) is the 0.3.0 timer program: it takes 99 interrupts in 10000 steps and ends with the hash f1b4f1df12342aae, the value 0.3.0 printed for the same program loaded word by word. It is checked by 27 hand-computed cases, eight property rules on seeded random images with no model, and seven more planted-defect controls that the cases and the rules must each refuse. Every earlier command prints the same bytes. Replay shows that this emulator repeats itself on one host and does not compare it with hardware; the checks have the same author as the code, no architecture test has been run, and no kernel has run on it. The package cannot write an image file, so the test image was made from its hexadecimal output with a host tool.
  • asm-rv64 0.1.0 (AGPL-3.0-only): a text assembler for the instructions the emu-rv64 core executes: RV64I, the six Zicsr instructions, MRET and WFI. The source is one statement to a line with # comments, labels, registers x0 to x31, decimal and hex numbers, loads and stores written imm(rs1), branch and jump targets as labels or byte offsets, CSRs by number or by the 14 names the core implements, and the directives .word and .org. It depends on emu-rv64 0.4.0 and calls that package's encoder, so the emulator and the assembler share one encoder and the assembler holds no bit layout; emu-rv64 is unchanged. asm FILE prints the words and bytes FILE the image as hex, dis FILE prints the text of hex words, and match, same and hand compare an assembled file with a built-in image of the emulator, an image file, or the words of a golden file. Every wrong line is reported with its number and one of 18 reasons, a file with any error gives no word, and no value is cut to fit a field. tests/timer.s assembles to the 88 bytes of the emulator's tests/timer.img, tests/trap.s to its trap image, and three text files to the 170 instruction words of the emulator's hand-computed cases. It is checked by 359 hand cases, nine property rules on seeded random instructions, words and programs against the emulator's encoder and decoder, and ten planted-defect controls that the cases and the rules must each refuse. There are no pseudo-instructions and no register names of the calling convention, and fence is written with its three fields. The assembler and its checks have one author, no comparison against any other assembler was run, and the field layouts were not read from the manual for this version. The package cannot write an image file, so an image is made from the output of bytes with a host tool.
  • emu-rv64 0.5.0 (AGPL-3.0-only): the trap profile of the emulator now executes the M extension (MUL, MULH, MULHSU, MULHU, DIV, DIVU, REM, REMU and the five 32-bit forms) and the A extension (LR, SC and nine AMOs, each in a 32-bit and a 64-bit width). Division by zero and signed overflow give the values the manual fixes and never trap. An atomic instruction at an address that is not a multiple of its width traps with cause 4 or 6, and one outside memory with cause 5 or 7. The machine has one hart, a single hardware thread of execution. The reservation, the mark LR leaves and SC checks, is ended by every SC and by nothing else, and an SC stores only at the address and width of its LR; SPEC.md says which of these rules the manual fixes and which are choices of this machine. misa now reports A, I and M. The checks are 398 hand cases whose words and expected values a separate Python script computed from the manual text with unbounded integers, a reference model for the two extensions compared after every step of a stream weighted toward M and A words and edge operands, fourteen property rules with no model, and eleven more planted-defect controls that all three checks refuse. tests/mulatomic.img, a program assembled by asm-rv64 0.2.0, multiplies, divides and runs an LR and SC loop whose first SC fails; it reaches its own pass label within 100 steps and replays to equal hashes. Every encoding and every rule of the two extensions was read from the manual text, none from memory. The report profile is unchanged and still has neither extension. 21 of the 26 earlier commands print the same bytes; mcases, both mfuzz seeds, ifuzz 7 50000 and mcontrols changed, because misa changed and because a few random words that were illegal are now M or A instructions. show_refusal moved into a library file, so a dependent package needs no copy. The atomic instructions run on one hart only, so no interleaving is tested; the script, the model and the core have one author; no architecture test has been run; everything ran on one host.
  • asm-rv64 0.2.0 (AGPL-3.0-only): the assembler now covers the M and A extensions of emu-rv64 0.5.0, on which it depends. The 13 multiply and divide mnemonics take rd, rs1, rs2. The atomic forms are written as the manual's examples write them, lr.d rd, (rs1), sc.d rd, rs2, (rs1) and amoadd.w rd, rs2, (rs1), with the suffixes .aq, .rl and .aqrl for the two ordering bits; an address with an offset is refused with the new reason expected (rs1). dis prints every word the 0.5.0 decoder accepts as text that assembles back to it. tests/mulatomic.s computes with MUL, DIV and REM and adds to a doubleword in an LR and SC retry loop; its expected registers are worked out by hand in its comment, a hand case assembles it and runs it on the emulator core against that working, and its 200 bytes equal the image emu-rv64 runs. There are 100 more hand cases, 459 in all; the words of the new single statements come from a Python script that holds the bit rows of the manual's instruction listing and shares no code and no table with the encoder. tests/hand-xcases.s assembles to the 398 instruction words of the emulator's new hand cases. Three more planted defects (source registers swapped, .w assembled as .d, the register in brackets dropped) are refused by the cases and by the property rules, thirteen in all. The package no longer carries a copy of show_refusal. One author wrote the assembler, the script and the emulator, no other assembler was used, the address is written (rs1) only, and there are still no pseudo-instructions.
  • emu-rv64 0.6.0 (AGPL-3.0-only): the emulator gains a third profile, the system profile, made by emu_new_system(): the privilege modes M, S and U, the supervisor CSRs (sstatus, sie, sip, stvec, sscratch, sepc, scause, stval, satp, scounteren, senvcfg) with medeleg, mideleg, mcounteren and menvcfg, CSR access checked from the bits of the CSR number, trap delegation, SRET, MRET to any mode, WFI under TW, SFENCE.VMA and satp under TVM, SRET under TSR, the three supervisor interrupts, and Sv39 address translation for the fetch, loads, stores and the atomic instructions, with SUM, MXR and MPRV and the page faults 12, 13 and 15. The machine never writes a page table entry: a clear A bit, or a clear D bit on a store, is a page fault, which the manual permits. It keeps no translation cache, so SFENCE.VMA only checks privilege and a program that forgets it cannot fail here, and it has no physical memory protection. The trap profile stays a machine with M-mode alone and the report profile is unchanged: the 34 commands of 0.5.0 print the same bytes, and no old golden changed. The checks are 875 hand cases and a permission matrix of 3456 rows, all computed from the manual text by a separate Python script that shares no code and no table with the package; a second implementation of the profile compared after every step of a seeded stream with drawn page tables, CSR states and modes (18,070,000 steps accepted over seven seeds); thirteen kinds of property rule with no model; and twenty planted defects, each refused by the hand cases, the differential check and the rules. tests/sv39.img, assembled by asm-rv64 0.3.0, builds page tables in M-mode, delegates, runs supervisor and user code, takes an environment call and a load page fault in the supervisor, and ends in the register state worked out by hand; it replays to equal hashes. Every rule carries the sentence of the manual it follows, and SPEC.md marks each choice the text leaves open. The planted defects of this profile are branches inside the core behind a variant number that is 0 in use. One hart, one author for the core, the model and the script, no architecture test, no other emulator, no kernel yet; field positions came from the manual's figure files.
  • asm-rv64 0.3.0 (AGPL-3.0-only): the assembler now covers the statements of the system profile of emu-rv64 0.6.0, on which it depends: sret, sfence.vma rs1, rs2, and the names of the fifteen CSRs that profile adds, 29 names in all. dis prints the two new words as text that assembles back to them. tests/sv39.s is the test program of the system profile, with its end state worked out by hand in its comment; its 4132 bytes equal the image emu-rv64 runs. There are 34 more hand cases, 493 in all; the words of the new statements come from the Python script of emu-rv64 0.6.0, which holds the bit rows of the manual's listings. One old case changed: it refused sstatus as an unknown CSR name and now refuses hstatus. The thirteen planted defects of 0.2.0 are still refused by the cases and by the property rules; none was added for the new statements. The assembler does not run the program, has no expression for the distance to a label, and still has no pseudo-instructions.
  • cg-rv64 0.1.0 and 0.2.0 (AGPL-3.0-only): a code generator written in BuildLang that reads the JSON buildc mir emit writes and prints RV64IM assembly for asm-rv64, so BuildLang programs run on emu-rv64. cg-rv64 run MIR ENTRY MAX generates, assembles and emulates in one step. The operation traces of os-pfa and os-runq are byte-equal between the host build and a run inside the emulator. 0.2.0 adds struct literals with an array field and globals. With it come emu-rv64 0.7.0 (a serial run with 4 MiB of memory and a halt convention) and asm-rv64 0.4.0 (a 1 MiB image and 65536 labels). (#252, #255)
  • os-pfa and os-runq 0.1.0 (AGPL-3.0-only): the host-testable cores of two operating-system kernel subsystems in pure .bld. os-pfa is a page-frame allocator over a caller-supplied bitmap; os-runq is a round-robin run queue over a caller-supplied ring. Each has an exact contract in SPEC.md, a reference model that shares no data structure with the core, hand-derived golden cases, a seeded differential fuzz run, model-free property checks, and four planted-defect controls that both checks must refuse. Neither has run inside a kernel.

A kernel package with a gated improvement loop

  • sum-det 0.1.0 in the registry adds a list of binary64 floats in a written order (serial, tree2, interleave8) and returns the same bits on every run. Two functions that share no code (sd_fsum, sd_binned) return the exact sum rounded once. Goldens come from ref/reference.py, which takes the exact sum from Python math.fsum and from a fractions.Fraction sum; the inputs include cancellation, half-way cases, subnormals and values near overflow.
  • src/i8.bld is a slot. A faster version replaces it only through the loop under improve/, which runs lint, buildc tv, the cases, the properties, a seeded fuzz run against the reference, a paired benchmark and a hold-out set, with six planted-wrong slots in the same run. The first run refused all six controls and one of three proposals (gain 1.6 percent, interval 1.0 to 2.2, under the 5 percent threshold set before the run). It promoted unroll8: 67.5 percent less time at 65,536 values over 20 paired rounds, 95 percent interval 67.1 to 67.8, on one x86-64 Windows machine with gcc 13.2.0 at -O2. Every decision is a line in improve/LEDGER.jsonl.
  • The loop cannot change its own cases, controls, hold-out or threshold: improve/FROZEN.sha256 lists their digests, the loop checks them before the first step and before a promotion, and compiler/tests/kernel_improve.rs checks the list and the ledger chain in CI with four planted faults that must be refused.
  • The loop is BuildLang except for improve/spawn.py, which starts the processes. BuildLang has no builtin that starts a process.