Install Calx
Build the calx command from source on Windows or Linux, put it on your PATH, and check that it runs a program.
Calx has no releases yet, so you build the compiler from source. It’s one CMake build. Calx runs on Windows and Linux, on 64-bit x86.
What you need
Section titled “What you need”- Git, to get the source.
- CMake 3.20 or later, and Ninja.
- clang and lld, from LLVM 18 or later. Calx compiles programs to C and has clang build that C, so you need clang to run programs, as well as to build the compiler.
- On Windows, Visual Studio or its Build Tools, with the “Desktop development with C++” workload. clang links programs against the C runtime and the Windows SDK that come with it. You can get them from visualstudio.microsoft.com.
- Python 3, only if you want to run the test suite.
On Ubuntu or Debian:
sudo apt install git cmake ninja-build clang lldIf clang --version says your clang is older than 18, apt.llvm.org has newer ones.
On Windows, with winget:
winget install Git.Gitwinget install Kitware.CMakewinget install Ninja-build.Ninjawinget install LLVM.LLVMLLVM’s installer puts clang in C:\Program Files\LLVM\bin. Add that folder to your PATH, or set CALX_CC to the full path of clang.exe.
Release builds use x86-64-v3 instructions, so the programs they make need a processor with AVX2, as most made since 2015 have. Debug builds run on any 64-bit x86 processor.
Build the compiler
Section titled “Build the compiler”git clone https://github.com/ellipog/calxcd calxcmake -S compiler -B build/compiler -G Ninja -DCMAKE_CXX_COMPILER=clang++ninja -C build/compilerThat makes build/compiler/calx, or calx.exe on Windows. It finds its runtime in the checkout it was built from, so leave the checkout where it is. If you move it, set CALX_HOME to the new place.
Add the build/compiler folder to your PATH. The guide and the reference call the command calx.
Check that it works
Section titled “Check that it works”From the checkout:
calx run tests/basics/hello.calxIt prints hello, calx, then four more lines. The first run builds Calx’s runtime as well as the program, which takes a moment. After that, a program that hasn’t changed starts in milliseconds.
If it says it can’t find clang, put clang on your PATH, or set CALX_CC to its full path.
Where builds go
Section titled “Where builds go”The compiler caches what it builds. The cache is in %LOCALAPPDATA%\calx\cache on Windows, and in ~/.cache/calx on Linux, or under XDG_CACHE_HOME if that’s set. CALX_CACHE puts it somewhere else. Deleting it is always safe: the next build makes it again.
The tests
Section titled “The tests”python tests/run.py builds the compiler and runs the test suite, which includes every example in these docs. CI runs it in debug and release builds, on Windows and Linux.
- Set up your editor: the VS Code extension highlights Calx and shows errors as you type (editor support).
- Start the guide with Getting started, which writes a first program.