Xo 0.46 release notes
Downloads: Xo 0.46.0 on GitHub,
with archives for macOS (Apple silicon and Intel, signed and
notarized), Linux (arm64 and x86-64), and Windows (x86-64, Authenticode
signed), and a SHA256SUMS file.
Getting started shows how to install
one. These notes cover everything since 0.44.0.
Xo 0.46.0 adds FreeBSD (amd64 and arm64) and linux/riscv64 as experimental cross targets, makes xo check about six times faster on a warm run by reading std’s declaration record instead of checking all of std, matches routes as Go 1.22’s ServeMux does, gives xo repl a JSON protocol and editing, and fixes a host name lookup that could return wrong IPv4 addresses.
Upgrade if your programs look up host names on networks with both IPv4 and IPv6, or if xo check time matters to you. Two changes can stop a program that compiled with 0.44.0 from compiling or change how it answers requests: std/http’s Router matching, and exhaustive matches on TargetArch or TargetOs; a third makes some existing xo.lock lines fail to verify (see Breaking changes).
Breaking changes
std/http
Routermatches as Go 1.22’s ServeMux. A pattern without a trailing slash is an exact path (GET /healthzno longer answers/healthz/), a pattern ending in/is a subtree route,{$}is the exact slash path,{name}needs a non-empty segment, unclean paths get a 307 to the cleaned path, aGETroute servesHEAD(it was a 405), and a 405’sAllowis sorted withHEAD. Migration: register the exact path and, for a tree, a/dir/or{p...}route.TargetArchgainsRiscv64andTargetOsgainsFreeBSD(decisions 0571 and 0573), so an exhaustivematch target.archormatch target.oswith no_ =>arm is now XO0301 on every target. Migration: add the new variant to an arm (Linux | FreeBSD => ...,Arm64 | Riscv64 => ...) or add_ =>; XO0301 names the missing variant.A module in a subdirectory of its repository carries the repository’s root LICENSE (decision 0590) when it has none of its own, as Go’s module zips do, so its zip hash changes. An
xo.lockline for such a module written by an older xo now fails with XO1304, with a note naming this change. Migration: delete the line and runxo mod tidy.
Platforms
- FreeBSD (experimental cross target, decision 0573): programs build with the native backends for freebsd/amd64 and freebsd/arm64, with threads, the kqueue poller, signals, the file system, sockets, HTTP and TLS, faults recovered by isolate and defer, and asynchronous preemption (a loop with no call yields as on Linux). Every golden program that builds passes on both (642 of 642, in FreeBSD 14.5 VMs).
use cbindings compile with clang against a FreeBSD sysroot (C that calls the C library is not supported yet). FreeBSD is not in--targets=alland has no prebuilt xo. - linux/riscv64 (experimental cross target, decision 0571):
xo build --targets=linux/riscv64 --backend=llvmbuilds 64-bit RISC-V Linux programs (RV64GC) against a riscv64 glibc sysroot (XO_LINUXSYSROOT), with asynchronous preemption; LLVM backend only, not in--targets=all, no prebuilt xo. Under qemu-user all 523 LLVM goldens that need no network pass, and std’s 60 test modules. - windows/arm64 (experimental, decision 0569):
use cprograms link with Xo’s PE linker, weak C references work, functions over 1 MB get segmented unwind data, a debug build writes a PDB, and--backend=arm64assembles with Xo’s own COFF writer, so a build needs no clang unless it has ause csource. The native backend is not yet the default there. - Windows debuggers: WinDbg and cdb load the PDB xo writes on windows/amd64 and windows/arm64.
xo debugon Intel Macs (darwin/amd64, decision 0253): runs, steps and attaches to programs, with backtraces through x86_64’s compact unwind data; it said “xo debug runs programs on macOS arm64, Linux and Windows”.
Language
- Integer bounds are type constants (decision 0587):
Int.max,Int.minand every sized integer type’s bounds (Int8.min,UInt64.max) work in aconstor a pattern;Int.max(a, b)is XO0407 naminga.max(b). - Effects (decision 0582): an interface value’s effect argument widens where the interface’s effect parameter is covariant, so a
Cred[fs.read]may go where aCred[(fs.read, proc)]is expected. Os { ... }may leave out fields (decision 0585): each omittedfs,net,env,procorstdiodenies everything, so a test or sandbox names only what it grants.- C libraries (decision 0574):
xo build --lib=sharedor--lib=staticbuilds a package as a C library with a generated header (NAME.h), andpub fn add(a: Int, b: Int) -> Int as c "geo_add"is its C functiongeo_add. Int, Float, Bytes (XoBytes) and Str (XoStr, UTF-8 with a length, no NUL needed) cross directly; any other value but Bool and functions crosses as anXoHandlethat C releases withxo_release. A function that can fail (-> T ! E) takes anint32_t *errlast and leaves the error’s text forxo_last_error(). The runtime starts when the library loads, and any C thread may call in. Works on darwin and linux, arm64 and amd64, with the native backends, linked with cc. Not yet: Windows DLLs, the LLVM backend, Optional and List results except as handles, and Bytes borrowed without a copy.
Tools
xo checkreads std’s declaration record (decision 0388) and parses std’s trees only where a body is needed: a warm check of fib went from 352 to 56 ms and of bench/perf/http from 365 to 52 ms on the Mac; output unchanged (XO_STD_EXPORT=0 restores the earlier path).xo replno longer needs XO_REPL=1 (it stays experimental):--jsonspeaks one request and one reply a line,--effects=LISTlimits what entries may use,:defs,:saveand:loadmanage a session, redefining a fn or type replaces it, and a terminal session edits entries in place with history.- Diagnostics for code written the Go way:
if v, ok := m[k]; ok {is one XO0177 namingif let Some(v) = m.get(k);"n = " + nnotes the interpolation form;xs.sort(fn(a, b) { a > b })is one XO0403 namingsort_by; XO0701 names the correctedusesclause with a machine-applicable fix;xo vetXO0542 warns ofx ?? lit <op> z. xo check --fixparenthesizes its.or(x)to??rewrite when an operator is next to it (m.get(w).or(0) + 1becamem.get(w) ?? 0 + 1, which adds 1 to the default only).- xo lsp: hover on std names links to the std reference page, and a std source opened in the editor is not checked as a module. Every prelude fn now has a doc comment.
- Module tools (decision 0568):
xo mod sumdb keygenandserve,--copy-toandrestore,--refresh, andxo mod proxy fillrun a checksum log and module proxy; every git fetch fails a remote slower than 1 KB/s for a minute instead of hanging. - xo init writes .gitignore only inside a git repository.
xo vetXO0541 warns of araw.bytes_bufslice kept past the loop iteration that reads into the buffer again, without.clone()(a Bytes slice is a view).
Fixes
- Windows:
xo fix,xo check --fixandxo modoutside a module no longer loop forever: the search for xo.mod stops at the drive’s root (C:/). - A host name lookup that asks for IPv4 and IPv6 at once no longer returns IPv4 addresses read from the IPv6 answer’s bytes (programs dialed addresses such as 38.6.71.0 when a resolver answered both back to back).
- Large darwin/arm64 programs link: a separately compiled program whose code ends more than about 112 MiB past std’s start failed with a branch range error.
- Float conversions:
UInt64(f)from 2^63 up to 2^64 converts on the native and LLVM backends (it faulted), and a failing Float to sized integer conversion names the type and value. xo check ./...(decision 0513) over 8 or more modules no longer reports “expectedStr, foundStr”; a package below its module root named as.keeps its import path (no false XO0604).- A stopped build (ctrl-c, SIGTERM) leaves no hidden stage or tomb file beside the output.
xo doc DIR/...documents every module at and below DIR, as its help says (it looked./...up as a declaration name).- darwin builds with –release or –trimpath write no debug map naming the builder’s cache under $HOME (decision 0563).
Standard library
Stdio.raw_input(on)(decision 0581) switches a terminal to raw input and back, restored on exit, fault or crash (Linux, macOS, Windows).- Ordering and comparator sorts in the prelude (decision 0586):
Orderingwithreverseandthen,a.cmp(b)on every Ord type, the stablesort_withandsort_in_place_with, andsort_by_descandsort_in_place_by_desc. - std/image (decision 0578), ported from Go’s image, image/color and image/draw with Go’s output as each test’s oracle: color conversions,
Image.atandset,sub_imageandcrop, YCbCr planes, PNG and JPEG in and out (from_png,to_png,from_jpeg,to_jpeg),draw,draw_maskandfill, Floyd-Steinberg dithering onto palettes, andscalewith nearest neighbor, bilinear and Catmull-Rom kernels (x/image/draw). - std/gif (Go’s image/gif: decode, decode_all, encode, encode_all, animations) and LZW in std/compress (
lzw_encode,lzw_decode). - std/htmlparse: golang.org/x/net/html’s tree builder and
Render(decision 0570), checked against Go on 1,789 html5lib and other cases. - std/trace records OpenTelemetry spans (ids, parent, kind, attributes, events, status, a
Recorder), and std/otlp encodes them (decision 0580). Aead.Aes128CbcHmacSha256, JWE’s A128CBC-HS256 (RFC 7518), checked against Go.- Go compatible error texts:
json.decode_go(decision 0553) follows encoding/json’s rules for null and missing fields and words a type error as it does;DecodeErr.go_text()andtimego.go_text(e)give encoding/json’s and time.Parse’s texts. - std/protojson: editions 2023 descriptors, groups as JSON objects, proto2 required fields checked, unknown fields kept by
normalize. - std/testing:
FakeProc.runs()lists the commands the code asked to run. - Fixes:
File.read_atandwrite_atkeep the file position on Windows;http.redirect’s body ends as Go’s does; under FakeNet a client request reaches a bare Listener.
Performance
- List slices allocate their length at once (bench/perf/listslice: 64 Ints of 256 in 0.198 of the time, linux/arm64).
Str.rune_countcounts 32 bytes at a time; arm64 drops the bounds check ofb[n - 1]undern > 0; wide struct==passes addresses; interpolations starting with a literal copy it inline (bench/perf/interpcat 0.937, linux/arm64); the LLVM backend writes 4 KiB values field by field.- Build time: register allocation and copy propagation do less work per register, and a parallel move of more than 16 words is ordered in O(n log n).
Xo against Go
Measured on linux/arm64 (12 CPUs) during the 0.46.0 cycle, against Go 1.26.1; Xo and Go alternate within each round.
- Run time: Xo is faster on 16 of 20 release benchmarks, from 0.89x of Go’s wall time (fib) to 0.18x (collection iteration); it is slower on sieve (1.19x), rwmutex (1.13x), pmap (1.06x) and nbody (1.02x). Peak memory is 0.21x to 0.68x of Go’s.
- Tests:
xo testof std’s base64 and json runs in 0.79x and 0.46x ofgo test’s wall time cold, 0.89x and 0.24x after an edit. - Builds: a cold build takes 1.1 to 1.3 s against Go’s 1.3 s, at 220 to 240 MB peak against Go’s 280 to 300 MB; an edit rebuilds in 40 to 110 ms (Go 70 to 80 ms), but an unchanged rebuild is 40 to 110 ms against Go’s 20 ms.
- HTTP server: against Go at its defaults Xo serves 3.4x to 6.0x the requests per second on a JSON route and 1.3x to 1.8x on a plain one, at about a quarter of Go’s memory; against Go tuned (GOGC=off, a 1 GiB memory limit) 1.27x to 1.38x and 1.15x to 1.23x, at under 1% of its memory. Against 0.44.0 the JSON route is 6% to 9% faster; the plain route is 0.6% to 1.0% slower.
- The macOS rows of this release are measured separately on the Mac.
Known issues
- windows/arm64’s native backend is not the default yet (decision 0569’s prerequisite 2: internal/arm64 has 11 failures on windows/arm64); target 0.47.