General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
A general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
Resources
- Introduction
- Download & Documentation
- Chapter 0 - Getting Started | ZigLearn.org
- Community
- Contributing
- Code of Conduct
- Frequently Asked Questions
- Community Projects
Installation
- download a pre-built binary
- install from a package manager
- build from source
- bootstrap zig for any target
from
https://github.com/ziglang/zig
------------------------------------
Building Zig From Source
The primary reason to build from source is in order to participate in the development process of Zig itself. Building from source means that you can make changes to Zig itself and then test out those changes.
If your goal is to install a specific version of Zig, you can find pre-built tarballs on the download page. You could also try installing Zig from a package manager. Finally, there is zig-bootstrap to cross-compile an installation of Zig from source for any target. When using zig-bootstrap, be sure to check out the git tag corresponding to the version you want to build, as master branch is not kept in any coherent state.
When building from source, pay attention to which commits failed and succeeded CI checks. Check the commit history and notice which commits succeeded (
If you run into trouble, first refer to Troubleshooting Build Issues, and then ask politely for help in one of the Community spaces.
The following steps are for Unix-like operating systems. For Windows, refer to Building Zig on Windows.
It is recommended to follow Option A after doing a git pull
, modifying the cmake line with -DCMAKE_BUILD_TYPE=Release
and then following Option B while working on a feature branch, using Option A as your prior build of Zig.
Option A: Use Your System Installed Build Tools
Dependencies
- cmake >= 2.8.12
- gcc >= 7.0.0 or clang >= 6.0.0
- LLVM, Clang, LLD development libraries == 16.x, compiled with the same gcc or clang version above
- Use the system package manager, or build from source.
Instructions
mkdir build
cd build
cmake ..
make install
Please be aware of the handy cmake variable CMAKE_PREFIX_PATH
. CMake will look for LLVM and other dependencies in this location first.
For macOS + Homebrew, use these commands:
mkdir build
cd build
cmake .. -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="$(brew --prefix llvm);$(brew --prefix zstd)"
make install
This produces stage3/bin/zig
which is the Zig compiler built by itself.
from
https://github.com/ziglang/zig/wiki/Building-Zig-From-Source