llvm monorepo & releases/prereleases

Fangrui Song 2019-09-04 18:49:16 -07:00
parent 0f82f92cb5
commit e35c56947f

@ -237,11 +237,10 @@ these releases. You must either:
#### Build clang+llvm by yourself #### Build clang+llvm by yourself
```sh ```sh
git clone https://git.llvm.org/git/llvm.git git clone https://github.com/llvm/llvm-project.git
git clone https://git.llvm.org/git/clang.git llvm/tools/clang cd llvm-project
cd llvm cmake -Hllvm -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DLLVM_TARGETS_TO_BUILD=X86
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 ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang
# Download ccls # Download ccls
@ -262,26 +261,27 @@ ninja -C Release
`-D__STDC_FORMAT_MACROS` is because otherwise `mingw-w64-headers/crt/inttypes.h` does not define `PRIu64`. `-D__STDC_FORMAT_MACROS` is because otherwise `mingw-w64-headers/crt/inttypes.h` does not define `PRIu64`.
## Compiling Clang+LLVM from source ## Build Clang+LLVM from the git monorepo
MaskRay's config (building trunk LLVM at `~/llvm/Release/`):
```sh ```sh
git clone https://git.llvm.org/git/llvm.git git clone https://github.com/llvm/llvm-project.git
git clone https://git.llvm.org/git/clang.git llvm/tools/clang cd llvm-project
cd llvm
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_ENABLE_LLD=ON -DLLVM_TARGETS_TO_BUILD=X86 cmake -Hllvm -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86
ninja -C Release clang clangFormat clangFrontendTool clangIndex clangTooling cxx ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang
# built Release/bin/clang
``` ```
* Remove `LLVM_ENABLE_LLD` if you don't have lld (a much faster linker than bfd/gold) installed * `LLVM_TARGETS_TO_BUILD` defaults to `ALL`. We just use the frontend, don't generate code, so `X86` should be sufficient. `clang -target powerpc64le-linux -fsyntax-only` still works.
* Remove `BUILD_SHARED_LIBS` if you want to build static libraries (`libclangIndex.a`) instead * Add `-DLLVM_ENABLE_LLD=on` if you have lld (a much faster linker than bfd/gold) installed
* Add `-DBUILD_SHARED_LIBS=on` if you want to build shared libraries (`libclangIndex.so`)
Then build ccls with `-DCMAKE_PREFIX_PATH`: Then build ccls with `-DCMAKE_PREFIX_PATH`:
```sh ```sh
cd ~/ccls cd ~/ccls
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_PREFIX_PATH="$HOME/llvm/Release;$HOME/llvm/Release/tools/clang;$HOME/llvm;$HOME/llvm/tools/clang" LLVM=$HOME/llvm-project
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_PREFIX_PATH="$LLVM/Release;$LLVM/llvm;$LLVM/clang"
ninja -C Release ninja -C Release
``` ```
@ -307,3 +307,16 @@ The cmake build system is expected to find these files:
~/llvm/Release/lib/libLLVMSupport.so or libLLVMSupport.a ~/llvm/Release/lib/libLLVMSupport.so or libLLVMSupport.a
... ...
``` ```
## Build Clang+LLVM from releases.llvm.org or prereleases.llvm.org
Similar to the instructions to build Clang+LLVM from the git monorepo:
```sh
# Download "LLVM source code" and rename the extracted directory to llvm
# Download "Clang source code" and rename the extracted directory to llvm/tools/clang
cd llvm
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86
ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling clang
# built Release/bin/clang
```