Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Produce all possible errors with Clang/Ninja / Keep going with Ninja / Ninja equivalent of make -k

Tags:

clang

ninja

I am compiling a fairly large library with many outside dependencies that I need to pull in. Each time I attempt a compilation I get a new error about a missing header file. I then have to go and track down where to find that header/library and add it to the project includes. This process of compilation-then-find-header/source is repeated and takes a lot of time.

I would like the compiler to continue trying to build and output all missing headers in one error list. Is this possible using Clang and if so how can I control it? On a related note, once I have all headers is it possible to tell Clang to report all linker errors/undefined references, so I don't have to repeat this process with source files?

I am looking for compiler flags to print out all possible errors (missing headers) and all undefined references. In other words, I want the compilation to continue passed the first file with errors and attempt to compile all files in the project. The compiler is Clang (C/C++) version 8.0.2. The make tool is ninja (1.5.3). Make files are generated with CMake (3.6.4).

Update: Looking back, my original question was asking for a solution in the wrong tool. Instead of passing a flag to Clang, I needed to pass a flag to my make tool, Ninja.

like image 737
javey Avatar asked Nov 18 '19 18:11

javey


1 Answers

From ninja --help:

-k N     keep going until N jobs fail [default=1]

so i'd run ninja command like:

ninja -k 100

to continue until 100 errors are found or the build succeeds. One thing to note is that some errors may just stop the entire build if the erroneous file is necessary to continue the build process.

like image 104
A. K. Avatar answered Oct 03 '22 00:10

A. K.