Start

Installation

The fastest way in is a prebuilt klainmain binary from the latest release; if you'd rather build the compiler yourself, or your platform isn't in a given release, build it from source. Either way klainmain is the compiler only — it drives clang, and a compiled program links nothing beyond plain libc unless it actually uses a feature that needs more.

Install a prebuilt binary

Every release ships a klainmain for each platform whose test suite passed for that version — Linux x64/arm64, macOS x64/arm64 (Apple Silicon), Windows x64 — as klainmain-v<version>-<platform>[.exe] with a checksums.txt on the GitHub Releases page. The one-line installers fetch the right asset, verify its SHA-256, and print klainmain --version when done.

macOS / Linux

shell
# → ~/.local/bin/klainmain (no sudo)
$ curl -fsSL https://raw.githubusercontent.com/memphisx/KlainMainLang/main/install.sh | sh
$ klainmain --version

Windows (PowerShell)

powershell
# → %LOCALAPPDATA%\Programs\klainmain\klainmain.exe (no elevation; added to your PATH)
PS> irm https://raw.githubusercontent.com/memphisx/KlainMainLang/main/install.ps1 | iex
PS> klainmain --version

Both installers honour KLAINMAIN_VERSION=v0.64.0 (pin a specific release instead of the latest) and KLAINMAIN_INSTALL_DIR (install elsewhere). If your platform's lane was red for a release it's left out of that release and the script says so — it returns with the next release that's green there, or build from source below in the meantime.

klainmain still needs clang on PATH to compile your programs (it emits LLVM IR and hands it to clang), plus any optional library a program actually uses. On Windows that toolchain is the mingw-w64 UCRT sysroot from MSYS2 — see the README's Windows section for the exact package list.

Build from source

Two things are always required to build the compiler:

  • Go 1.26+ — builds the compiler itself (see go.mod for the exact pinned version).
  • clang (LLVM 15+, opaque-pointer support) — the backend that turns emitted LLVM IR into a native binary.

macOS (Apple Silicon or Intel)

shell
# Homebrew — https://brew.sh
$ brew install go llvm
# clang from the llvm formula, or use Xcode's:  xcode-select --install

Debian / Ubuntu

shell
$ sudo apt-get update
$ sudo apt-get install golang clang

Alpine

shell
$ apk add go clang

Windows

Windows x64 builds through the mingw-w64 UCRT toolchain from MSYS2 (Git for Windows supplies the Git Bash the Makefile expects). The full package list and PATH ordering live in the README's Windows section.

Clone & build

shell
$ git clone https://github.com/memphisx/KlainMainLang
$ cd KlainMainLang
$ make build            # → ./klainmain

That produces ./klainmain in the repo root (stamped with git describe; make dist cross-compiles every platform into dist/). Point it at a .ts file and run the binary it writes next to the source:

shell
$ ./klainmain examples/basics/basics.ts   # → examples/basics/basics
$ ./examples/basics/basics                # run it yourself

Optional feature libraries

Every library below is linked only when your program uses the feature — the same conditional-linking convention throughout. A program that never touches these stays plain-libc, so install a library only when you hit the feature that needs it. This applies whether you installed a prebuilt klainmain or built it from source.

FeatureLibraryInstall
fetch / http.listenlibcurlbrew install curl · apt-get install libcurl4-openssl-dev · apk add curl-dev
http.listen (h2c)libnghttp2brew install nghttp2 · apt-get install libnghttp2-dev · apk add nghttp2-dev
RegExplibpcre2-8brew install pcre2 · apt-get install libpcre2-dev · apk add pcre2-dev
crypto.subtle / tls / wss://OpenSSL 3brew install openssl@3 · apt-get install libssl-dev · apk add openssl-dev
bigintlibtommath (default)brew install libtommath · apt-get install libtommath-dev · apk add libtommath-dev
-mm=gc (opt-in GC)bdw-gc / libgcbrew install bdw-gc · apt-get install libgc-dev · apk add gc-dev

crypto.getRandomValues / randomUUID use the OS CSPRNG directly and need no library. On macOS, -crypto=commoncrypto uses the built-in CommonCrypto with zero install. GMP is an alternative bigint backend via -bigint=gmp. On Windows these come from the MSYS2 UCRT packages (see the README's Windows section).