Target Triples
A target triple names the platform a program is compiled for,
independently of the platform the toolchain runs on (the host).
Karkain owns this model: pkg/target parses, validates and normalizes
triples on its own terms and never delegates triple handling to an
external compiler framework.
Canonical short triples
The canonical short form is <arch>-<os>. Karkain supports eight
(Phase 139 added the Windows-ARM64, RISC-V and macOS rows):
Triple |
Meaning |
|---|---|
|
AMD64 / Windows (MinGW-w64 GNU toolchain flavor by default) |
|
ARM64 / Windows ( |
|
AMD64 / Linux (glibc, GNU) |
|
ARM64 / Linux (glibc, GNU) |
|
RISC-V 64-bit / Linux (parse + error paths; no backend builds it yet) |
|
AMD64 / macOS (clang |
|
ARM64 / macOS, Apple Silicon (clang |
|
WebAssembly 32-bit / WASI |
Long-form normalization
Conventional vendor- and ABI-bearing triples are accepted and normalized to the canonical short form (the vendor component is dropped):
x86_64-pc-windows-msvc → x86_64-windows
x86_64-unknown-linux-gnu → x86_64-linux
aarch64-unknown-linux-gnu → aarch64-linux
x86_64-windows-gnu → x86_64-windows
riscv64-unknown-linux-gnu → riscv64-linux
x86_64-apple-macosx → x86_64-macos
x86_64-darwin → x86_64-macos
aarch64-apple-macosx → aarch64-macos
When the triple does not name an environment/ABI, Karkain assumes the default for the OS: GNU for Windows and Linux (its native pipeline links through MinGW-w64 gcc on Windows and glibc gcc on Linux); macOS and WASI targets carry no ABI (macOS builds go through clang by design).
Model
The pkg/target model components are:
Architecture —
x86_64,aarch64,riscv64,wasm32OS —
windows,linux,macos,wasiEnvironment/ABI —
gnu,msvc,musl(recognized, not buildable)
ABI sanity checks reject combinations no real backend supports, e.g.
msvc on Linux or macOS, gnu on macOS or WASI, musl for any
current backend, riscv64 outside Linux, macos outside
x86_64/aarch64, and wasm32 paired with any OS other than wasi.
Invalid components produce precise ParseError diagnostics listing the
supported values:
$ karkain build hello.kark --target sparcv9-solaris
unsupported architecture 'sparcv9' in target 'sparcv9-solaris'
(supported architectures: x86_64, aarch64, riscv64, wasm32)
Features model
Every parseable target yields a Features record describing its ABI
facts — derived from the model, never guessed from the host:
Pointer width — 64 bits for x86_64/aarch64/riscv64, 32 for wasm32
Endianness — little-endian for all current targets
Object / executable formats — ELF, PE/COFF, Mach-O, or WASM
ABI name — e.g. Microsoft x64, System V x86_64/glibc, System V x86_64/Apple, WebAssembly/WASI
Runtime variant —
windows,linux-gnu,macos, orwasiLinker requirement — what an external C toolchain must supply (MinGW triple,
<arch>-linux-gnu-gcc, clang--targetfor macOS, or “none” for WASM because the backend emits the module directly)
Host vs foreign
``SameMachine`` compares architecture + OS — machine kind, not triples.
x86_64-pc-windows-msvcandx86_64-windowsare the same machine even though their ABIs differ;x86_64-linuxis never the same machine as a Windows host.``IsHost`` reports whether a target equals the running toolchain’s platform. Host detection is used only to derive the implicit
nativetarget and to gate cross-run — never as a substitute for an explicit target.
In-language builtins
target.os / target.arch builtins that expose the current
target to Karkain source are planned (post-111). They would require
kcc-parity changes and are not available today.
See also
Host Targets — host detection and the full pkg/target
model.
Cross-Compilation — building for a target in the matrix.
Target — the karkain target command output.