From 947ef898d00aae71a291bbac2c0dc6061f5d4f82 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 30 Sep 2017 14:36:55 -0400 Subject: [PATCH] streamline building zig on windows instructions --- Building-Zig-on-Windows-with-Visual-Studio.md | 110 ------------------ Building-Zig-on-Windows.md | 39 +++++++ 2 files changed, 39 insertions(+), 110 deletions(-) delete mode 100644 Building-Zig-on-Windows-with-Visual-Studio.md create mode 100644 Building-Zig-on-Windows.md diff --git a/Building-Zig-on-Windows-with-Visual-Studio.md b/Building-Zig-on-Windows-with-Visual-Studio.md deleted file mode 100644 index 649be3f..0000000 --- a/Building-Zig-on-Windows-with-Visual-Studio.md +++ /dev/null @@ -1,110 +0,0 @@ -Zig requires the llvm/clang development libraries (version 5.0). - -## Prebuilt Artifacts - -* [llvm+clang+lld-5.0.0-win32-msvc.tar.xz](https://s3.amazonaws.com/superjoe/temp/llvm%2bclang%2blld-5.0.0-win32-msvc.tar.xz) (679 MB) (sha256 40810195c943ec1e3a6e39c8f904bcc77ddb49edc67a079219faac78e39e9915) -* [llvm+clang+lld-5.0.0-win64-msvc.tar.xz](https://s3.amazonaws.com/superjoe/temp/llvm%2bclang%2blld-5.0.0-win64-msvc.tar.xz) (806 MB) (sha256 0f319a2857a8d871e1decd5ea6a3d1187d52ad47540a9db59d6185fd2159343f) (**use this one**) - - -Please consider [donating $1/month](https://www.patreon.com/andrewrk) if you use this link to help cover cost of hosting such a large file. - -If you use this then skip down to [Building Zig](#building-zig). - -## Building LLVM/CLANG - -Following these build instructions should be sufficient but you can also refer to LLVM's documentation here: https://llvm.org/docs/GettingStartedVS.html - -### Requirements - -* CMake (version >= 2.8.9) -* Microsoft Visual Studio 2015, Version 14.0. (download here https://imagine.microsoft.com/en-us/Catalog/Product/101). - Make sure you have the latest updates installed (Up to Update 3) and that you have the C/C++ compiler. -* Python 2.7.x - -### Get the llvm/clang source code. - -Option 1: Use Git -``` -git clone https://github.com/llvm-mirror/llvm -b release_50 -cd llvm/tools -git clone https://github.com/llvm-mirror/clang -b release_50 -``` - -Option 2: Download the sources - -### Configure the build - -Open a command prompt and configure the Visual Studio 2015 64-bit environment by running. -```dos -"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 -``` -> Note: right now zig only supports the 64-bit version of LLVM, but to configure the build with 32-bit you would use "x86" instead of "amd64". - -> Note: after you have setup the Visual Studio environment, make sure you can run `rc`. If not, then it means you've run into a bug with the Microsoft SDK where they have added the wrong path to the "Windows Kits" tools. You can solve this by adding the correct directory which should be similar to "C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64". When you locate the correct path on your system run `set "PATH=;%PATH%"`, then make sure you can run the `rc` command. - -`cd` into the llvm source code, then create a directory to build in: -```dos -cd -mkdir -cd -``` - -Inside this directory you can use cmake to generate build files. The default build files for visual studio are msbuild files. You can either configure/generate the build files using one command line, i.e. -```doc -cmake .. -DCMAKE_INSTALL_PREFIX= -``` -or you can run `cmake-gui ..` which allows you to see all the configuration options before generating the build files. The default options should work, however, you may want to use a custom CMAKE_INSTALL_PREFIX which is where llvm will install the final output files. - -> Note: problems have been seen with the Visual Studio generator, if this is the case you can use Ninja instead, just make sure ninja is in your path and add the "-G Ninja" options to your cmake command. - -When using cmake-gui, run "Configure" to get all the configuration options (make sure to select the "Visual Studio 14 2015 Win64 generator to build 64-bit). Keep re-running "Configure" until there are no new options (new options are highlighted in red). Then click "Generate" to generate the build. - -### Perform the Build/Install - -#### Option 1: Use cmake from the command line -Run the following from the build directory -```dos -:: perform the build -cmake --build . -:: perform the install -cmake --build . --target install -``` -This option should work no matter what generator you used. -#### Option 2: Use msbuild from the command line -Run the following from the build directory -```dos -:: perform the build -msbuild ALL_BUILD.vcxproj -:: perform the install -msbuild INSTALL.vcxproj -``` -#### Option 3: Use Visual Studio -* Open llvm.sln -* To Build, in the "Solution Explorer", right-click "ALL_BUILD" and click "Build". -* To Install, in the "Solution Explorer", right-click "INSTALL" and click "Build". - -## Building Zig - -### Get the source code. - -```dos -git clone https://github.com/zig-lang/zig -``` - -### Configure the build -Open a Visual Studio 2015 64-bit Command Prompt. Note that you can convert a normal command prompt to a Visual Studio 2015 command prompt by running -```dos -"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 -``` -`cd` into the zig repository, then create a directory to build in: -```dos -cd -mkdir -cd -``` - -Inside this directory you can use cmake to generate build files. Zig will need to be able to find where LLVM was installed. It uses the `find_package` command in cmake. If you'd like to configure via the command line you can specify the path like this: -```dos -cmake .. -DCMAKE_PREFIX_PATH= -``` -Or course you can also configure the build by running `cmake-gui ..` inside the build directory. After you run "Configure" you should get an error indicating that the "LLVM" package could not be found, fix this by clicking "Add Entry" and add the variable `CMAKE_PREFIX_PATH` and give it the value ``. Click "Configure" again and you should be ready to "Generate" the build files and start the build (see [Perform the Build/Install](#perform-the-buildinstall) above) \ No newline at end of file diff --git a/Building-Zig-on-Windows.md b/Building-Zig-on-Windows.md new file mode 100644 index 0000000..12b6281 --- /dev/null +++ b/Building-Zig-on-Windows.md @@ -0,0 +1,39 @@ +Here is llvm, clang, and LLD 5.0.0 x64 built with MSVC: + +* [llvm+clang+lld-5.0.0-win64-msvc.tar.xz](https://s3.amazonaws.com/superjoe/temp/llvm%2bclang%2blld-5.0.0-win64-msvc.tar.xz) (806 MB) (sha256 0f319a2857a8d871e1decd5ea6a3d1187d52ad47540a9db59d6185fd2159343f) + +Please [donate $1/month](https://www.patreon.com/andrewrk) to help cover cost of hosting such a large file. + +Unzip this file to a directory with no spaces, such as `C:\Users\Andy\`. It contains a single directory, so when you do this the full path will be e.g. `C:\Users\Andy\llvm+clang+lld-5.0.0-win64-msvc\`. + +Install [Visual Studio Community 2015 with Update 3](https://my.visualstudio.com/Downloads?q=visual%20studio%202015&wt.mc_id=o~msft~vscom~older-downloads). + +Install [CMake](http://cmake.org). + +Use [git](https://git-scm.com/) to clone the zig repository to a path with no spaces, e.g. `C:\Users\Andy\zig`. + +Run the CMake GUI. Click **Add Entry** and add these entries (these are examples - use the correct values): + + * `CMAKE_PREFIX_PATH` type `PATH` value `C:\Users\Andy\llvm+clang+lld-5.0.0-win64-msvc`. + * `CMAKE_INSTALL_PREFIX` type `PATH` value `C:\Users\Andy\zig\build`. (this is where you cloned zig to, plus `\build`) + +Click **Configure** and use these options: + + * Specify the generator for this project: `Visual Studio 14 2015 Win64` + * Optional toolset to use: `host=x64` + * `Use the default native compilers` + +Click **Generate**. + +Using the start menu, run **VS2015 x64 Native Tools Command Prompt** and execute these commands: + +``` +cd C:\Users\Andy\zig\build +msbuild INSTALL.vcxproj +``` + +You now have the `zig.exe` binary at `bin\zig.exe` and you should run the tests to make sure they pass: + +``` +bin\zig.exe build --build-file ..\build.zig test +``` \ No newline at end of file