Command-Line Tool
Commands, flags, targets, release behaviour, output defaults, and environment variables.
Contents
The compiler is a single executable named hz. It compiles one entry file, follows the file's use declarations, and produces an executable, assembly, object file, or UQBE IL. It also provides a formatter, an AST printer, a test runner, and a language server.
Commands#
| Command | Behaviour |
|---|---|
hz file.hz |
Compile and link an executable |
hz run file.hz |
Compile and run the executable |
hz build file.hz |
Alias for ordinary compilation |
hz check file.hz |
Alias for ordinary compilation |
hz compile file.hz |
Alias for ordinary compilation |
hz asm file.hz |
Stop after assembly |
hz qbe file.hz |
Stop after UQBE IL |
hz fmt file.hz |
Format to standard output |
hz fmt -w file.hz |
Format in place |
hz fmt -check file.hz |
Fail if the file is not formatted |
hz fmt -stdin |
Read source from standard input and write formatted source |
hz ast file.hz |
Parse and print the syntax tree |
hz test path |
Run test blocks in a file or directory |
hz lsp |
Run the language server on standard input and output |
The command names are aliases for flag combinations. The canonical form is a flag before the file, as in hz -run file.hz and hz -S file.hz.
Flags#
| Flag | Meaning |
|---|---|
-o file |
Output path |
-target name |
Select a UQBE target |
-S |
Stop after assembly |
-c |
Stop after object file |
-qbe |
Stop after UQBE IL emission |
-run |
Run the produced executable |
-release |
Omit runtime contract and invariant checks |
-d |
Link dynamically; the default is static |
-keep |
Keep temporary files |
-cc path |
C compiler used for assembly and linking |
-runtime path |
Path to the runtime archive |
-Ldir |
Add a linker search directory |
-llib |
Link an external library |
-v |
Print the version |
-verbose |
Print the tool commands |
-w |
Format in place |
-check |
Fail if formatting differs |
-stdin |
Read formatting input from standard input |
-h |
Print help |
GNU-style long flags such as --help are rejected. Use the single-dash forms.
Targets#
| Target | Architecture | Platform |
|---|---|---|
amd64_sysv |
x86-64 | System V ABI |
amd64_apple |
x86-64 | macOS |
amd64_win |
x86-64 | Windows |
arm64 |
AArch64 | Default platform |
arm64_apple |
AArch64 | macOS |
arm64_win |
AArch64 | Windows |
rv64 |
RISC-V 64 | Default platform |
Platform aliases such as linux/amd64, darwin/arm64, and windows/amd64 are accepted. The default target is the host target supplied by UQBE. A cross-target build still needs a C compiler capable of assembling and linking for the target.
Output Defaults#
| Mode | Default output |
|---|---|
| Executable | Input path with the extension removed |
-qbe |
<input>.ssa |
-S |
<input>.s |
-c |
<input>.o |
| Windows executable | The same path with .exe when no extension is present |
-o - writes IL or assembly to standard output. The executable mode requires a real output path.
Release Mode#
-release removes generated runtime checks. It does not disable compile-time evaluation, and it does not remove test assertions.
| Check | Debug | Release |
|---|---|---|
| Compile-time contract folding | Yes | Yes |
| Constant-false contract rejection | Yes | Yes |
| Runtime preconditions | Yes | No |
| Runtime postconditions | Yes | No |
| Runtime loop invariants | Yes | No |
| Runtime checked-construction invariants | Yes | No |
| Runtime index bounds checks | Yes | Yes |
assert in tests |
Yes | Yes |
The flag is a performance switch for a program that has been verified by other means. It is not a way to bypass a failing contract.
Formatting#
hz fmt uses four spaces per indentation level, a target line width of 100 columns, and a token-based layout that normalizes operator spacing, contract colons, braces, and alignment. It preserves blank-line groups and collapses some single-return blocks into => bodies. -w writes the result back to the file; -check exits with a failure status when the file is not formatted.
The formatter does not type-check and does not evaluate @cfg. It is safe to run on a file that is not yet compilable, but a malformed token stream will still fail to format.
Environment Variables#
| Variable | Effect |
|---|---|
HAZE_RUNTIME |
Path to the runtime archive when -runtime is not given |
HAZE_CC |
C compiler when -cc is not given |
CC |
Fallback C compiler |
HAZE_HEAP_SIZE |
Runtime heap size for the generated program |
HAZE_GC_WORKERS |
Number of collector workers |
HAZE_GC_LOG |
Enable collector logging |
HAZE_GC_VERIFY |
Enable collector verification |
HAZE_GC_STRESS |
Enable collector stress behaviour |
The runtime variables affect the generated program, not the compiler. They are useful for diagnosing memory behaviour but are not part of the language's portable semantics.
Diagnostics#
Compiler errors use a Rust-style source snippet with a primary label, optional secondary labels, notes, and hints. A warning is printed with a file, line, and column. Color is enabled only when the output stream is a terminal.
The exit status is zero on success and non-zero on a compile, link, or runtime failure. A main returning i32 supplies the process exit status of the generated program; a void main exits with zero.
The Language Server#
hz lsp runs a JSON-RPC server on standard input and output. It supports full-document synchronization, completion (triggered by : and .), signature help (triggered by ( and ,), hover, and go-to-definition. Diagnostics publication, formatting, rename, and code actions are not implemented in the current tree.
For formatting in an editor, run hz fmt -w on save. For a quick syntax check, run hz -S file.hz or hz ast file.hz.