Contents

Haze is distributed as source. The compiler is written in C++23 and uses the UQBE backend, which is vendored by the build. The generated programs link against a small runtime library that is embedded into the compiler and extracted when needed.

Requirements#

Requirement Notes
A C compiler Used to assemble and link generated code; cc by default
A supported target amd64_sysv, amd64_apple, amd64_win, arm64, arm64_apple, arm64_win, or rv64

The compiler does not require LLVM. UQBE is fetched and built as part of the project. To build from source a C++23 compiler and CMake are required.

Building from Source#

From the repository root, configure a release build and compile the hz target.

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 own executable, so the binary and the library directory should stay together.

Installing#

Installation places hz and hazelib under a prefix. The conventional local prefix is $HOME.

cmake --install build --prefix "$HOME"

After installation, hz should be on PATH. The project's fw/install.sh script is a convenience wrapper for the same command.

Verifying the Toolchain#

Print the version and compile a program that does not use the standard library.

hz -v
printf 'fn main() {\n    print("ok")\n}\n' > /tmp/hello.hz
hz -run /tmp/hello.hz

The program should print ok. If the compiler cannot find the runtime, the diagnostic names the searched locations. The environment variable HAZE_RUNTIME can point at libhazert.a directly, and the -runtime flag overrides both.

Editor Support#

The compiler includes a language server. Run hz lsp from an editor configuration and connect it over standard input and output. The server supports completion, signature help, hover, and go-to-definition for Haze files.

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 yet implemented
Formatting, rename, code actions Not yet implemented

For formatting, invoke hz fmt directly. Editors can run it on save with hz fmt -w file.hz or verify formatting in continuous integration with hz fmt -check file.hz.

Troubleshooting#

Symptom Likely 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 The library was not passed to the compiler Add -l name and, if needed, -L directory
Generated binary will not run on another machine The default link is static but the runtime may still depend on libc Rebuild for the target platform with the appropriate -target
hz: ... rejected; use single-dash GNU-style long flags are not accepted Use Plan 9 style flags such as -target, not --target

Next Steps#

The next chapter, Your First Program, introduces the edit, compile, and run loop and the first contract. Readers who prefer a broad map before details can continue to the Language Tour.