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?
Adding some folks more knowledgeable on this topic Gábor, Endre, do you know what’s the issue here? Do we have this documented somewhere?
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
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
Hope this helps,