mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 16:45:07 +00:00
Update local clang+llvm build instructions
parent
36746ec679
commit
36b758bb4b
51
Build.md
51
Build.md
@ -79,47 +79,54 @@ If using Windows the automatically downloaded LLVM binaries are 64-bit; you shou
|
|||||||
|
|
||||||
## Link against clang+llvm libraries compiled from source
|
## Link against clang+llvm libraries compiled from source
|
||||||
|
|
||||||
MaskRay's config (building trunk LLVM at `~/Dev/llvm/release/`):
|
* `include/llvm/Config/config.h`
|
||||||
|
* `include/clang/Config/config.h`
|
||||||
|
* `lib/libclangIndex.so`
|
||||||
|
* `lib/libLLVM{Support,...}.so` or `lib/libLLVM{Support,...}.a` or `lib/libLLVM.so`
|
||||||
|
|
||||||
|
MaskRay's config (building trunk LLVM at `~/llvm/Release/`):
|
||||||
|
|
||||||
```
|
```
|
||||||
cd ~/Dev
|
cd
|
||||||
git clone https://git.llvm.org/git/llvm.git
|
git clone https://git.llvm.org/git/llvm.git
|
||||||
cd llvm/tools
|
cd llvm/tools
|
||||||
git clone https://git.llvm.org/git/clang.git
|
git clone https://git.llvm.org/git/clang.git
|
||||||
cd ~/Dev
|
cd ~/llvm
|
||||||
# create a build directory named `release/`
|
# create a build directory named `Release/`
|
||||||
cmake -H. -Brelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_SHARED_LIBS=ON -DLLVM_ENABLE_LLD=ON -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_GO_TESTS=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_USE_SPLIT_DWARF=On -DLLVM_OPTIMIZED_TABLEGEN=On
|
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_SHARED_LIBS=ON -DLLVM_ENABLE_LLD=ON -DLLVM_TARGETS_TO_BUILD=X86
|
||||||
|
ninja -C Release clangIndex clangTooling
|
||||||
```
|
```
|
||||||
|
|
||||||
Remove `LLVM_ENABLE_LLD` if don't have lld (a much faster linker than bfd/gold) installed
|
* Remove `LLVM_ENABLE_LLD` if you don't have lld (a much faster linker than bfd/gold) installed
|
||||||
Remove `BUILD_SHARED_LIBS` if you want to build static libraries (`libclangDriver.a` `libLLVMSupport.a`, note `libclang.so` is still a shared object)
|
* Remove `BUILD_SHARED_LIBS` if you want to build static libraries (`libclangIndex.a`) instead
|
||||||
|
|
||||||
Then build ccls:
|
Then build ccls with `-DSYSTEM_CLANG` and `-DCMAKE_PREFIX_PATH`:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
cmake -H. -Brelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DSYSTEM_CLANG=On -DCMAKE_PREFIX_PATH="$HOME/Dev/llvm/release;$HOME/Dev/llvm/release/tools/clang;$HOME/Dev/llvm;$HOME/Dev/llvm/tools/clang"
|
cd ~/ccls
|
||||||
cmake --build release
|
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DSYSTEM_CLANG=On -DCMAKE_PREFIX_PATH="$HOME/llvm/Release;$HOME/llvm/Release/tools/clang;$HOME/llvm;$HOME/llvm/tools/clang"
|
||||||
|
ninja -C Release
|
||||||
```
|
```
|
||||||
|
|
||||||
There are 4 directories specified in `CMAKE_PREFIX_PATH`:
|
`-DCMAKE_PREFIX_PATH=` is a `;`-separated list where you can find:
|
||||||
|
|
||||||
* `Dev/llvm`: llvm source
|
* `llvm`: llvm source
|
||||||
* `Dev/llvm/tools/clang`: clang source (`git clone https://git.llvm.org/git/clang.git`)
|
* `llvm/tools/clang`: clang source (`git clone https://git.llvm.org/git/clang.git`)
|
||||||
* `Dev/llvm/release`: build directory. `include/` contains some generated llvm header files
|
* `llvm/Release`: build directory. `include/` contains generated llvm header files, e.g. `include/llvm/Config/config.h`
|
||||||
* `Dev/llvm/release/tools/clang`: part of the build directory. `include/` contains some generated clang header files
|
* `llvm/Release/tools/clang`: build directory. `include/` contains generated clang header files, e.g. `include/clang/Config/config.h`
|
||||||
|
|
||||||
The cmake build system is expected to find these files:
|
The cmake build system is expected to find these files:
|
||||||
|
|
||||||
```
|
```
|
||||||
# generated clang+llvm header files
|
# generated clang+llvm header files
|
||||||
~/Dev/llvm/release/include/llvm/Config/config.h
|
~/llvm/Release/include/llvm/Config/config.h
|
||||||
~/Dev/llvm/release/tools/clang/include/clang/Config/config.h
|
~/llvm/Release/tools/clang/include/clang/Config/config.h
|
||||||
# libclang
|
# libclangIndex.so
|
||||||
~/Dev/llvm/release/lib/libclang.so
|
~/llvm/Release/lib/libclangIndex.so
|
||||||
# -resource-dir
|
# -resource-dir
|
||||||
~/Dev/llvm/release/lib/clang/7.0.0
|
~/llvm/release/lib/clang/7.0.0
|
||||||
# clang+llvm libraries
|
# clang+llvm libraries
|
||||||
~/Dev/llvm/release/lib/libclangDriver.so
|
~/llvm/release/lib/libclangDriver.so
|
||||||
~/Dev/llvm/release/lib/libLLVMSupport.so
|
~/llvm/release/lib/libLLVMSupport.so
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user