Build: update Windows

Fangrui Song 2019-01-15 20:46:14 +08:00
parent e70a9478cb
commit 8a532fd7ba

@ -187,22 +187,35 @@ The Windows archive on releases.llvm.org does not contain library headers.
Since **ccls** uses Clang C++ APIs, it is not possible to build **ccls** with
these releases. You must either:
1. Build LLVM+Clang by yourself with your favorite toolchain.
2. Get prebuilt LLVM+Clang from other sources.
1. Build clang+llvm by yourself
2. Get prebuilt LLVM+Clang from other sources, e.g. MSYS2.
### Build clang+llvm by yourself
```sh
git clone https://git.llvm.org/git/llvm.git
git clone https://git.llvm.org/git/clang.git llvm/tools/clang
cd llvm
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DLLVM_TARGETS_TO_BUILD=X86
ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang
# Download ccls
cd ccls
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-cl -DSYSTEM_CLANG=On -DCMAKE_PREFIX_PATH="D:/llvm/Release;D:/llvm/Release/tools/clang;D:/llvm;D:/llvm/tools/clang"
ninja -C Release
```
### MSYS2
For 2, one possible way is use MSYS2, in MSYS2 MinGW 64-bit shell:
```
pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-cmake mingw-w64-x86_64-jq mingw-w64-x86_64-ninja mingw-w64-x86_64-ncurses
mkdir build
cd build
cmake .. -G Ninja -DSYSTEM_CLANG=ON -DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS
cmake --build .
cmake -H. -BRelease -G Ninja -DSYSTEM_CLANG=ON -DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS
ninja -C Release
```
Building ccls with MSVC 2017 and locally built LLVM+Clang on Windows does not
work right now, contributions welcome.
`-D__STDC_FORMAT_MACROS` is because otherwise `mingw-w64-headers/crt/inttypes.h` does not define `PRIu64`.
## Notes on compiling Clang+LLVM from source