Skip to content

Compiler reference

Thor is the normal way to build applications. This page documents zapc for editor integration, custom tooling, and compiler diagnostics. For a project, start with Thor build tool.

The compiler itself accepts one source entry point:

Terminal window
zapc main.zp -o app
./app

Run zapc --help to see the options supported by the installed version. In a Thor project, pass a one-off compiler option with thor build -- <option>.

OptionEffect
-o pathSet the output path
-O0, -O1, -O2, -O3Set the optimization level
-cCompile and assemble without linking
-SCompile without assembling or linking
-emit-llvmEmit LLVM IR
-emit-zirEmit Zap IR
--target=tripleSelect an LLVM target triple
-l nameLink a library
-L pathAdd a library search directory
OptionEffect
--import-map alias=pathMap an import prefix to a path; may be repeated
--print-stdlib-pathPrint the resolved standard library directory
--print-core-pathPrint the resolved core library directory
-nopreludeDisable the automatic prelude import
-nostdlibDo not link the standard library
--freestandingCompile without host OS runtime assumptions

-noprelude removes convenient names such as println, List, and StringView from the automatic scope. It does not by itself make a program freestanding.

Terminal window
zapc main.zp -emit-zir -o main.zir
zapc main.zp -emit-llvm -o main.ll

These forms are useful when reporting a compiler bug. Include the smallest source file that reproduces the problem, the exact command, the compiler version from zapc --version, and the emitted diagnostic.

--allow-unsafe is deprecated. Unsafe language features are enabled without that flag.