Repository navigation
·
827 commits
to release/0.3.x
since this release
Immutable
release. Only release title and notes can be modified.
Kairo 0.3.1 is a fix release on top of 0.3.0. Most of it turns compiler crashes and errors from the backend into proper Kairo diagnostics, and fixes the places where 0.3.0 quietly built the wrong thing. It also adds a few features: T? as U? conversions, @export for plain C symbols and wasm exports, [T]::emplace, a clang-cl mode for kcc, and ASan / TSan on glibc Linux. Same LLVM (23.1.6) and the same 14 hosts as 0.3.0. There are a few small breaking changes, listed at the end.
Highlights
T? as U?: converts the value and keeps null (code as string?,ptr as *Dog?).@export("name"): a free function also gets the plain C symbolname; on wasm it's the module export too.- kcc and build systems:
kcc --versionprints clang's banner, so CMake detects kcc as Clang;--driver-mode=cltakes clang-cl's command line. - Sanitizers:
-fsanitize-addressand-fsanitize-threadinstrument Kairo code on glibc Linux targets. [T]::emplace(args...): builds the new last element in place.- Fewer crashes: a long list of ICE's (I003E, CL001E) and backend verif errors are now checked and error correctly instead, and several of them compile fully now.
- Windows: a crash exits with status 134 like everywhere else, and sources and headers aren't locked while a compile or kals has them open.
- CRLF sources lex and report lines and columns the same as LF sources.
Platforms and downloads
| Archive | Host |
|---|---|
kairo-0.3.1-x86_64-linux-musl.tar.xz |
Linux, x86-64 |
kairo-0.3.1-i686-linux-musl.tar.xz |
Linux, 32-bit x86 (Pentium 4 class or newer) |
kairo-0.3.1-aarch64-linux-musl.tar.xz |
Linux, 64-bit Arm |
kairo-0.3.1-armv7-linux-musl.tar.xz |
Linux, 32-bit Arm (ARMv7 or newer) |
kairo-0.3.1-riscv64-linux-musl.tar.xz |
Linux, RISC-V 64 |
kairo-0.3.1-x86_64-unknown-freebsd.tar.xz |
FreeBSD, x86-64 |
kairo-0.3.1-aarch64-unknown-freebsd.tar.xz |
FreeBSD, 64-bit Arm |
kairo-0.3.1-x86_64-unknown-netbsd.tar.xz |
NetBSD, x86-64 |
kairo-0.3.1-x86_64-windows-gnu.zip |
Windows, x86-64 |
kairo-0.3.1-i686-windows-gnu.zip |
Windows, 32-bit x86 |
kairo-0.3.1-aarch64-windows-gnu.zip |
Windows, 64-bit Arm |
kairo-0.3.1-armv7-windows-gnu.zip |
Windows, 32-bit Arm |
kairo-0.3.1-x86_64-apple-macosx10.15.zip |
macOS 10.15 or newer, Intel |
kairo-0.3.1-arm64-apple-macosx11.0.zip |
macOS 11 or newer, Apple silicon |
Every archive holds:
bin/:kairo,kcc,kld,kfmt,ksys,kals,llvm-symbolizerandllvm-ar(withllvm-ranlibandllvm-liblinks).lib/: the compiler's resource directory (lib/clang/23) and Kairo'sbuiltin,stdandrtlibraries.sysroot/: on Linux the host's prebuilt musl and glibc sysroots, on Windows the host'swindows-gnusysroot; the BSD and macOS archives ship none. Every other target's sysroot (the BSD host's own included) is built byksysfromshare/kairo/sysroot/the first time--targetnames it (about 10 to 30 s), then cached.scripts/:darwin-sysroot.shandmsvc-sysroot(.sh/.ps1), which build the macOS and MSVC sysroots from your own Apple SDK or Microsoft CRT and Windows SDK. We never ship those SDKs; the Kairo half of each root is prebuilt inshare/kairo/sdk-overlays/, andshare/kairo/runtimes/holds the LLVM runtimes source for a full build.share/kairo/templates/: the projectskairo --initcopies.LICENSE,NOTICE,LICENSES/andTHIRD-PARTY-NOTICES.
Installing
curl -fsSL https://www.kairolang.org/install.sh | sh # Linux, macOS, FreeBSD, NetBSDirm https://www.kairolang.org/install.ps1 | iex # Windows PowerShell 5.1 or pwsh 7install.sh and install.ps1 are one script that runs under both POSIX sh and PowerShell. It detects the host's triple, downloads the archive and SHA256SUMS from this release, checks the archive's SHA-256 before unpacking anything, and needs no root:
- sh: the tree goes to
~/.local/share/kairo/0.3.1and the tools are linked into~/.local/bin(KAIRO_PREFIXmoves both); it prints the line to add that directory toPATHwhen it's missing. On macOS it clears the quarantine flag (the binaries aren't notarized) and assembles the macOS sysroot from the Command Line Tools or Xcode SDK. - PowerShell: the tree goes to
%LOCALAPPDATA%\Kairo\0.3.1and itsbinis added to the userPath(older Kairo entries under the same root are dropped). With Visual Studio's C++ tools and a Windows SDK installed it also assembles the optional MSVC sysroot (x86_64 and aarch64); the defaultwindows-gnutarget needs nothing. Run under pwsh on another OS, it hands over to the sh installer. - The sysroot step never fails the install: a missing SDK or a failure prints the command to run later.
KAIRO_NO_SYSROOT=1skips it. - Environment:
KAIRO_VERSION(default0.3.1),KAIRO_PREFIX,KAIRO_BASE_URL(where the archive andSHA256SUMSlive; afile://URL works),KAIRO_TRIPLE(overrides detection). - Installer:
--archive <path-or-url>/--sha256 <hex>(KAIRO_ARCHIVE,KAIRO_SHA256; PowerShell-Archive,-Sha256) installs a release archive you already downloaded.
Language
Types, conversions and expressions
T? as U?: converts the value and keeps null (code as string?,ptr as *Dog?); a conversionT as U?doesn't have is SC027E.x as Ufrom aT?whoseTconverts is SC027E ("converts, but may be null") instead of failing in the emitted code.s as [T]: a slice[T;]or[const T;]casts to its vector, a new[T]copying each element (same ass.to_vec()); it needsT impl Copyable(SC153E), and a vector of other elements is SC027E.op aswith arequiresclause: a source that doesn't meet it is SC153E at the cast.var *d = xis accepted after a null check provesxnon-null (no false SC266E);dis*T, same asvar d: *T = x.assert c, msg: prints the evaluated message whenmsgisn't a literal (it printed the statement's source); a message that isn't a string is SC028E.- Statement breaks: a line after a tuple literal that starts with
*,-,&,(or..is its own statement, not a continuation of the line above. var g = fwherefis a generic function without its type arguments, an overload set or a method is SC094E at type check, with notes at its declarations (was a build failure, or a compiler crash at file scope).- Closure default arguments don't apply once the closure variable is reassigned (it silently used a wrong value; now SC099E).
Generics and extensions
extendblocks: a member declared twice across the blocks of one type in a file is R041E (was a build failure).- Packs: a pack forwarded into an overload set is checked against the candidates' bounds at the definition (R051E / R025E) when no candidate's pack bounds are met.
- Const C++ objects in generics: calling a non-const C++ method through a const dependent C++ object (
const v: cxx::std::vector<T>) is SC063E at type check instead of a build failure. v[i]in a generic class, wherei's type depends on the class's parameter, compiles (was a crash, I003E[]on a record).- Duck mixins, slicing: a bound from a duck call in a mixin body (
s[1..self.dyn()->n()]) compiles (was I003E); an open range on a duck receiver (self.dyn()->xs()[1..]) is accepted. - Duck mixins,
for i in a..bwith a bound only the instance types compiles (was I003E); a bound that isn't an integer, or one that narrows, is a normal error. - Duck mixins, stored ranges: a range stored, passed or returned with such a bound (
var r = k..self.dyn()->n()) compiles; with only a literal as the other bound it's SC001E with a note;eval forover such a bound is SC192E.
Moves and ownership
cxx::std::move(v[i])/cxx::std::move(m[k])moves the element out and leaves the container moved-from (SC052E on a later use), as a@moveargument does; on a map a missing key gets a default value first (was a build failure on a move-only element).- C++ move check: a pointer passed through a C
...argument in a C++ body counts as an unknown call (a move under-fstrict-cxx-moves). - SC182E on a loop binder suggests
const *xwhere the loop yields read-only elements (a const vector, a set, a const-onlyop in). - Messages: SC182E's note names
std::move(...)for the explicit hand-off; R068E, S089E and S090E are reworded.
C and C++ interop
@export("name"): gives a free function the unmangled C symbolnamebeside its own; on wasm it's also the module export (instance.exports.name). C signatures only (SC369E); one name defined twice is SC370E.- P012W (new): warns when a host system header stands in for a missing
--cxx-include/--ffi-include/-Iroot, or one that lacks the header, for ffi imports, C/C++ inputs and kcc. ffi "c++" import <h>is S064E with a fix-it that quotes the header (import "h"); the header is still imported, so its names don't cascade into more errors.- A primitive after
::in a type (cxx::std::i32<N>) is R025E with a fix-it naming the primitive bare (was a compiler crash).
Allocation
- Global allocator: the
kairo_global_*functions of a@set_global_allocatorallocator must return with the scoped-allocator stack as they found it (stated inglobal_alloc.h).
Library
[T]::emplace(args...): builds the new last element in place from a constructor ofT; nothing is copied, moved or dropped into the slot.- Slices for C++ hosts:
size()anddata()are members of a slice, so a C++ file that includes a.kfile can calls.size()ands.data(). copy()andto_owned():string.copy()is always a deep copy andto_owned()is gone (see breaking changes).
Toolchain
kairo
--linker-arg=<arg>: passes one argument to the linker, repeatable and in order (a second spelling of--ld-flags);--linker-arg=--import-undefinedleaves body-lessffi "c"functions as wasm imports.-Xlinker <arg>(also--Xlinker) is accepted and joins--ld-flags/--linker-argin command-line order.--print-target-infoneeds no input file and reports the CPU a compile with the same flags uses (host default,--mcpu,--march).--emit-headers: a command-line input outside every search directory and library (no module path, so no header) is U026W naming the-I <dir>that gives it one (was a silent exit 0).- Sanitizers:
-fsanitize-address/-fsanitize-threadinstrument Kairo code and link the runtime from--sanitizer-runtime-dir=<dir>(none ships). glibc Linux targets only; musl,--staticor both sanitizers together are L002E. ASan seesmalloconly with--heaplib=libc. wasm32-unknown-unknown: Kairo code for it is refused up front (P011E, any WebAssembly triple with no OS) with a pointer towasm32-wasi, instead of failing in the runtime's headers; plain C/C++ builds are unchanged.- wasm32 and
--cache-dir: no moreunknown directive; the object cache is off for wasm targets. - Library cache: a leftover
.copy-/.tmp-/.stale-tree from an interrupted publish counts toward the 2 GB cap and is removed after a day. - Reproducible links: PE programs are linked with
-Brepro(no wall-clock timestamp), and Mach-O programs don't carry the object-cache record. - CRLF sources lex and report line ends and columns like LF sources; incremental replay scripts with CRLF line ends work.
- Windows: a crash exits with status 134, as on every other target, with no abort dialog.
- Windows: sources aren't held open while compiling, so saving a file during a compile or while kals runs, and
--incr-replayedits, work; a C/C++ header of 16 KiB or more isn't locked either (headers are read, not mapped).
kcc
--version/-vprint clang's banner (kcc-clang version 23.1.6 (...),Target:,Thread model:,InstalledDir:), so CMake identifies kcc as Clang for C and assembly.-vgoes to stderr, exits 0 with no input, and no longer turns on kairo's log (that's-Xkairo -v).- clang-cl mode:
--driver-mode=cland a-clprogram name take clang-cl's command line (/c,/Fo,/Fe,/I,/D,/O2,/std:,/Tc,/Tp); an object with no/Fois<stem>.obj;/Fo<dir>/is refused.
kfmt
- kfmt keeps
= NAME!on a declaration whose macro isn't defined, and formats expression-bodied functions whose body starts with a parenthesized operand (-> bool = (v as u32) < 0x80).
kals
- kals: the live worker's aside check no longer leaks a diagnostic collector per request.
ksys and sysroots
- glibc sysroots: the compiler-rt directory is named for the normalized triple (
x86_64-unknown-linux-gnu), so a C/C++ compiler given a glibc target and the root's resource dir finds crtbegin and the builtins. - glibc roots are link-only: running the stub
ld.soor a library prints that and how to run the program, exit 127 (was SIGSEGV). ksys build --outkeeps file permissions, and with--libc-onlykeeps a root's symlinks (sonames, loader links) as symlinks.SYSROOT.tomlextra_cflagsapply to C/C++ inputs (wasm32-wasi C++ exceptions are caught); thumbv7 Linux C/C++ compiles as Thumb-2, not A32.- Soft-float Arm (thumbv7m-none-eabi): no more spurious "+soft-float-abi is not a recognized feature" warning.
KaTAR
- ktextract reports a malformed archive trailer or table with a message and exits 1 instead of aborting, and rejects a name length larger than the archive.
Build
- build.py and
Scripts/cross_llvm.pyseed from the release tree before N-1, andcross_llvm.pyhonours$KAIRO_SEED. - build.py: a host build whose LLVM major differs from the bundled fork's stops at once and names the command that works (
--target x86_64-linux-musl --stale-llvm=use).
Fixes
Language and code generation
- Fixed:
null as T?compiles to the target's null (was an internal compiler error). - Fixed: a negative integer literal of 2^63 or more assigned to
i256ori512is sign-extended (it was zero-extended, a wrong value). - Fixed: an imported
inttypedef andlongtypedef are distinct base types on LLP64 and 32-bit targets (R028E where they clash); Darwin and wasm32 callsize_t's own C overload for ausizeargument; non-ASCII command-line arguments work on Windows. - Fixed:
evalstring constants (eval LIT: string = "abc") compile, and aneval fnthat takes or returns astringby value compiles. - Fixed:
F256,F512,F8E4M3andF8E5M2resolve in a file with no literal or keyword of the type. - Fixed:
eval ifin an interface or extension body keeps its taken branch: its requirements are required and its members are emitted (an untaken branch contributes nothing; avarthere is SC231E). - Fixed:
ffi import "sys/time.h"beforeffi import "time.h"no longer hidestime.h's names. - Fixed: overloads that differ only by a
requires T derives Bclause (against!(T derives B)or none) compile instead of aborting with I003E. - Fixed: importing a C++ header with a partial specialization whose argument names its own parameter (LLVM's
cl::applicator<char[n]>, for one) no longer crashes the compiler (a stack overflow in the name printer). - Fixed:
for *x/for const *xover a C++ range whose iterator is a rawconst T*(llvm::SmallVector) binds a pointer to const (was CL001E). - Fixed: passing
[T;]to a generic[const T;]parameter (f<T>(s),[T]::from_slice(s)) no longer fails at build (CL001E). - Fixed: a
constparameter of an imported type with deleted copy and move constructors compiles when a later argument of the call has a side effect (was CL001E). - Fixed: a generic call with a move-only
Targument beside a later argument that could change it no longer copies it (it failed to build); the operand is bound per instance. - Fixed:
collecton a chain over a generic parameter is no longer ambiguous (SC064E). - Fixed (memory safety): a value built under an
ifarm of aforheader and passed to a const parameter lives through the loop (it was read after it ended). - Fixed: a closure holding a MOVE capture, passed beside a panicking argument, trapped at run time.
- Fixed:
embed_str!crashed the compiler; it's reported as not supported yet (SC116E), and--print-tokensand--dump-preprocessedno longer crash on it. - Fixed: turning on a sanitizer no longer crashes the compiler (SIGSEGV in code generation while compiling the builtin library).
Toolchain
- Fixed: a source file rewritten during a compile no longer crashes the compiler (an ICE, or SIGBUS on Linux, macOS and the BSDs) or builds the wrong text.
- Fixed:
kairono longer stalls (hangs on Windows) when a C/C++ header it imports is missing, such as from a sysroot with no C++ headers. - Fixed:
--freestandingno longer compiles the hosted runtime (string.h/stdlib.hnot found with--builtins-diron a bare-metal target). - Fixed:
--disable-kairo-pass=spec-devirtalso turns off the backend's speculative devirtualization of single-target virtual calls. - Fixed:
kcc -std=c++20builds programs that use the library again.
Breaking changes
- Closure defaults: a short call through a closure variable that's reassigned, passed as
&f, or captured by|*f|/|*|is SC099E; pass every argument. - Literals: a character literal holding zero or several characters (
'','ab') and a base prefix with no digits (0x,0b,0o) are S001E ('ab'was accepted as a multi-character constant); use a string literal for text. - Generic bounds: a generic body that builds a bounded generic record at one of its own parameters (
Box<U>(u),Box<U>{ .. },@create Box<U>(u), through an alias too) needs that parameter's bounds to grant the record's: R051E for an unbounded parameter, R025E for one bounded by something else. Arequiresclause of alternatives (T impl A || T impl B) is held to the same rule. Add the bound to the caller's parameter. string.copy()is the deep copy: a view's copy owns its bytes (it was a view); a literal's copy is still the literal.to_owned()is removed, usecopy().- Slices:
to_owned()isto_vec();copy()is still the view copy.
Known issues
- ThinLTO bitcode from clang 22: linking third-party ThinLTO objects or archives written by clang 22 (or older) with 0.3.1's LLVM 23 linker can drop symbols that kept code still calls, so the link fails with undefined symbols. Link those libraries as non-LTO objects, or rebuild their bitcode with 0.3.1's
kcc;-fgc-sectionshides it on most ELF links but not on COFF. - ASan on the default heap: an ASan program on the default mimalloc heap crashes before
main; link it with--heaplib=libc. - meson can't detect kcc's linker yet:
kcc -Wl,--versionisn't forwarded. embed_str!isn't supported yet (SC116E).- Placeholder diagnostic codes: some diagnostics still carry a placeholder code (
R001E,SC001E,SC001W,U001E) andSC182Ecovers several situations, so--explaincan show general text. They get their own codes in a later release. - i686-linux-musl: a 64-bit
__atomic_*operation that isn't lock-free (an object not 8-byte aligned) fails to link (__atomic_compare_exchangeundefined). - CL001E instead of a diagnostic: returning a
const [T]parameter or aconstlocal (SC182E by the language reference) passes the checks and fails in code generation. overrideagainst a C++ base class isn't checked, so--type-check-onlyand kals miss a removed virtual.- NetBSD on 64-bit Arm has no archive; the installer says so and prints the command to build from source.