Repository navigation
Abla v0.2.66
·
1104 commits
to master
since this release
Behaviour changes and migration (read first)
- Every path compile-time code names is read against its source file (d84bb8b, 818eb4e, 6f67354, decision #95 A).
- Where the rule applies:
#compilerWriteFile, andabla/fsreads, writes, listings, metadata, moves and removals in#code. It applies in the interpreter and in native compile-time slices alike. v0.2.65 applied the same rule to build calls (#91); compile-time file access now follows it too:Path("data.txt").readText()in a#site oftools/gen.abreadstools/data.txt, whichever directoryablac buildruns from. - Which file counts: the
#site's own file, the file that uses a$subparser, or the file that declares a#compiler.transform's handler. A library function any of them calls writes where that file says, not beside the library. - The project boundary: relative paths and every write, move or removal stay inside the source file's project. The project is the nearest
abla.tomlwith aname, else the repository root (.git), else the working directory. Anything outside it isE_BUILD_PATH_OUTSIDE. - Absolute paths: an absolute path is read as given, wherever it is (an SDK in
/nix/store, a toolchain,/proc/self/exe);filesystem.readis what grants that. - Migration: rewrite root-relative paths relative to the source file. For this release only, a path whose file (for a write, whose directory) is not next to the source file but is there from the working directory still takes the old reading, with
warning[W_BUILD_PATH_CWD]naming the source file's directory.ABLA_BUILD_PATH_CWD=errorturns that intoE_BUILD_PATH_CWDnow, and the compiler's own suite runs with it. The next release removes the old reading for build calls and compile-time file access alike. - One trap during this release: a write into a directory beside the source file that doesn't exist yet takes the old reading when the working directory has one of that name (usually
build/). Spell it./build/...to mean the one beside the source file:./isn't valid under the old reading, so the fallback leaves it alone.
- Where the rule applies:
- The default Linux toolchain download is the static one (8cc39a3, decision #90 A extended to the toolchain).
abla-toolchain-x86_64-linuxis now the statically linked package:- it contains the static compiler, the sysroot, the compiler-rt builtins and the Xtensa installer;
- it has no
libLLVM.so, no loader and no external LLVM tools, and runs on an emptyPATH; - its release builds make their objects in the compiler's own process (726837e, 5ea6550, b40e698, #101): llc's code generation through the shim, parts in parallel as children of the compiler, and opt and llc for the cross targets as
ablac --llvm-tool opt|llcchildren, byte for byte what the external tools build. - it carries LLVM's RISC-V backend, so riscv64 and riscv32 cross builds generate code in process too. The static download grows about 16 MB, about 3 MB compressed (fba51e1).
The previous dynamically linked package ships asabla-toolchain-dynamic-x86_64-linuxfor one release. It now carries Abla's pinned, patched, portable LLVM build rather than Ubuntu's stock tools, and its release job checks that the packaged opt, clang and lld fold0.0 / (0.0 * x)correctly (360235e, e940955, 3fd5598).ABLA_CODEGEN_INPROCESS=0runs the external tools as before.
- Reads return strings of the bytes read (91bf308, 0981181).
linuxReadFile,LinuxFileDescriptor.read,TcpConnection.read/readResult, the UDP receives,SecureFile.readChunkand the pure and hosted TLS reads used to return a string that kept the whole limit-sized buffer alive. A 9-byte file read with a 4 MB limit held 4 MB, and 80 small TCP reads with a 1 MB limit held 80 MB. They now copy a short read into a string of its own size. The contents are unchanged.
Known issue
await task { ... }orawait thread { ... }, with the task or thread written directly afterawait, doesn't keep it alive while it runs: a garbage collection inside its body can free it, and the program crashes or uses freed memory. Until v0.2.77, bind the task or thread to avalfirst (val t = task { ... }; await t). Fixed in v0.2.77.- Reading a very long number as a floating-point value (
parseFloat, JSON'sasF64orreadNumber,strtod) takes time quadratic in its digits, so one request carrying a JSON number of about a megabyte can keep a server busy for minutes. Until v0.2.77, reject or truncate numbers longer than a few hundred digits before converting them, or keep request bodies small. Fixed in v0.2.77. - Android libraries built with the release (static) Linux compiler are generated as if for plain Linux on arm64, not for Android. They use native ELF thread-local storage instead of emulated TLS, so on Android 7 to 9 (API levels below 29) loading such a library can fail. They also use register x18, which Android reserves (on Android 9 and later it holds the shadow call stack), so a library may crash on any Android version. To work around it, set
ABLA_CODEGEN_INPROCESS=0and have LLVM'soptandllconPATH(or setABLA_LLVM_TOOLS): the compiler then runs them instead of its own code generation, and the library is built for Android. This affects v0.2.66 and later. Fixed in v0.2.71. - Ordinary code can write fields that the standard library's native buffers and cells rely on (
closedof aNativeByteBuffer,NativeI64CellorNativePointerCell), so safe code can reach memory it doesn't own. Until v0.2.79, don't write those fields outside the standard library, and check that your dependencies don't. Fixed in v0.2.79. - A dependency's prepared copy in
.abla/packages/is trusted by its marker files without checking its contents againstabla.lockin single-file builds, and in project builds that also have a vendored copy, so a changed copy (from a restored CI cache, or committed next to a reviewed lock) is built as is. Until v0.2.79, delete.abla/packages/before building when it may come from somewhere you don't control (it is fetched again and checked), and don't cache or commit it. Fixed in v0.2.79. - The HTTP clients (
HttpClient.send,HttpAsyncClient, and the WebSocket TLS client's upgrade request) write the method, path and header values they are given without checking them, so a line break in a value that came from user input can add headers or a second request. Until v0.2.79, percent-encode user input in paths and queries (percentEncode) and refuse CR, LF and other control bytes in header values before passing them to a client. Fixed in v0.2.79. - The static Linux compiler's own hardening was weaker than a glibc build's: its stack-protector canary was a fixed value on AArch64, its
_FORTIFY_SOURCEbuffer checks did nothing, andrealpathcould overrun its caller's buffer with a very deep working directory plus a long relative path. None of these is reachable alone; each makes a separate overflow bug in LLVM or lld easier to exploit when compiling code you don't trust. On AArch64 itsprintffamily also read arguments from the wrong place, so text that LLVM formats could show stack contents or crash the compiler. Until v0.2.79, on x86-64 Linux the dynamic compiler asset (ablac-dynamic-x86_64-linux, built on glibc) avoids them; elsewhere, build code you don't trust from a shallow directory. Fixed in v0.2.79.
Highlights
- SIMD, parts A and B (b280e09, 62ffa42, a04aec1, d4b0a0f).
- 512-bit vectors: alongside 128 and 256. LLVM splits them where the target has no 512-bit instruction, for example into two halves with AVX2.
@target("avx512f")and@target("avx512bw")paths are guarded bycpuHas, which checks the OS saves ZMM state. - Table lookups:
.swizzle(indices)and.swizzle2(other, indices), where a lane out of range gives zero. These usetblon AArch64,i8x16.swizzleon Wasm andpshufbwith SSSE3. - Rounding:
.floor(),.ceil(),.trunc()and.roundEven(). - Conversions: widen, saturating narrow, and cross-width conversions. Float to int truncates, saturates, and maps NaN to 0.
- Gathers:
TGather(values, indices), bounds-checked as scalar indexing, with AVX2 gathers for dense arrays. - Compile time: vectors can be built, operated on and returned under
#. - Testing: the suite runs as static AArch64 Linux executables under qemu. CI reports whether its AVX-512 paths ran natively, and
ABLA_SIMD_SDEruns both under Intel SDE (docs/simd.md).
- 512-bit vectors: alongside 128 and 256. LLVM splits them where the target has no 512-bit instruction, for example into two halves with AVX2.
- Crash reports (061aac5, d22b0d2, 2060c06, 5defa0c, 552fcb6, 1c4b17e, a7614be).
- Release builds: a release build that hits a bad memory access prints
fatal signal: a bad memory access at 0x…instead of nothing. This applies only to a fault the kernel raised (si_code 1 to 15); a signal sent bykillnames no address. On Apple Silicon, where macOS fills in a fault's code and address for every SIGSEGV, a fault is told from a sent signal by the exception syndrome (4e8a5f8). A WebAssembly panic reaches its host as one write. build --backtrace: keeps frame pointers and a table of function names, so a release build prints a named stack on a panic or a fault. Measured: hello 30,400 to 38,872 bytes. Without the flag a build is byte for byte unchanged.- Native
--backtracebuilds: they also write<output>.debug, the line tables split off after the link, soablac symbolizeand gdb give file:line for a stripped crash. - WebAssembly
--backtracemodules: they keep their name section, so a host's trap stack namescrash.crash, notwasm-function[8]. ablac symbolize <program> [<crash text>]: reads a printed stack from a file or standard input and gives each frame's function and file:line:column, inlined frames included. It uses llvm-symbolizer, or atos on macOS.
- Release builds: a release build that hits a bad memory access prints
- Debugging (11939e1, 4fc3213, 8392bea).
- Native development builds (
-g --fast): they now describe functions, parameters and locals with their Abla types. gdb and lldb show an instance's fields, a string's text, nullable instances and array elements, and break on an Abla function by name. A development executable grows about 40%; an optimized-gbuild stays line tables only. - Browser developer tools: WebAssembly source maps put the standard library on the ignore list, and dispatch entries are named readably (
probe.main.lambda.boxed). - Missing llvm-dwarfdump: a Wasm debug build without it still succeeds, without a source map.
- The tour gains a debugging chapter (docs/tour/14-debugging.md).
- Native development builds (
- The same source gives the same bytes from any directory (f6171db, #1090). A native object's debug file names used to be the paths as the build was given them. They are now relative to the entry source's directory, so a build from another working directory, by an absolute path, or from a copy of the project is byte-identical.
--path-prefix-map OLD=NEWrewrites an absolute prefix (clang's-fdebug-prefix-map), so the standard library can map to a fixed place. Also, a requested--sidecarobject no longer changes the executable (ebf3f2c, de3f64c). - The collector paces itself and sweeps in parallel (e311528, 81d38ac, 56c0627, c1ef085).
- Pacing: hosted programs pace collections by the surviving footprint and by native allocation pressure. The first budget is 8 MiB; after each collection the next is three times what survived, between 8 and 128 MiB, and native buffer volume counts. A large mapped heap is trimmed when it dwarfs the survivors.
memorySetCollectionGrowth(bytes)orABLA_GC_GROWTHstill selects explicit pacing. - Parallel sweep: the collector that frees in the background sweeps on up to 8 threads with no serial registry walk, and shares mark work earlier. A program that asked for collection threads uses them adaptively: small collections stay serial, and larger ones choose the faster mode from what consecutive collections cost.
- Measurements: the compiler asks for four threads, and its self-build's collection pauses went from 1.68 to 1.28 s with no extra wall or CPU time.
ABLA_GC_TRACE=1prints the phase times (docs/standard-library.md).
- Pacing: hosted programs pace collections by the surviving footprint and by native allocation pressure. The first budget is 8 MiB; after each collection the next is three times what survived, between 8 and 128 MiB, and native buffer volume counts. A large mapped heap is trimmed when it dwarfs the survivors.
$regexliterals (21950e2, 8b831ab, cd59069, 9d3f74d, 33fcd99).$regex("pattern")checks the pattern while compiling and embeds the compiled program. Named groups(?<name>…)give a typed match:match.yearis astringwhen the group takes part on every successful path, andstring?when it can be skipped. Small capture-free literals and equal-width ASCII searches take faster specialized paths (docs/stdlib/regex.md).$sql, with the brace form (d2171da, dd2d290).import "abla/sql".$sql("…")and$sql { … }check one statement from a PostgreSQL subset while compiling. Each${expression}becomes a numbered parameter bound separately as text, and needs an immediate::typecast that the compiler checks against the Abla value's type. The brace form takes SQL as written, double quotes and dollar quotes included, and keeps strings, quoted identifiers, dollar quotes and comments verbatim (stdlib/abla/sql/README.md).$xmlandabla/xml(731bc63, 3a94fff, 25d6c21).$xml <tag attr={value}>{text}</tag>builds anXmlElementchecked while compiling: names, closing tags, namespaces, duplicate attributes and references.{node …}/{nodes …}insert typed nodes, and#$xmlfreezes a static element. With the abla-xml package,$xmlw(writer)streams an element straight to a writer (docs/stdlib/xml.md).- Packages (50bff1d, 40f8b4a, 4b79df3, 0a6427e, 77b721b).
- Search and info:
ablac package search <words>andablac package info <name>look libraries up in the Abla index (https://abla.dev/packages.toml), fetched with Abla's own HTTPS client. Names are case-insensitive, and theabla-prefix is optional. The last good catalog is cached, so--offlineworks and a failed refresh falls back to it. ablac package add <name|owner/repo> [--tag …]: adds an import to the entry module and pins the revision, plus any new transitive dependencies, inabla.lock. Existing pins keep their revisions.ablac package outdated: lists newer tags of locked Git packages with each tag's declared compiler range, without changing anything.ablac new <name> [--lib] [--github]: scaffolds a runnable app or library with tests and an optional GitHub Actions workflow.
- Search and info:
- Clearer diagnostics (a6b7761, abd28b6, 083cc78, bd5bbee). Parser and import errors carry a help line that says what to write, for example an unterminated block comment (
E_PARSE_UNTERMINATED_COMMENT). Areturnof the wrong type names the type to return.E_BORROW_CONFLICT,E_OWNERSHIPandE_DEFINITE_ASSIGNMENTexplain what to do; docs/diagnostics.md documents each, with examples. - The standard library is documented in full (a0e406d and the doc-comment sets). Every public declaration has a comment: 9,499 of 9,499, up from 2,301 of 8,020 in v0.2.65.
ablac docand editor hovers show them, and the suite keeps the count from going back. W_JSON_CONSTRUCTION, opt-in (ef6ec2b, e970e15, 881bd7c):--warn-json-construction, or the editor optionjsonConstruction, suggests$json/$jsonwfor JSON assembled by interpolation, concatenation orByteBufferappends. It offers edits only where the rewrite is certain.- JSON: guarded members (lazy omission, the same bytes in tree and streaming forms) and nullable strings in literals (5fe0298, f483b6a, 5b5dd60).
$jsonwnow writes each static fragment straight to theByteBuffer's append methods instead of through a forwarding call whose GC frame outlived inlining, and leaves out the key check when every guarded key is a valid literal; computed keys are still validated, and aliased imports of the buffer keep working (e1394a2, cdf8a59, #1099). The compiler's analysis service streams its occurrence records this way (25224be). #compiler.exportedNames(modules)(2fe11fa): the sorted C names of the@export,@exportCheckedand@exportLocalfunctions in the loaded graph.- REPL:
:load <file>adds a file's declarations in one reload, and a line longer than the terminal wraps over its rows (295cc4c, 93e32d7). - Windows, first steps (1d5c1ad, c0a18a3, e940490, 5bd1fb4; docs/design/windows-target.md).
--target x86_64-windowslinks a freestanding program with lld-link against import libraries the compiler writes itself, with no SDK or llvm-dlltool. CI cross-builds one on Linux and runs it on windows-latest. The static compiler links these in process through lld's COFF driver, so nolld-linkhas to be shipped or found; its output is byte for byte what the external lld-link gives (98bc450, #1092). A first hosted step, not yet a supported target:x86_64-windows-hostedcross-builds a program with the Abla runtime and standard library over kernel32 (output, memory, sleeping, futex waits, clocks and opening files) and runs it under Wine; a system call it doesn't translate yet stops the program with status 70 and the call's number (0102163, fa3f68b). Threads run there too:CreateThreadbehind thread start and join, waits onWaitOnAddress, 8 MiB stacks (5a45fff). So do files and the environment: a descriptor table over handles with UTF-16 paths covers opening, reading, writing, seeking,stat, directory listing, rename, mkdir, rmdir, unlink, the working directory, fsync, truncation and random bytes, and the environment block follows argv as on Linux (a3c5bbd, d9ac350, 35371ec).abla/fs/pathgives lexical path syntax for POSIX and Windows with no file system access (a8984e3).
Fixes
- v0.2.65's static compiler aborted building a WebAssembly module (8cb7ae8). The static libc's
pthread_attr_initcleared 64 bytes of a 56-bytepthread_attr_t, so whenever LLVM's thread pool started ("stack smashing detected"),#wasmBuildModulefailed with the defaultablac-x86_64-linux; this covers lld's Wasm LTO with partitions. The compile-time Wasm builders now run with the static compiler in its CI job and match the ordinary compiler's modules byte for byte (93da925). - The static compiler's libm is correctly rounded (fc4c0f4, e7a40ef, 37607fb, #1045).
expm1,log1p,log2,log10,asin,acos,sinh,cosh,tanh,erfanderfcare written from the mathematics and rounded once. They were checked against MPFR on about 40,000 arguments, and a typical call takes 1.6 to 5 µs. v0.2.65's known issue, compile-time folds differing from the dynamic compiler in the last bits, is gone. - A forked child of a program that frees in the background no longer stalls 20 ms in its first collection (53fb78a): 300 forks took 6.3 s, now 0.15 s.
- Alias imports: a member named like a built-in type no longer prefixes the type (1bed972), and transitive re-exports resolve through an aliased module (704a7dd). A staged parser builtin's arity is checked before dispatch (91774cd).
- The RSA keygen worker wipes its own stack (34c490e).
- Checked array accesses stay live across class field stores (ac3b515).
- The static compiler failed a second WebAssembly link in one build (e3cbf13). lld's WebAssembly LTO can't run twice in one process ("attempt to add bitcode file after LTO"). That happened whenever a build linked two Wasm modules, such as a
#wasmBuildModuleand a Wasm#buildProgramin one build file, or a release module, whose link runs twice. The static compiler now runs wasm-ld and lld-link as child processes of itself, still with no external tools to find. It runs llvm-extract and llvm-ar in its own process, byte for byte what the LLVM tools produce. - The static compiler's archives are reproducible (7eeba50). Its in-process archiver named each member by the temporary directory it was written in, so two builds of the same program differed. Members are now named by their base name, as llvm-ar does.
- LLVM's instcombine could fold
0.0 / (0.0 * x)to a signed zero instead of NaN in optimised builds that used stock LLVM tools (v0.2.65's known issue). Every LLVM Abla ships is now the patched one: the static compiler and the default toolchain in process, the dynamic Linux toolchain through the pinned portable archives (e940955), and macOS through revision 2 of the patched archives (2c75db8). Your own LLVM tools still need LLVM's fix (trunk PR #202482).
Performance
- Five-language comparison, EJ (29bbcf2), from cx2's report (tools/bench-languages; one shared machine, CPU 24, pinned toolchains, five runs).
- CPU workloads: across the six (binary-trees, fannkuch, n-body, spectral-norm, mandelbrot, fasta), Abla's geometric mean wall time is 1.464× C's. It was 1.521× at EH. Rust is at 1.106×, Zig at 1.142× and Go at 1.228×.
- binary-trees: 22.3% faster than at EH, through the collector work above.
- Close to C: mandelbrot (1.005×), spectral-norm (1.026×) and HTTP echo throughput (0.999×).
- Further behind: fannkuch (2.09×), fasta (2.03×) and regex-redux (2.16×).
- Startup: a hello process starts in 0.298 ms against C's 0.535 ms.
- Measurement records: docs/measurements/ holds the archived v0.2.64-era baseline.
- SIMD scanners on x86-64 (a539cfb, ab2a85f). Native x86-64 programs scan 16-byte blocks with SSE2 for byte search, substring search (
indexOf,contains,split,replace), ASCII checks and the ASCII prefix of UTF-8 validation, the JSON parser's string scan, and base64 encoding and decoding. Short inputs, partial blocks and other targets keep the scalar loops, and the suite checks the x86-64 results against scalar AArch64 builds on a fuzzed corpus. A WebAssembly build doesn't need SIMD128. - JSON: small parsed arrays are built in one allocation (3fdc47b, #1115).
- Small executables build faster: the hosted collector's cold paths stay out of line, so LLVM does less work for each program: 2.46% fewer instructions to build hello and 1.50% fewer for binary-trees (69fc4d3).
- Memory and string routines (1e09838, #806): every hosted x86-64 Linux executable copies, fills and measures strings with SSE paths for mid-sized lengths, and the static libc's
qsortis an introsort. - Strings: eligible append loops build a private string (1cd7938), single-byte appends stay on the buffer's active stage (59c3ff3), and rope flattening scratch space is bounded (80668bb).
- Arrays: checked indexing of a local dense integer array that doesn't escape compiles to direct slot accesses, with the same bounds diagnostics (89253a7).
- Globals in loops: a scalar global that a loop updates, and that nothing the loop calls can observe, is kept in a local for the loop and stored back on exit, as fasta's random state is; fresh float array arguments use checked packed reads (f31ddd4, 930ac33, 0277b03).
- The compiler: syntax walks are shared across semantic summaries (2bec331), and unchanged generic probe negatives are skipped (1c6b3b5).
Tools
- CI:
- the static compiler's job builds the compile-time Wasm modules (93da925);
- the Linux job reports whether the AVX-512 paths ran natively (d4b0a0f);
- a freestanding Windows program runs on windows-latest (e940490);
- local gates run the Android link and bionic tests (c0fb75e);
- the static compiler's suite runs nightly, and the release job runs the full static suite on the exact artifact it publishes, checked by source commit and checksum, before anything is published (5f141f9, 84f1322).
- The fuzzer and robustness:
- Memory guards: the analysis and compiler memory tests hold live bytes per byte of source (deterministic on any machine), with the resident size as a loose ceiling, instead of a resident-size bound that failed on core count and source growth (51e726e, 3f71fbf).
- Benchmarks:
tools/bench-languages, a five-language benchmark lab with verified outputs and fair-slot batching (4d492cd and following). - LLVM: workflows build portable patched LLVM archives for Linux on Ubuntu 22.04 and the audited Mac tool set (ad3aed8, 3c0978f); both are pinned, and the Linux release packages the portable cohort with its debug reader (360235e, 3fd5598, e940955, 2c75db8).
- Bootstrap: pinned to the verified v0.2.65 artifacts (b9fb38f); the convergence workflow defaults to the v0.2.65 lineage (aaef105).
Bootstrap convergence
Two fresh Linux builders bootstrapped the source of v0.2.66 (fba51e1e7883f3e4169b0c6cd5f03c320c227bb3) from different seeds and reached the same compiler:
- route A: v0.2.65 (
ablac-x86_64-linuxsha256b5ee36b5a4a535cf6a7696ae9a1f17a544e9e02b468f1e79be4f2ea5cd90c3c9) -> stage 1, 2, 3 - route B: v0.2.64 (sha256
708d1cc5d50b318fb763113d16977ee209c9c6c5b39d1afdf96a43824c74be92) -> the sources of v0.2.65 (ed00a14c893a72671d4a2ec24140231ffd8544f8), twice -> stage 1, 2, 3 - canonical IR (raw, non-debug, pre-prune
--emit-llvm src/orc_main.abat/build/source): sha2565235ac692803ae7b58589341d828b1b357c15df531029f87ff6cb23d683fffa6 - stage 2 executable
4c7e2ec4e4da2742d5dc1e8c0af5df2ea78ebe4c712d692ca28aeb1992b32947, object9d99a4375f5a91bb953eab8305810164dd41fce8ea2edbf5a30f018df1388026 - toolchain: environment
30c15d5d7641a41807489447e76f05f8d7b306cef23643a616920a5c1da1ffe8, closureb1872f918c677d4b376f11826949774047bafeac6c208592b89a05f2dc4640aa - run: https://github.com/AndreBaltazar8/ablac/actions/runs/45025330033
This is route convergence within one compiler lineage: it is not an independent implementation, and it does not exclude a seed compromise shared by both routes (docs/bootstrap.md).