From aa86353e978e4ffb41f274d7235c7472e47ea5e6 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 10 Jan 2019 00:00:29 +0800 Subject: [PATCH] Delete %clang and add an example about -march=armv7a --- Project-Setup.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Project-Setup.md b/Project-Setup.md index 1bd6253..33239c9 100644 --- a/Project-Setup.md +++ b/Project-Setup.md @@ -152,12 +152,6 @@ By default `.ccls` specify compiler flags of files not listed in `compile_commands.json` is parsed, the rest lines of `.ccls` will be appended to the compiler flags. -### `%clang` - -Resolves to either `clang` (C) or `clang++` (C++). This is useful if your -project has both C and C++ source files, because if unconditional `clang++` is -used instead, `clang++ a.c` parses `a.c` as C++. - ### `%c` / `%cpp` / `%objective-c` / `%objective-cpp` This argument should be added only when parsing C (`%c`), C++ (`%cpp`), @@ -168,12 +162,19 @@ Objective-C (`%objective-c`), or Objective-C++ (`%objective-c++`) files. This argument should be added only when indexing C header files (`%h`: `*.h`) or C++ header files (`%hpp`: `*.hh` `*.hpp`). Note, `*.h` files are considered as C, not C++. +### Compiler driver + +The compiler driver (the first line unless `%compile_commands.json` is used) can usually just be `clang`. +`clang++` is usually unnecessary, and incorrect if some files are C. + +Note that `clang a.cc` and `clang++ a.cc` are different, but the difference is only related to linking (what default runtime libraries are passed) and is not relevant for the frontend actions ccls performs. + ## `.ccls` examples #### Example A ``` -%clang +clang %c -std=c11 %cpp -std=c++2a %h %hpp --include=Global.h @@ -194,7 +195,19 @@ header files (`%hpp`: `*.hh` `*.hpp`). Note, `*.h` files are considered as C, no -Iinc ``` -It appends flags so `%clang` should not be used. +It appends flags so `clang` should not be used. + +#### Example: `-march=armv7a` + +See . +If the compiler driver is a GCC cross-compiler, `--target=` may be required. Suppose `arm-linux-gnueabi-gcc -march=armv7a` is used, add a `--target=`: + +``` +%compile_commands.json +--target=armv7a-linux-gnueabi +``` + +Otherwise clang will `error: unknown target CPU 'armv7a'`. ## `compile_commands.json` examples