General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
Go to file
2019-05-08 22:05:59 -04:00
.builds freebsd ci: install wget and set -x -e 2019-03-18 23:44:29 -04:00
c_headers update clang C headers to 8.0.0rc3 2019-02-28 13:52:17 -05:00
ci Don't install stage2 artifacts 2019-04-30 12:13:41 -04:00
cmake Fix alignment of macro FIND_AND_ADD_CLANG_LIB 2019-04-24 14:42:08 -04:00
deps add patch to LLD to fix deadlock race condition in wasm linker 2019-04-16 03:56:46 -04:00
doc docgen: show -target command line argument 2019-05-03 15:56:33 -04:00
example breaking changes to zig build API and improved caching 2019-03-08 23:23:11 -05:00
libc Merge remote-tracking branch 'origin/master' into llvm8 2019-03-18 20:03:23 -04:00
libcxx/include libcxx headers 8.0.0rc3 2019-03-05 22:42:35 -05:00
libunwind libunwind 8.0.0rc3 2019-03-05 22:42:14 -05:00
src self-hosted translate-c progress on function decls 2019-05-08 22:05:59 -04:00
src-self-hosted self-hosted translate-c progress on function decls 2019-05-08 22:05:59 -04:00
std add --bundle-compiler-rt function to link options 2019-05-08 20:51:49 -04:00
test translate-c: NULL pointers translate to null 2019-05-08 19:21:54 -04:00
.gitattributes fix gitattributes 2019-03-12 18:40:31 -04:00
.gitignore fix .gitignore file and add commit missing std lib file 2019-02-26 18:33:27 -05:00
build.zig add --bundle-compiler-rt function to link options 2019-05-08 20:51:49 -04:00
CMakeLists.txt Implement stack probes for x86/x86_64 2019-05-08 12:36:54 -04:00
LICENSE add license 2015-08-05 16:22:18 -07:00
README.md Update README.md 2019-05-08 05:11:21 -04:00

ZIG

Zig is an open-source programming language designed for robustness, optimality, and maintainability.

Resources

Building from Source

Build Status

Note that you can download a binary of master branch.

Stage 1: Build Zig from C++ Source Code

Dependencies

POSIX
  • cmake >= 2.8.5
  • gcc >= 5.0.0 or clang >= 3.6.0
  • LLVM, Clang, LLD development libraries == 8.x, compiled with the same gcc or clang version above
Windows
  • cmake >= 2.8.5
  • Microsoft Visual Studio 2017 (version 15.8)
  • LLVM, Clang, LLD development libraries == 8.x, compiled with the same MSVC version above

Instructions

POSIX
mkdir build
cd build
cmake ..
make install
MacOS
brew install cmake llvm@8
brew outdated llvm@8 || brew upgrade llvm@8
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=/usr/local/Cellar/llvm/8.0.0
make install
Windows

See https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows

Stage 2: Build Self-Hosted Zig from Zig Source Code

Note: Stage 2 compiler is not complete. Beta users of Zig should use the Stage 1 compiler for now.

Dependencies are the same as Stage 1, except now you can use stage 1 to compile Zig code.

bin/zig build --build-file ../build.zig --prefix $(pwd)/stage2 install

This produces ./stage2/bin/zig which can be used for testing and development. Once it is feature complete, it will be used to build stage 3 - the final compiler binary.

Stage 3: Rebuild Self-Hosted Zig Using the Self-Hosted Compiler

Note: Stage 2 compiler is not yet able to build Stage 3. Building Stage 3 is not yet supported.

Once the self-hosted compiler can build itself, this will be the actual compiler binary that we will install to the system. Until then, users should use stage 1.

Debug / Development Build

./stage2/bin/zig build --build-file ../build.zig --prefix $(pwd)/stage3 install

Release / Install Build

./stage2/bin/zig build --build-file ../build.zig install -Drelease-fast

Contributing

Start a Project Using Zig

One of the best ways you can contribute to Zig is to start using it for a personal project. Here are some great examples:

  • Oxid - arcade style game
  • TM35-Metronome - tools for modifying and randomizing Pokémon games
  • trOS - tiny aarch64 baremetal OS thingy

Without fail, these projects lead to discovering bugs and helping flesh out use cases, which lead to further design iterations of Zig. Importantly, each issue found this way comes with real world motivations, so it is easy to explain your reasoning behind proposals and feature requests.

Ideally, such a project will help you to learn new skills and add something to your personal portfolio at the same time.

Spread the Word

Another way to contribute is to write about Zig, or speak about Zig at a conference, or do either of those things for your project which uses Zig. Here are some examples:

Zig is a brand new language, with no advertising budget. Word of mouth is the only way people find out about the project, and the more people hear about it, the more people will use it, and the better chance we have to take over the world.

Finding Contributor Friendly Issues

Please note that issues labeled Proposal but do not also have the Accepted label are still under consideration, and efforts to implement such a proposal have a high risk of being wasted. If you are interested in a proposal which is still under consideration, please express your interest in the issue tracker, providing extra insights and considerations that others have not yet expressed. The most highly regarded argument in such a discussion is a real world use case.

The issue label Contributor Friendly exists to help contributors find issues that are "limited in scope and/or knowledge of Zig internals."

Editing Source Code

First, build the Stage 1 compiler as described in the Building section.

When making changes to the standard library, be sure to edit the files in the std directory and not the installed copy in the build directory. If you add a new file to the standard library, you must also add the file path in CMakeLists.txt.

To test changes, do the following from the build directory:

  1. Run make install (on POSIX) or msbuild -p:Configuration=Release INSTALL.vcxproj (on Windows).
  2. bin/zig build --build-file ../build.zig test (on POSIX) or bin\zig.exe build --build-file ..\build.zig test (on Windows).

That runs the whole test suite, which does a lot of extra testing that you likely won't always need, and can take upwards of 2 hours. This is what the CI server runs when you make a pull request.

To save time, you can add the --help option to the zig build command and see what options are available. One of the most helpful ones is -Dskip-release. Adding this option to the command in step 2 above will take the time down from around 2 hours to about 6 minutes, and this is a good enough amount of testing before making a pull request.

Another example is choosing a different set of things to test. For example, test-std instead of test will only run the standard library tests, and not the other ones. Combining this suggestion with the previous one, you could do this:

bin/zig build --build-file ../build.zig test-std -Dskip-release (on POSIX) or bin\zig.exe build --build-file ..\build.zig test-std -Dskip-release (on Windows).

This will run only the standard library tests, in debug mode only, for all targets (it will cross-compile the tests for non-native targets but not run them).

When making changes to the compiler source code, the most helpful test step to run is test-behavior. When editing documentation it is docs. You can find this information and more in the --help menu.