Repository navigation
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.exewrites a runnable x86-64 executable: a PE32+ file on Windows, an ELF64 file on Linux.--target x86_64-windowsand--target x86_64-linuxchoose 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 includingwrapping_*, comparisons, locals,if,while,loop,break,continue, calls and recursion (up to 4 arguments on Windows, 6 on Linux), andprintln/printwith plain{}holes. - Refused by name, with no file written: floats,
i128, structs, arrays,Vec,Stringvalues,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.mdhas 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(orwasm32) writes a binary WebAssembly module, encoded by the compiler itself.--target wator-o NAME.watwrites the text form. The module exportsmainandmemory, prints through host importsenv.print_i64,env.print_u64,env.print_f64,env.print_boolandenv.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
whileloop whose header was not the first block compiled wrong. - Fixed arrays,
Vecvalues, strings and structs lower into linear memory: arrays on a shadow stack that traps on overflow, a bump-allocated heap that grows the memory, andVecand string handles. Index,get,setandpoptrap out of bounds. buildc lib.bld --target wasmbuilds a package as a library: the module exports every function it defines plusmemory,__allocand__str_new, andusedependencies 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.rsagainst the C backend's output. The registry'ssha256package, unmodified, gives the digests Node'scryptogives for 3, 43 and 1000 bytes, andmerklegives 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%sand%Nx, and any runtime builtin without a wasm helper. Nof64program has been compared with the C backend, andprint_f64uses JavaScript number formatting, which differs from C's. Thecanonical-record,readabilityandcolorpackages do not build for wasm yet.
Language
- A type with
impl Drophas itsdroprun: 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 havedropruns 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,continueand?leaving a block, a temporary never bound to a name, aletassigned 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 theperformsite:performreturns the value and the code after it runs. A clause with noresumeends thehandle, as before. Any otherresumeis refused at check time with BL0383. Limits: 8 resuming clauses perhandle, and captured locals are read-only inside one. Ahandlewith two or more clauses now matches its clauses; before, none matched. (#278) &v[a..b]on aVecis a&[T]view withlen, indexing andfor, fora..b,..b,a..,..anda..=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)Optionhasmap,and_then,unwrap_or,is_someandis_none. (#272)s.parse::<T>()returns aResultand follows Rust's rules, andto_string()works on abool.unwrap,expectandunwrap_erron 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!, theirdebug_forms,unreachable!,todo!andunimplemented!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()andis_empty()work on a fixed array, andfor x in sworks over a slice. (#275)- A fixed array passed by value and declared
mutno 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), andstatic mut T: [u32; 3] = [7, 8, 9]keeps its initializer. A method with&mut selfcalled 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)
portreads 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 underport/. 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,
switchwithout fall-through, and numeric#define. Refused: structs, pointer parameters, acasethat falls through, and macros with parameters. port/check.sh, run by theportworkflow: 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-oracleandbuild-ecosystemmoved intosuite/with their history. Each keeps its own licence (FSL-1.1-MIT), version and changelog, and thesuiteworkflow runs each package's tests. These are Python packages; this release publishes none of them to a package index.build-financegains an offline paper kernel (build_finance/live_paper) that replays local, schema-checked events with model inference disabled, andbuild-enginegainscapital-replay, which replays a local fixture and can write a receipt. (#276)build-financegains 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 orVecelement is itsBlSlice_Tstruct{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, asdocs/C-ABI.mdshows. 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 (aletannotation, a return, an argument) is the empty view{NULL, 0}. Before, it lowered to ani32.- A range of a slice or a fixed array is a view:
&s[1..],&s[..2],&s[1..=2],&a[2..], andfor x in &a[..3], sototal(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 } }, thenlet 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 areturnstatement. 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.
popworks 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 alet, a signature, a struct literal and a format argument. Before, the check refused a value of an aliased type inprintln!. 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 animpl Named for Athat writes onlybase, and an impl that writes its owntwicekeeps 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
loopthat only leaves throughreturn: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 awhile, or in aloopleft by a plainbreak, 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, andLONGandINon 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 foreignstatickeeps 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 as0, as did1 << 40,3 as f64,(4),17 % 5and0xF0 | 0x0F. Arithmetic, bit operations, shifts, comparisons,!, parentheses andascasts between number types are now evaluated at compile time, in aconst, astaticand 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 withStringorstatic. Before, the global was a null string, and printing it crashed or printed(null). Tests:tests/features/const_strings.bld. - A
boolconstant printstrueorfalseand acharconstant prints its character. Before,println!("{}", B)withconst B: bool = true;crashed, and acharconstant printed its code. - String methods work on a borrowed string:
fn n(s: &str) -> usize { s.len() }, andtrim,starts_with,ends_with,containsand the rest. Before, the check refused them.r + swithra 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 printed1: an argument that was a call, a field, an index, a negation, a cast or a method result was typedi32and truncated. Tests:tests/features/generic_*.bld. let P { x, y } = p;builds and runs. Before, a struct pattern inletpassed 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 typedi32, 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; }andP::DIM. Before, the check passed and the C compiler reportedP_DIMundeclared. - A program can define a function named like a C library or runtime function:
log,read,write,open,close,time,print,printf,strlen,sqrtand 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 asprint(2)printed20). Such a function is now lowered under its own C name, and calls and references follow it. Limit:exitis still treated as the built-in by the check. - Two
handleexpressions in one function build. Before, both used the same C labels and the C compiler stopped with "duplicate label". tests/featuresholds one small program per language feature with its expected output, andcompiler/tests/feature_matrix.rsruns them all.tests/features/GAPS.txtlists 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 inw[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 bycompiler/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 = vwithxs: &mut [S], andv[i].w[j] = xwith a vector of structs. Before, the store went to a temporary copy and was lost. Whole-array stores such ass.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 = von 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)andfill(&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&vfix below. Tests:compiler/tests/vec_ref_as_slice.rs. S { a: 9, ..base }takes every field it does not write frombase. Before, the..basepart was ignored and those fields read as zero:T { b: 20, ..t }witht = T { a: 1, b: 2, c: 3 }printed0 20 0. Same test file as the struct literals.- Two constants or statics of one name in one module are reported by
buildc checkwith 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, theisizeandi128minimums, 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 = 5was dropped), and an element store into an array that is a call result. &vwithv: 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 bindinglet 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 treatsVec<T>as an unknown type, so it does not catch a vector passed to an unrelated parameter type.let s: &[T] = &a;withaa 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 =="), andfn 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¶meter, aletwith a&annotation, a&exprinitializer, a copy of one of those, or a&exproperand. 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
constorstaticdeclared later in the source than a function that uses it now keeps its declared type in that function. Before, the C backend storedBASE + 8_u64withconst BASE: u64 = 0x80000000_u64;at the end of the file in anint32_ttemporary, so the result was sign-extended toffffffff80000008with 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 + 1withstatic mut TICKS: u64called 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)andptr::write_volatile(p, v)now compile for a raw pointer to any integer width. The spellingsstd::ptr::,core::ptr::,ptr_read_volatileandptr_write_volatileare accepted too. Each lowers to one Cvolatileaccess, so a status register read in a loop condition is read on every iteration. Before, both failed to compile. The method formp.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 asasm!("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-rv640.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-rv640.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 registersmstatus,misa,mie,mtvec,mscratch,mepc,mcause,mtvalandmip, 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-rv640.3.0 (AGPL-3.0-only): the emulator core can now be interrupted. The trap profile gains a timer device,mtimeandmtimecmpat the addresses the QEMUvirtmachine uses, wheremtimecounts 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-rv640.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 at0x80000000into 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 STEPSruns the image and prints the counters and a hash of the whole state.replay IMAGE STEPSruns 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 imagetests/timer.img(88 bytes) is the 0.3.0 timer program: it takes 99 interrupts in 10000 steps and ends with the hashf1b4f1df12342aae, 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-rv640.1.0 (AGPL-3.0-only): a text assembler for the instructions theemu-rv64core executes: RV64I, the six Zicsr instructions, MRET and WFI. The source is one statement to a line with#comments, labels, registersx0tox31, decimal and hex numbers, loads and stores writtenimm(rs1), branch and jump targets as labels or byte offsets, CSRs by number or by the 14 names the core implements, and the directives.wordand.org. It depends onemu-rv640.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-rv64is unchanged.asm FILEprints the words andbytes FILEthe image as hex,dis FILEprints the text of hex words, andmatch,sameandhandcompare 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.sassembles to the 88 bytes of the emulator'stests/timer.img,tests/trap.sto 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, andfenceis 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 ofbyteswith a host tool.emu-rv640.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.mdsays which of these rules the manual fixes and which are choices of this machine.misanow 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 byasm-rv640.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, bothmfuzzseeds,ifuzz 7 50000andmcontrolschanged, becausemisachanged and because a few random words that were illegal are now M or A instructions.show_refusalmoved 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-rv640.2.0 (AGPL-3.0-only): the assembler now covers the M and A extensions ofemu-rv640.5.0, on which it depends. The 13 multiply and divide mnemonics takerd, rs1, rs2. The atomic forms are written as the manual's examples write them,lr.d rd, (rs1),sc.d rd, rs2, (rs1)andamoadd.w rd, rs2, (rs1), with the suffixes.aq,.rland.aqrlfor the two ordering bits; an address with an offset is refused with the new reasonexpected (rs1).disprints every word the 0.5.0 decoder accepts as text that assembles back to it.tests/mulatomic.scomputes 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 imageemu-rv64runs. 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.sassembles to the 398 instruction words of the emulator's new hand cases. Three more planted defects (source registers swapped,.wassembled 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 ofshow_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-rv640.6.0 (AGPL-3.0-only): the emulator gains a third profile, the system profile, made byemu_new_system(): the privilege modes M, S and U, the supervisor CSRs (sstatus,sie,sip,stvec,sscratch,sepc,scause,stval,satp,scounteren,senvcfg) withmedeleg,mideleg,mcounterenandmenvcfg, CSR access checked from the bits of the CSR number, trap delegation, SRET, MRET to any mode, WFI under TW, SFENCE.VMA andsatpunder 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 byasm-rv640.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, andSPEC.mdmarks 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-rv640.3.0 (AGPL-3.0-only): the assembler now covers the statements of the system profile ofemu-rv640.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.disprints the two new words as text that assembles back to them.tests/sv39.sis the test program of the system profile, with its end state worked out by hand in its comment; its 4132 bytes equal the imageemu-rv64runs. There are 34 more hand cases, 493 in all; the words of the new statements come from the Python script ofemu-rv640.6.0, which holds the bit rows of the manual's listings. One old case changed: it refusedsstatusas an unknown CSR name and now refuseshstatus. 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-rv640.1.0 and 0.2.0 (AGPL-3.0-only): a code generator written in BuildLang that reads the JSONbuildc mir emitwrites and prints RV64IM assembly forasm-rv64, so BuildLang programs run onemu-rv64.cg-rv64 run MIR ENTRY MAXgenerates, assembles and emulates in one step. The operation traces ofos-pfaandos-runqare 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 comeemu-rv640.7.0 (a serial run with 4 MiB of memory and a halt convention) andasm-rv640.4.0 (a 1 MiB image and 65536 labels). (#252, #255)os-pfaandos-runq0.1.0 (AGPL-3.0-only): the host-testable cores of two operating-system kernel subsystems in pure.bld.os-pfais a page-frame allocator over a caller-supplied bitmap;os-runqis a round-robin run queue over a caller-supplied ring. Each has an exact contract inSPEC.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-det0.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 fromref/reference.py, which takes the exact sum from Pythonmath.fsumand from afractions.Fractionsum; the inputs include cancellation, half-way cases, subnormals and values near overflow.src/i8.bldis a slot. A faster version replaces it only through the loop underimprove/, 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 promotedunroll8: 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 inimprove/LEDGER.jsonl.- The loop cannot change its own cases, controls, hold-out or threshold:
improve/FROZEN.sha256lists their digests, the loop checks them before the first step and before a promotion, andcompiler/tests/kernel_improve.rschecks 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.