mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Delete SYSTEM_CLANG after #221
parent
1233fddf9d
commit
c02a58c799
91
Build.md
91
Build.md
@ -3,20 +3,33 @@ system-specific sections below if you'd like to investigate that.
|
||||
|
||||
Otherwise, you'll need to build **ccls** from source. You will need:
|
||||
|
||||
* The source code for **ccls**.
|
||||
* [CMake](https://cmake.org/) 3.8 or higher.
|
||||
* A C++ compiler with C++17 support:
|
||||
* Clang 5 or higher.
|
||||
* GCC 7.2 or higher (`optional,string_view` require libstdc++7 or higher)
|
||||
* MSVC 2017 or higher (included with VS2017 Build Tools)
|
||||
* On POSIX systems, either GNU make or Ninja (optional on other systems)
|
||||
* Clang+LLVM headers and libraries
|
||||
|
||||
The simplest/quickest build with all defaults (only for POSIX systems) is:
|
||||
|
||||
```sh
|
||||
git clone --depth=1 --recursive https://github.com/MaskRay/ccls
|
||||
cd ccls
|
||||
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
# Download "Pre-Built Binaries" from https://releases.llvm.org/downloads.html
|
||||
# and unpack to /path/to/clang+llvm-xxx
|
||||
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/path/to/clang+llvm-xxx
|
||||
cmake --build Release
|
||||
```
|
||||
|
||||
The Ubuntu 16.04 prebuit binaries are actually suitable for many non-Ubuntu distributions.
|
||||
You may relace the last two cmake commands with:
|
||||
|
||||
```sh
|
||||
wget -c http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz
|
||||
tar xf clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz
|
||||
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PWD/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04
|
||||
cmake --build Release
|
||||
```
|
||||
|
||||
@ -82,65 +95,51 @@ for your system, as well as methods of obtaining and locating Clang+LLVM.
|
||||
|
||||
## Choosing Clang+LLVM
|
||||
|
||||
**ccls** requires LLVM and Clang. There are many ways they can be obtained.
|
||||
|
||||
* `-DSYSTEM_CLANG=(ON|OFF)`
|
||||
|
||||
Default: **OFF**
|
||||
|
||||
The default behavior of CMake is to download a pre-built binary of Clang.
|
||||
If you prefer a different approach add `-DSYSTEM_CLANG=ON` and choose a
|
||||
method below.
|
||||
|
||||
### System Clang+LLVM
|
||||
|
||||
If you want to link against a version of Clang+LLVM already installed on your
|
||||
system you will need to install `libclang-*-dev` and `llvm-*-dev` packages (or
|
||||
equivalent) in order to have the correct libraries. If they are installed
|
||||
into the standard locations for our system, CMake will locate them.
|
||||
|
||||
Use `-DSYSTEM_CLANG=ON`.
|
||||
|
||||
* `-DCMAKE_PREFIX_PATH=<path>`
|
||||
|
||||
CMake searches the paths in `CMAKE_PREFIX_PATH` for `include` and `lib`
|
||||
subdirectories containing the required Clang headers and libraries, e.g.
|
||||
|
||||
`-DSYSTEM_CLANG=ON -DCMAKE_PREFIX_PATH=/usr/local/llvm70`
|
||||
If you want to link against a version of Clang+LLVM already installed on your
|
||||
system you will need to install packages (or equivalent) in order to have the
|
||||
correct libraries. e.g. `-DCMAKE_PREFIX_PATH=/usr/local/llvm70`
|
||||
|
||||
**ccls** requires LLVM and Clang. There are many ways they can be obtained.
|
||||
|
||||
### System Clang+LLVM
|
||||
|
||||
If they are installed into the standard locations for our system, CMake will locate them.
|
||||
|
||||
On Debian and its derivatives, you may install `libclang-*-dev` and `llvm-*-dev`.
|
||||
|
||||
You may add multiple directories for `include` and `lib` separated by a `;`.
|
||||
|
||||
### Alternate Clang+LLVM
|
||||
### Prebuilt binaries
|
||||
|
||||
If you wish to download and unpack Clang yourself rather than having CMake do
|
||||
it for you, or if you want to build Clang+LLVM from source, or if CMake can't
|
||||
find your installation of Clang+LLVM for any other reason, set the
|
||||
`CMAKE_PREFIX_PATH` CMake variable to point to the correct location:
|
||||
Pick the one on https://releases.llvm.org/downloads.html that suits your system.
|
||||
Note, the Ubuntu 16.04 prebuit binaries are actually suitable for many non-Ubuntu distributions.
|
||||
|
||||
Similar as System Clang+LLVM, `-DSYSTEM_CLANG=ON -DCMAKE_PREFIX_PATH=clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04`
|
||||
After unpacking, `-DCMAKE_PREFIX_PATH=/path/to/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04`
|
||||
|
||||
The Windows prebuilt binaries lack C++ header files, thus they cannot be used.
|
||||
|
||||
## GNU/Linux
|
||||
|
||||
* On GNU/Linux distributions with older versions of glibc (older than
|
||||
2013-04-25), such as Red Hat EL 6.x, you may need to add the `-D__STDC_FORMAT_MACROS` option to `CMAKE_CXX_FLAGS`:
|
||||
|
||||
`-DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS`
|
||||
2013-04-25), such as Red Hat EL 6.x, append `-DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS`
|
||||
|
||||
### Arch Linux
|
||||
|
||||
To install pre-built **ccls**, use
|
||||
[aur/ccls-git](https://aur.archlinux.org/packages/ccls-git).
|
||||
Arch User Repository: [aur/ccls-git](https://aur.archlinux.org/packages/ccls-git).
|
||||
|
||||
To build **ccls** on Arch Linux with system Clang+LLVM, you will need to add
|
||||
`-DLLVM_ENABLE_RTTI=on -DUSE_SHARED_LLVM=on`.
|
||||
To build **ccls** on Arch Linux with system clang+llvm: `cmake -H. -BRelease -DUSE_SHARED_LLVM=on -DLLVM_ENABLE_RTTI=on`
|
||||
|
||||
`extra/clang` and `extra/llvm` provide `/usr/lib/{libclangAST.so,libLLVM*.a,libLLVM.so}`.
|
||||
`libclangAST.so` needs `libLLVM.so` and there would be a conflict if `libLLVM*.a` (instead of `libLLVM.so`) are linked. See https://bugs.archlinux.org/task/60512
|
||||
|
||||
### Gentoo Linux
|
||||
|
||||
To build **ccls** on Gentoo Linux with system Clang+LLVM, you will need to add
|
||||
`-DLLVM_ENABLE_RTTI=on`.
|
||||
To build **ccls** on Gentoo Linux with system Clang+LLVM: `cmake -H. -BRelease -DLLVM_ENABLE_RTTI=on`
|
||||
|
||||
### Debian / Ubuntu
|
||||
|
||||
@ -150,8 +149,7 @@ On Ubuntu 16.04 install g++-7 via [these directions](https://gist.github.com/jlb
|
||||
|
||||
### Void Linux
|
||||
|
||||
To build **ccls** on Void Linux with system Clang+LLVM, you will need to add
|
||||
`-DLLVM_ENABLE_RTTI=on`.
|
||||
To build **ccls** on Void Linux with system Clang+LLVM: `cmake -H. -BRelease -DLLVM_ENABLE_RTTI=on`
|
||||
|
||||
### Red Hat / CentOS
|
||||
|
||||
@ -165,10 +163,12 @@ To install **ccls** with Homebrew use https://github.com/twlz0ne/homebrew-ccls
|
||||
To build from source you need MacOS 10.12 (Sierra) or higher to get a version
|
||||
of Xcode with a sufficiently-new Clang.
|
||||
|
||||
To build using MacPorts Clang add CMake flags `-DSYSTEM_CLANG=on
|
||||
To build using MacPorts Clang add CMake flags
|
||||
```sh
|
||||
-DCMAKE_CXX_COMPILER=clang++-mp-6.0
|
||||
-DCMAKE_PREFIX_PATH=/opt/local/libexec/llvm-6.0 -DLLVM_ENABLE_RTTI=on
|
||||
-DUSE_SHARED_LLVM=on`
|
||||
```
|
||||
|
||||
With clang < 8, to make header completion work, use a [shell script wrapper](Install#shell-script-wrapper):
|
||||
```sh
|
||||
@ -181,8 +181,7 @@ See https://github.com/MaskRay/ccls/issues/191#issuecomment-453809905 for detail
|
||||
## FreeBSD
|
||||
|
||||
* [devel/ccls](https://www.freshports.org/devel/ccls)
|
||||
* With `devel/llvm70` add CMake flags `-DSYSTEM_CLANG=on
|
||||
-DUSE_SHARED_LLVM=on -DCMAKE_PREFIX_PATH=/usr/local/llvm70`
|
||||
* With `devel/llvm70` add CMake flags `-DUSE_SHARED_LLVM=on -DCMAKE_PREFIX_PATH=/usr/local/llvm70`
|
||||
* To use the releases.llvm.org prebuilt archive and its libc++ add CMake flag
|
||||
`-DCLANG_USE_BUNDLED_LIBC++=on`
|
||||
|
||||
@ -207,7 +206,7 @@ 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"
|
||||
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_PREFIX_PATH="D:/llvm/Release;D:/llvm/Release/tools/clang;D:/llvm;D:/llvm/tools/clang"
|
||||
ninja -C Release
|
||||
```
|
||||
|
||||
@ -217,7 +216,7 @@ 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
|
||||
cmake -H. -BRelease -G Ninja -DSYSTEM_CLANG=ON -DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS
|
||||
cmake -H. -BRelease -G Ninja -DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS
|
||||
ninja -C Release
|
||||
```
|
||||
|
||||
@ -245,11 +244,11 @@ ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling
|
||||
* 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 (`libclangIndex.a`) instead
|
||||
|
||||
Then build ccls with `-DSYSTEM_CLANG` and `-DCMAKE_PREFIX_PATH`:
|
||||
Then build ccls with `-DCMAKE_PREFIX_PATH`:
|
||||
|
||||
```sh
|
||||
cd ~/ccls
|
||||
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"
|
||||
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"
|
||||
ninja -C Release
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user