Installation
Build the Haze compiler and configure an editor.
Contents
The compiler is written in C++23 and uses a vendored UQBE backend. Generated programs link against a small runtime library embedded in the compiler.
Requirements#
| Requirement | Notes |
|---|---|
| A C compiler | Assembles and links generated code; cc by default |
| A supported target | amd64_sysv, amd64_apple, amd64_win, arm64, arm64_apple, arm64_win, or rv64 |
| A C++23 compiler and CMake | Required to build the compiler |
Building#
From the repository root:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
The build produces build/hz and copies hazelib/ next to it. The compiler finds the standard library relative to its executable, so the binary and library directory must stay together.
Installing#
cmake --install build --prefix "$HOME"
This installs hz and hazelib under the prefix. fw/install.sh wraps the same command.
Verifying#
hz -v
printf 'fn main() {\n print("ok")\n}\n' > /tmp/hello.hz
hz -run /tmp/hello.hz
The program prints ok. If the runtime cannot be found, the diagnostic lists the searched locations. HAZE_RUNTIME names libhazert.a directly; -runtime overrides both.
Editor Support#
Run hz lsp and connect over standard input and output.
| Capability | Status |
|---|---|
| Full-document synchronization | Supported |
| Completion | Supported, triggered by : and . |
| Signature help | Supported, triggered by ( and , |
| Hover | Supported |
| Go to definition | Supported |
| Diagnostics publication | Not implemented |
| Formatting, rename, code actions | Not implemented |
Use hz fmt for formatting. hz fmt -w file.hz rewrites in place; hz fmt -check file.hz verifies formatting.
Troubleshooting#
| Symptom | Cause | Remedy |
|---|---|---|
cannot find module 'std/...' |
hazelib is not next to the compiler |
Reinstall, or keep build/hz and build/hazelib together |
Linker cannot find libhazert.a |
Runtime archive missing from the search path | Use -runtime path/to/libhazert.a or set HAZE_RUNTIME |
| Linker cannot find a C library | Library not passed to the compiler | Add -l name and, if needed, -L directory |
| Binary fails on another machine | The default link is static but the runtime may depend on libc | Rebuild for the target platform with -target |
hz: ... rejected; use single-dash |
GNU-style long flags are not accepted | Use Plan 9 style flags such as -target |