Update wiki and import some contents from cquery.wiki

Fangrui Song 2018-04-07 10:34:55 -07:00
parent eeca4952f3
commit e7f72d966b
4 changed files with 39 additions and 23 deletions

@ -48,14 +48,10 @@ ccls. Debug is recommended when debugging cquery with a debugger. Since cquery
defaults to a Release build it usually isn't necessary to define this option defaults to a Release build it usually isn't necessary to define this option
unless you're debugging an issue in ccls with a debugger. unless you're debugging an issue in ccls with a debugger.
* `-DSYSTEM_CLANG=(ON|OFF)` * `-DSYSTEM_LIBCLANG=(ON|OFF)`
Enable `SYSTEM_CLANG` if you want to use your own system installation of Clang Enable `SYSTEM_LIBCLANG` if you want to link ccls against a system installation
instead of downloading Clang during the configure process. This requires you to of libclang instead of downloading libclang during the configure process.
have a recent installation of Clang/LLVM installed on your system. Note that
using system Clang is not recommended and there is a higher chance of bugs due
to possible version differences between downloaded Clang and system installed
Clang.
* `-DCMAKE_PREFIX_PATH="custom_install_path"` * `-DCMAKE_PREFIX_PATH="custom_install_path"`
@ -67,15 +63,18 @@ subdirectories containing the required Clang headers and libraries. For example,
to use a system installation of Clang on Windows you can add the following to use a system installation of Clang on Windows you can add the following
option: `-DCMAKE_PREFIX_PATH="C:/Program Files/LLVM"`. option: `-DCMAKE_PREFIX_PATH="C:/Program Files/LLVM"`.
If the 'include' and 'lib' directories reside in two different parent You may add directories for `include` and `lib` separated by a `;`, e.g. to use trunk clang:
directories (possible when building LLVM from source) you will have to add both `-DCMAKE_PREFIX_PATH="$HOME/Dev/llvm/release;$HOME/Dev/llvm/tools/clang"`
these directories to CMAKE_PREFIX_PATH separated by a ';'
(`-DCMAKE\_PREFIX\_PATH="<include-parent-dir>;<lib-parent-dir>"`). # Windows
If using Windows the automatically downloaded LLVM binaries are 64-bit; you should build cquery in 64-bit as well. You can tell cmake to build 64-bit using `-DCMAKE_GENERATOR_PLATFORM=x64`
My personal config: MaskRay's config:
```zsh ```zsh
CXX=clang++ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_LINKER=/usr/bin/ld.lld -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DSYSTEM_CLANG=On -DCMAKE_PREFIX_PATH="$HOME/Dev/llvm/static-release;$HOME/Dev/llvm/tools/clang" -Brelease -H. cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_LINKER=ld.lld -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DSYSTEM_LIBCLANG=On -DCMAKE_PREFIX_PATH="$HOME/Dev/llvm/static-release;$HOME/Dev/llvm/tools/clang" -Brelease -H.
cmake --build release
``` ```
``` ```
@ -87,4 +86,4 @@ CXX=clang++ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_LINKER=/usr/bin/ld
├── libclang.so -> libclang.so.7 ├── libclang.so -> libclang.so.7
├── libclang.so.7 -> libclang.so.7.0 ├── libclang.so.7 -> libclang.so.7.0
└── libclang.so.7.0 └── libclang.so.7.0
``` ```

24
FAQ.md

