| ... | @@ -14,98 +14,12 @@ A general-purpose programming language and toolchain for maintaining | ... | @@ -14,98 +14,12 @@ A general-purpose programming language and toolchain for maintaining |
| 14 | * [Frequently Asked Questions](https://github.com/ziglang/zig/wiki/FAQ) | 14 | * [Frequently Asked Questions](https://github.com/ziglang/zig/wiki/FAQ) |
| 15 | * [Community Projects](https://github.com/ziglang/zig/wiki/Community-Projects) | 15 | * [Community Projects](https://github.com/ziglang/zig/wiki/Community-Projects) |
| 16 | | 16 | |
| 17 | ## Building from Source | 17 | ## Installation |
| 18 | | 18 | |
| 19 | [](https://dev.azure.com/ziglang/zig/_build/latest?definitionId=1&branchName=master) | 19 | * [download a pre-built binary](https://ziglang.org/download/) |
| 20 | | 20 | * [install from a package manager](https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager) |
| 21 | Note that you can | 21 | * [build from source](https://github.com/ziglang/zig/wiki/Building-Zig-From-Source) |
| 22 | [download a binary of the master branch](https://ziglang.org/download/#release-master) or | 22 | * [bootstrap zig for any target](https://github.com/ziglang/zig-bootstrap) |
| 23 | [install Zig from a package manager](https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager). | | |
| 24 | | | |
| 25 | ### Stage 1: Build Zig from C++ Source Code | | |
| 26 | | | |
| 27 | This step must be repeated when you make changes to any of the C++ source code. | | |
| 28 | | | |
| 29 | #### Dependencies | | |
| 30 | | | |
| 31 | ##### POSIX | | |
| 32 | | | |
| 33 | * cmake >= 2.8.5 | | |
| 34 | * gcc >= 5.0.0 or clang >= 3.6.0 | | |
| 35 | * LLVM, Clang, LLD development libraries == 11.x, compiled with the same gcc or clang version above | | |
| 36 | - Use the system package manager, or [build from source](https://github.com/ziglang/zig/wiki/How-to-build-LLVM,-libclang,-and-liblld-from-source#posix). | | |
| 37 | | | |
| 38 | ##### Windows | | |
| 39 | | | |
| 40 | * cmake >= 3.15.3 | | |
| 41 | * Microsoft Visual Studio. Supported versions: | | |
| 42 | - 2017 (version 15.8) | | |
| 43 | - 2019 (version 16) | | |
| 44 | * LLVM, Clang, LLD development libraries == 11.x | | |
| 45 | - Use the [pre-built binaries](https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows) or [build from source](https://github.com/ziglang/zig/wiki/How-to-build-LLVM,-libclang,-and-liblld-from-source#windows). | | |
| 46 | | | |
| 47 | #### Instructions | | |
| 48 | | | |
| 49 | ##### POSIX | | |
| 50 | | | |
| 51 | ``` | | |
| 52 | mkdir build | | |
| 53 | cd build | | |
| 54 | cmake .. | | |
| 55 | make install | | |
| 56 | ``` | | |
| 57 | | | |
| 58 | Need help? [Troubleshooting Build Issues](https://github.com/ziglang/zig/wiki/Troubleshooting-Build-Issues) | | |
| 59 | | | |
| 60 | ##### MacOS | | |
| 61 | | | |
| 62 | ``` | | |
| 63 | brew install cmake llvm | | |
| 64 | brew outdated llvm || brew upgrade llvm | | |
| 65 | mkdir build | | |
| 66 | cd build | | |
| 67 | cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) | | |
| 68 | make install | | |
| 69 | ``` | | |
| 70 | | | |
| 71 | ##### Windows | | |
| 72 | | | |
| 73 | See https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows | | |
| 74 | | | |
| 75 | ### Stage 2: Build Self-Hosted Zig from Zig Source Code | | |
| 76 | | | |
| 77 | Now we use the stage1 binary: | | |
| 78 | | | |
| 79 | ``` | | |
| 80 | zig build --prefix $(pwd)/stage2 -Denable-llvm | | |
| 81 | ``` | | |
| 82 | | | |
| 83 | This produces `stage2/bin/zig` which can be used for testing and development. | | |
| 84 | Once it is feature complete, it will be used to build stage 3 - the final compiler | | |
| 85 | binary. | | |
| 86 | | | |
| 87 | ### Stage 3: Rebuild Self-Hosted Zig Using the Self-Hosted Compiler | | |
| 88 | | | |
| 89 | *Note: Stage 2 compiler is not yet able to build Stage 3. Building Stage 3 is | | |
| 90 | not yet supported.* | | |
| 91 | | | |
| 92 | Once the self-hosted compiler can build itself, this will be the actual | | |
| 93 | compiler binary that we will install to the system. Until then, users should | | |
| 94 | use stage 1. | | |
| 95 | | | |
| 96 | #### Debug / Development Build | | |
| 97 | | | |
| 98 | ``` | | |
| 99 | stage2/bin/zig build | | |
| 100 | ``` | | |
| 101 | | | |
| 102 | This produces `zig-cache/bin/zig`. | | |
| 103 | | | |
| 104 | #### Release / Install Build | | |
| 105 | | | |
| 106 | ``` | | |
| 107 | stage2/bin/zig build install -Drelease | | |
| 108 | ``` | | |
| 109 | | 23 | |
| 110 | ## License | 24 | ## License |
| 111 | | 25 | |