mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 09:05:10 +00:00
Delete LLVM_ENABLE_RTTI and USE_SHARED_LLVM; they are unnecessary since https://github.com/MaskRay/ccls/pull/313
parent
72acf4dcc5
commit
fbd115776a
88
Build.md
88
Build.md
@ -68,14 +68,6 @@ for your system, as well as methods of obtaining and locating Clang+LLVM.
|
|||||||
|
|
||||||
Set the install location. See [[Install]] for more details.
|
Set the install location. See [[Install]] for more details.
|
||||||
|
|
||||||
* `-DUSE_SHARED_LLVM=(ON|OFF)`
|
|
||||||
|
|
||||||
Default: **OFF**
|
|
||||||
|
|
||||||
Link against `libLLVM.so` instead of static LLVM libraries. This makes
|
|
||||||
linking faster and the executable significantly smaller but the **ccls**
|
|
||||||
binary will need access to `libLLVM.so` at runtime as well as link-time.
|
|
||||||
|
|
||||||
* `-DCLANG_USE_BUNDLED_LIBC++=(ON|OFF)`
|
* `-DCLANG_USE_BUNDLED_LIBC++=(ON|OFF)`
|
||||||
|
|
||||||
Default: **OFF**
|
Default: **OFF**
|
||||||
@ -85,55 +77,45 @@ for your system, as well as methods of obtaining and locating Clang+LLVM.
|
|||||||
Linux due to conflict of libstdc++ (linked by clang+llvm libraries) and
|
Linux due to conflict of libstdc++ (linked by clang+llvm libraries) and
|
||||||
libc++.
|
libc++.
|
||||||
|
|
||||||
* `-DLLVM_ENABLE_RTTI=(ON|OFF)`
|
* `-DCMAKE_PREFIX_PATH=<path>`
|
||||||
|
|
||||||
Default: **OFF**
|
Specify paths where CMake can locate Clang/LLVM headers and libraries.
|
||||||
|
CMake searches the paths in `CMAKE_PREFIX_PATH` for `include` and `lib`.
|
||||||
Some system-supplied versions of `libLLVM` enable RTTI in which case
|
|
||||||
**ccls** must as well: use `-DLLVM_ENABLE_RTTI=ON`. See the system-specific
|
|
||||||
sections below.
|
|
||||||
|
|
||||||
## Choosing Clang+LLVM
|
## Choosing Clang+LLVM
|
||||||
|
|
||||||
* `-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.
|
|
||||||
|
|
||||||
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
|
### System Clang+LLVM
|
||||||
|
|
||||||
If they are installed into the standard locations for our system, CMake will locate them.
|
If your system Clang+LLVM is sufficiently new, consider using them. If they
|
||||||
|
are installed into the standard locations for our system, `CMAKE_PREFIX_PATH`
|
||||||
|
is not required.
|
||||||
|
|
||||||
On Debian and its derivatives, you may install `libclang-*-dev` and `llvm-*-dev`.
|
A simple `cmake -GNinja -H. -BRelease` (remove `-GNinja` if you don't use
|
||||||
|
Ninja) works for at least the following distributions:
|
||||||
|
|
||||||
You may add multiple directories for `include` and `lib` separated by a `;`.
|
* Arch Linux
|
||||||
|
* Fedora Linux
|
||||||
|
* Gentoo Linux
|
||||||
|
* Void Linux
|
||||||
|
|
||||||
### Prebuilt binaries
|
### Prebuilt Clang+LLVM binaries
|
||||||
|
|
||||||
Pick the one on https://releases.llvm.org/download.html that suits your system.
|
Pick the one on https://releases.llvm.org/download.html that suits your system.
|
||||||
Note, the Ubuntu 16.04 prebuit binaries are actually suitable for many non-Ubuntu distributions.
|
Note, the Ubuntu 16.04 prebuit binaries are actually suitable for many non-Ubuntu distributions.
|
||||||
|
|
||||||
After unpacking, `-DCMAKE_PREFIX_PATH=/path/to/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04`
|
After unpacking, `cmake -GNinja -H. -BRelease -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.
|
The Windows prebuilt binaries lack C++ header files, thus they cannot be used.
|
||||||
|
|
||||||
## GNU/Linux
|
## System specific notes
|
||||||
|
|
||||||
* On GNU/Linux distributions with older versions of glibc (older than
|
On GNU/Linux distributions with older versions of glibc (older than
|
||||||
2013-04-25), such as Red Hat EL 6.x, append `-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
|
### Arch Linux
|
||||||
|
|
||||||
Arch User Repository: [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: `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}`.
|
`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
|
`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
|
||||||
|
|
||||||
@ -141,13 +123,9 @@ To build **ccls** on Arch Linux with system clang+llvm: `cmake -H. -BRelease -DU
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
apt install clang-7 libclang-7-dev
|
apt install clang-7 libclang-7-dev
|
||||||
cmake -H. -BRelease -DCMAKE_PREFIX_PATH=/usr/lib/llvm-7 -DLLVM_ENABLE_RTTI=on
|
cmake -H. -BRelease -DCMAKE_PREFIX_PATH=/usr/lib/llvm-7
|
||||||
```
|
```
|
||||||
|
|
||||||
### Gentoo Linux
|
|
||||||
|
|
||||||
To build **ccls** on Gentoo Linux with system Clang+LLVM: `cmake -H. -BRelease -DLLVM_ENABLE_RTTI=on`
|
|
||||||
|
|
||||||
### Ubuntu
|
### Ubuntu
|
||||||
|
|
||||||
To build from source you'll need `sudo apt install zlib1g-dev libncurses-dev`
|
To build from source you'll need `sudo apt install zlib1g-dev libncurses-dev`
|
||||||
@ -160,28 +138,19 @@ To build with system Clang+LLVM: `sudo apt install clang libclang-dev`
|
|||||||
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release \
|
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release \
|
||||||
-DCMAKE_PREFIX_PATH=/usr/lib/llvm-7 \
|
-DCMAKE_PREFIX_PATH=/usr/lib/llvm-7 \
|
||||||
-DLLVM_INCLUDE_DIR=/usr/lib/llvm-7/include \
|
-DLLVM_INCLUDE_DIR=/usr/lib/llvm-7/include \
|
||||||
-DLLVM_BUILD_INCLUDE_DIR=/usr/include/llvm-7/ \
|
-DLLVM_BUILD_INCLUDE_DIR=/usr/include/llvm-7/
|
||||||
-DLLVM_ENABLE_RTTI=on
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Notice that `LLVM_INCLUDE_DIR` points to /usr/lib, and `LLVM_BUILD_INCLUDE` points to /usr/include.
|
Notice that `LLVM_INCLUDE_DIR` points to /usr/lib, and `LLVM_BUILD_INCLUDE` points to /usr/include.
|
||||||
|
|
||||||
Build as normal. You'll have a ccls library that will be compiled against the sytem-installed LLVM, and use the system clang resource directory as well.
|
Build as normal. You'll have a ccls library that will be compiled against the sytem-installed LLVM, and use the system clang resource directory as well.
|
||||||
|
|
||||||
### Void Linux
|
|
||||||
|
|
||||||
To build **ccls** on Void Linux with system Clang+LLVM: `cmake -H. -BRelease -DLLVM_ENABLE_RTTI=on`
|
|
||||||
|
|
||||||
### Red Hat / CentOS
|
### Red Hat / CentOS
|
||||||
|
|
||||||
Older versions (6.x) use an older GNU libc which requires
|
Older versions (6.x) use an older GNU libc which requires
|
||||||
`-DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS`
|
`-DCMAKE_CXX_FLAGS=-D__STDC_FORMAT_MACROS`
|
||||||
|
|
||||||
### Fedora
|
### MacOS
|
||||||
|
|
||||||
(Tested on Fedora 29) To build **ccls** on Fedora with system Clang+LLVM: `cmake -H. -BRelease -DUSE_SHARED_LLVM=on -DLLVM_ENABLE_RTTI=on`
|
|
||||||
|
|
||||||
## MacOS
|
|
||||||
|
|
||||||
To install **ccls** with Homebrew use https://github.com/twlz0ne/homebrew-ccls
|
To install **ccls** with Homebrew use https://github.com/twlz0ne/homebrew-ccls
|
||||||
|
|
||||||
@ -191,8 +160,7 @@ of Xcode with a sufficiently-new Clang.
|
|||||||
To build using MacPorts Clang add CMake flags
|
To build using MacPorts Clang add CMake flags
|
||||||
```sh
|
```sh
|
||||||
-DCMAKE_CXX_COMPILER=clang++-mp-6.0
|
-DCMAKE_CXX_COMPILER=clang++-mp-6.0
|
||||||
-DCMAKE_PREFIX_PATH=/opt/local/libexec/llvm-6.0 -DLLVM_ENABLE_RTTI=on
|
-DCMAKE_PREFIX_PATH=/opt/local/libexec/llvm-6.0
|
||||||
-DUSE_SHARED_LLVM=on`
|
|
||||||
```
|
```
|
||||||
|
|
||||||
With clang < 8, to make header completion work, use a [shell script wrapper](Install#shell-script-wrapper):
|
With clang < 8, to make header completion work, use a [shell script wrapper](Install#shell-script-wrapper):
|
||||||
@ -203,14 +171,14 @@ exec /path/to/ccls/Release/ccls -init='{"clang":{"extraArgs":["-isystem", "/Libr
|
|||||||
|
|
||||||
See https://github.com/MaskRay/ccls/issues/191#issuecomment-453809905 for details.
|
See https://github.com/MaskRay/ccls/issues/191#issuecomment-453809905 for details.
|
||||||
|
|
||||||
## FreeBSD
|
### FreeBSD
|
||||||
|
|
||||||
* [devel/ccls](https://www.freshports.org/devel/ccls)
|
* [devel/ccls](https://www.freshports.org/devel/ccls)
|
||||||
* With `devel/llvm70` add CMake flags `-DUSE_SHARED_LLVM=on -DCMAKE_PREFIX_PATH=/usr/local/llvm70`
|
* With `devel/llvm70` add CMake flags `-DCMAKE_PREFIX_PATH=/usr/local/llvm70`
|
||||||
* To use the releases.llvm.org prebuilt archive and its libc++ add CMake flag
|
* To use the releases.llvm.org prebuilt archive and its libc++ add CMake flag
|
||||||
`-DCLANG_USE_BUNDLED_LIBC++=on`
|
`-DCLANG_USE_BUNDLED_LIBC++=on`
|
||||||
|
|
||||||
## GuixSD (0.16)
|
### GuixSD (0.16)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
guix package -i cmake clang gcc-toolchain
|
guix package -i cmake clang gcc-toolchain
|
||||||
@ -218,7 +186,7 @@ cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/home/$USER/.
|
|||||||
cmake --build Release
|
cmake --build Release
|
||||||
```
|
```
|
||||||
|
|
||||||
## Windows
|
### Windows
|
||||||
|
|
||||||
The Windows archive on releases.llvm.org does not contain library headers.
|
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
|
Since **ccls** uses Clang C++ APIs, it is not possible to build **ccls** with
|
||||||
@ -227,7 +195,7 @@ these releases. You must either:
|
|||||||
1. Build clang+llvm by yourself
|
1. Build clang+llvm by yourself
|
||||||
2. Get prebuilt LLVM+Clang from other sources, e.g. MSYS2.
|
2. Get prebuilt LLVM+Clang from other sources, e.g. MSYS2.
|
||||||
|
|
||||||
### Build clang+llvm by yourself
|
#### Build clang+llvm by yourself
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://git.llvm.org/git/llvm.git
|
git clone https://git.llvm.org/git/llvm.git
|
||||||
@ -243,7 +211,7 @@ cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=cla
|
|||||||
ninja -C Release
|
ninja -C Release
|
||||||
```
|
```
|
||||||
|
|
||||||
### MSYS2
|
#### MSYS2
|
||||||
|
|
||||||
For 2, one possible way is use MSYS2, in MSYS2 MinGW 64-bit shell:
|
For 2, one possible way is use MSYS2, in MSYS2 MinGW 64-bit shell:
|
||||||
|
|
||||||
@ -255,7 +223,7 @@ 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`.
|
||||||
|
|
||||||
## Notes on compiling Clang+LLVM from source
|
## Compiling Clang+LLVM from source
|
||||||
|
|
||||||
MaskRay's config (building trunk LLVM at `~/llvm/Release/`):
|
MaskRay's config (building trunk LLVM at `~/llvm/Release/`):
|
||||||
|
|
||||||
|
27
Install.md
27
Install.md
@ -28,30 +28,27 @@ cmake --build Release --target install
|
|||||||
# cmake --build . --config Release --target install
|
# cmake --build . --config Release --target install
|
||||||
```
|
```
|
||||||
|
|
||||||
This will install **ccls** as `<prefix>/bin/ccls` (and also install the LLVM
|
This will install **ccls** as `<prefix>/bin/ccls`. If you have `<prefix>/bin` on your `PATH` then **ccls** should be found.
|
||||||
shared libraries if `-DUSE_SHARED_LLVM=ON`).
|
|
||||||
|
|
||||||
If you have `<prefix>/bin` on your `PATH` then **ccls** should be found.
|
|
||||||
|
|
||||||
## Clang resource directory
|
## Clang resource directory
|
||||||
|
|
||||||
Some header files such as `stddef.h stdint.h` are located in the `include/`
|
Some header files such as `stddef.h stdint.h` are located in the `include/`
|
||||||
subdirectory of Clang resource directory.
|
subdirectory of Clang resource directory. The path is derived from `clang
|
||||||
|
-print-resource-dir` at CMake configure time.
|
||||||
|
|
||||||
The location of Clang resource directory is hard-coded in the `ccls` executable
|
The location is hard-coded in the `ccls` executable
|
||||||
(`-DDEFAULT_RESOURCE_DIRECTORY=` when building ccls). The absence of Clang
|
(`-DDEFAULT_RESOURCE_DIRECTORY=` when building ccls). If you want to install
|
||||||
resource directory may lead to errors like `unknown type name 'size_t'` and
|
|
||||||
incomplete index results.
|
|
||||||
|
|
||||||
If you downloaded Clang+LLVM as part of the build and you want to install
|
|
||||||
**ccls** and delete the build directory, you need to copy the contents of the
|
**ccls** and delete the build directory, you need to copy the contents of the
|
||||||
resource directory; for example something like:
|
resource directory before building ccls.
|
||||||
|
|
||||||
|
Otherwise the absence of Clang resource directory may lead to errors like
|
||||||
|
`unknown type name 'size_t'`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo mkdir -p /usr/local/clang/7.0.0
|
sudo mkdir -p /usr/local/clang/7.0.0
|
||||||
sudo cp -a Release/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/lib/clang/7.0.0/include /usr/local/clang/7.0.0/
|
sudo cp -a Release/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/lib/clang/7.0.0/include /usr/local/clang/7.0.0/
|
||||||
```
|
```
|
||||||
|
|
||||||
Then you must configure `ccls` to locate this directory by adding an option
|
Then you must set the initialization option
|
||||||
such as `--init='{"clang": {"resourceDir": "/usr/local/clang/7.0.0"}}'` (see
|
[`clang.resourceDir`](Customization#clangresourcedir): `--init='{"clang":
|
||||||
[`clang.resourceDir`](Customization#clangresourcedir) for more information).
|
{"resourceDir": "/usr/local/clang/7.0.0"}}'`.
|
||||||
|
Loading…
Reference in New Issue
Block a user