@ -38,13 +38,13 @@ system C/C++ headers can be detected reliably. For Clang resource directory, the
`build/debug/lib/clang+llvm-5.0.1-x86_64-linux-gnu-ubuntu-14.04/bin/c-index-test -index-file local /tmp/c/a.cc -isystem/usr/include/c++/7.3.0 -isystemyour_include_path2` `build/debug/lib/clang+llvm-5.0.1-x86_64-linux-gnu-ubuntu-14.04/bin/c-index-test -index-file local /tmp/c/a.cc -isystem/usr/include/c++/7.3.0 -isystemyour_include_path2`
Play with your `-isystem` options until you get a group of options that you can add to [`.ccls`](https://github.com/ccls-project/cquery/wiki/Getting-started#cquery) Play with your `-isystem` options until you get a group of options that you can add to [`.ccls`](https://github.com/MaskRay/cquery/wiki/Getting-started#cquery)
If you want the ccls binary at a specific location use a symlink - do not move the binary itself. If you want the ccls binary at a specific location use a symlink - do not move the binary itself.
### Project root detection ### Project root detection
For C++ projects, `compile_commands.json` is used by [emacs-ccls](https://github.com/ccls-project/emacs-cquery/) to mark the project root. This is usually a symlink to the real `compile_commands.json` in a build directory: For C++ projects, `compile_commands.json` is used by [emacs-ccls](https://github.com/MaskRay/emacs-cquery/) to mark the project root. This is usually a symlink to the real `compile_commands.json` in a build directory:
``` ```
proj proj
@ -55,7 +55,7 @@ proj
compile_commands.json -> build/compile_commands.json compile_commands.json -> build/compile_commands.json
``` ```
In this example, the `:rootUri` of the generated C++ file is `proj/build/` because of `proj/build/compile_commands.json`. However, the user wants it to be `proj/`. Customize `ccls-project-root-matchers`. In this example, the `:rootUri` of the generated C++ file is `proj/build/` because of `proj/build/compile_commands.json`. However, the user wants it to be `proj/`. Customize `MaskRay-root-matchers`.
### Includes ### Includes
@ -108,6 +108,16 @@ ccls will save a file in `cacheDirectory`:
... ...
``` ```
#### AST deserialisation error when precompiled headers are used
Unfortunately, libclang is very picky when it comes to precompiled headers. Even if your system compiler and the bundled libclang are the same versions there will be problems. Namely, to avoid AST deresialisation errors while using PCH, you need to create them with the same toolchain which will be used inside ccls for completions.
However, making ccls use precompiled headers doesn't make much sense. Libclang will internally create the precompiled headers, but won't store them on permanent storage, so having precompiled headers upfront only speeds up the initial parse - precompiled headers shouldn't make a difference on subsequent parses.
Going back to "create precompiled headers with the same toolchain that will be used by ccls", you can still use precompiled headers, but you will be forced to use your system's libclang, not the one bundled with cquery (even though the bundled one is what's tested).
For reference, read [Valloric/ycmd#892](https://github.com/Valloric/ycmd/issues/892) and [cquery-project/cquery#545](https://github.com/cquery-project/cquery/issues/545).
### Definitions ### Definitions
`textDocument/definition` can be used in many places. Some are current implementation details and may subject to change. `textDocument/definition` can be used in many places. Some are current implementation details and may subject to change.
@ -142,20 +152,20 @@ ccls will save a file in `cacheDirectory`:
* <code><kbd>A</kbd> <kbd>a</kbd>;</code> lists all instances of user-defined `A`. * <code><kbd>A</kbd> <kbd>a</kbd>;</code> lists all instances of user-defined `A`.
* <code>int <kbd>i</kbd>;</code> lists all instances of `int`. * <code>int <kbd>i</kbd>;</code> lists all instances of `int`.
### [`$ccls/callHierarchy`](https://github.com/ccls-project/cquery/blob/master/src/messages/cquery_call_hierarchy.cc) ### [`$ccls/callHierarchy`](https://github.com/MaskRay/cquery/blob/master/src/messages/cquery_call_hierarchy.cc)
```elisp ```elisp
(ccls-call-hierarchy nil) ; caller hierarchy (ccls-call-hierarchy nil) ; caller hierarchy
(ccls-call-hierarchy t) ; callee hierarchy (ccls-call-hierarchy t) ; callee hierarchy
``` ```
### [`$ccls/inheritanceHierarchy`](https://github.com/ccls-project/cquery/blob/master/src/messages/cquery_inheritance_hierarchy.cc) ### [`$ccls/inheritanceHierarchy`](https://github.com/MaskRay/cquery/blob/master/src/messages/cquery_inheritance_hierarchy.cc)
```elisp ```elisp
(ccls-inheritance-hierarchy nil) ; base hierarchy (ccls-inheritance-hierarchy nil) ; base hierarchy
(ccls-inheritance-hierarchy t) ; derived hierarchy (ccls-inheritance-hierarchy t) ; derived hierarchy
``` ```
### [`$ccls/memberHierarchy`](https://github.com/ccls-project/cquery/blob/master/src/messages/cquery_member_hierarchy.cc) ### [`$ccls/memberHierarchy`](https://github.com/MaskRay/cquery/blob/master/src/messages/cquery_member_hierarchy.cc)
Recursively list members of a record type. 😂 nobody has implemented UI for the feature. Help wanted! Recursively list members of a record type. 😂 nobody has implemented UI for the feature. Help wanted!

@ -50,4 +50,7 @@ you cannot use `` `command` `` or space-separated arguments like `%cpp -std=gnu+
### Windows ### Windows
`-fms-extensions -fms-compatibility -fdelayed-template-parsing` in clang-cl mode. If your project is compiled with MSVC, you may change the compiler driver to `clang-cl`, and use the initialization option `extraClangArguments` pass three options:
`-fms-extensions -fms-compatibility -fdelayed-template-parsing`.
See https://clang.llvm.org/docs/MSVCCompatibility.html

@ -97,4 +97,8 @@ with open(os.path.join(sys.argv[1], 'compile_commands.json')) as f:
wget 'https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux' -O .config wget 'https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux' -O .config
yes '' | make config yes '' | make config
bear make -j bzImage modules bear make -j bzImage modules
``` ```
## Misc
`compile_commands.json` should reside in the project root. Set the initialization option `compilationDatabaseDirectory` for an alternative directory containing `compile_commands.json`.