kairo
kairo is the compiler. It is written in Kairo, runs clang and lld in-process, and compiles and links in one command.
kairo main.k -o main # compile and link
kairo --type-check-only main.k
Common flags
| Flag | Meaning |
|---|---|
-o <file> | output name |
-c, -S | stop after the object / assembly |
--emit=obj,asm,llvm-ir,llvm-bc | choose the outputs. obj alone links; one other kind stops there and -o names that file; two or more kinds link only with -o, which names the executable, and the kinds are written beside it. Empty or repeated items change nothing (obj, is obj) |
--emit-headers=<dir> | write one C++ header per module (Using Kairo in C++) |
--type-check-only | parse and check without generating code |
--target=<triple>, --sysroot=<dir>, --freestanding, --native | cross-compilation and sysroots |
--no-sysroot-build | with --target and no installed or cached sysroot, refuse (P009E, exit 2) instead of building one with ksys |
--sysroot-exact | use --sysroot exactly as given: never substitute a bundled or cached sysroot for the target (what ksys itself relies on when it compiles the runtimes) |
--print-runtimes-revision | print the LLVM runtimes revision this compiler was built from, and exit |
--progress=auto|always|never|lines | the build status line |
--sema-threads=N, --codegen-threads=N, --threads=N | parallelism of type checking and code generation |
--interface-pch=auto|on|off | share precompiled Kairo interfaces between files |
--cache-dir <dir>, --force-recompile | incremental compilation: unchanged files skip code generation |
-finfer-purity / -fno-infer-purity | infer const / @pure for functions that make no promise (on by default) |
-fimplicit-conv / -fno-implicit-conv | Kairo's implicit conversions (Conversion Lattice); on by default. Applies to your files only: the builtin and std libraries always compile with the default rules |
-funwind, -fcxx-implicit-conv | apply to your own files only; the standard library always compiles with noexcept functions and without C++ implicit conversions |
-fcxx-implicit-conv / -fno-cxx-implicit-conv | at a call into C++, apply the implicit conversions C++ would (one converting constructor or conversion operator; a string literal as its const char[N]); off by default, so such an argument needs as T |
-Wconst-self | opt-in lint for methods that could take const self |
--error-format=..., --explain <CODE>, --diag-show-ids | diagnostics: --explain prints the long form of a code |
--print-stats, -v | timings, counts, and what each step did Also, in a build with an import cycle, the number of re-export fixpoint rounds |
--help, --help-hidden | list the flags; --help-hidden adds internal and not-yet-implemented ones |
On x86, --march names a CPU as --mcpu does, and an unknown one is an error (P006E) before compilation starts. --print-ast=tree lists a struct's and union's constructors and operators as well as its fields.
Targets and sysroots
--target=<triple> compiles for another platform. The first time you name a target whose sysroot is neither shipped in the install (<install>/sysroot/) nor already cached, kairo builds it in-process from the sources the toolchain ships and prints building sysroot for <name>, first time only. Later builds reuse the cached root. --sysroot=<dir> names a root you already have, --freestanding compiles without one, and --no-sysroot-build turns the automatic build into an error. A failed build is P010E (exit 3); a refusal is P009E (exit 2). The *-apple-macosx and *-windows-msvc targets need your own SDK and are never built this way (ksys). Target names, including the glibc version suffix (x86_64-linux-gnu.2.17), the cache and KAIRO_SYSROOT_CACHE are on the ksys page.
Pretty diagnostics show the location as file:line:col. On a terminal a build prints a single status line (parse, sema, codegen with counts) that disappears before any diagnostic appears.
kairo finds its standard library, runtime and clang resources relative to its own location, so an unpacked release runs without flags. python3 build.py stages the same layout when building from source (Installation). See also kcc, ksys, kld and kfmt.