Generating index file for CTU analysis

Hi, I was trying to play with the cross translation unit analysis by passing the argument ‘-analyzer-config experimental-enable-naive-ctu-analysis=true’. However, it seems I need to generate an ‘externalDefMap.txt’ file at first. Then I found that I may be able to use 'intercept-build ’ and ‘analyze-build --ctu-collect-only’ script for generating this file.

I currently stack at the intercept build step,
But after running ‘intercept-build gcc -o test test.c foo.c’, I got an empty ‘compile_commands.json’ file.

How could I address this problem or is there any other way to generate the CTU index file?

Thank you!

Regards!

Adding some folks more knowledgeable on this topic :slight_smile: Gábor, Endre, do you know what’s the issue here? Do we have this documented somewhere?

Hi,

To generate a compile_commands.json file and this is independent from
cross translation unit analysis. You would need this file even if you
were not doing CTU but a single TU based analysis. If you have a CMAKE
project, then you can set -DCMAKE_EXPORT_COMPILE_COMMANDS=1.
Otherwise, intercept-build has issues on MacOS, so you may try to use
alternatives like bear (https://github.com/rizsotto/Bear). AFAIK, Bear
should work on Linux too, but on Linux the best approach is to use the
"CodeChecker log" command to get the compile commands
(https://github.com/Ericsson/codechecker).

We actively develop CTU with CodeChecker as a "runner" script,
scan-build on the other hand is not actively developed (it has
different errors and issues, expect it to work with the very basic
projects only).

Hope this helps,
Gabor