Skip to content

Conversation

@bruntib
Copy link
Contributor

@bruntib bruntib commented Nov 28, 2025

A new flag is added to "CodeChecker analyze": --dump-compiler-info-file. This flag is given a filename as parameter. This filename will be created in the output folder. The file contains implicit include paths and some other gcc-specific data that can be used to finetune analysis later. When this flag is used, then analysis doesn't run.

The compiler_info.json was generated in the output directory by default. Due to some bug, this file is empty in recent CodeChecker versions. The reason is that parsing compile_commands.json is done in parallel with a process pool. The dict object that collects this data must be handled by multiprocessing.SyncManager() so it can be used in a process pool.

Copy link
Collaborator

@barnabasdomozi barnabasdomozi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left some questions when reviewing this patch.

Also note that analyzer tests are currently failing:

-   File "/home/runner/work/codechecker/codechecker/build/CodeChecker/lib/python3/codechecker_analyzer/cli/analyze.py", line 1383, in main
-     if args.dump_compiler_info_file:
- AttributeError: 'Namespace' object has no attribute 'dump_compiler_info_file'

if args.dump_compiler_info_file:
compiler_info = Path(args.output_path) / 'compiler_info.json'
try:
os.rename(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the code, it's not clear to me what this flag actually does. Renames an already existing file? Why?
Why not dump the file to output path args.dump_compiler_info_file in the first place?

The help description says:

Dump implicit gcc compiler info to a json file
that can be used for fine-tuning analysis later.

To me, it seems this file is already dumped regardless of this flag, just under a different name: compiler_info.json. Correct me if I'm wrong, but this part is not clear to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first idea was introducing this command:

CodeChecker analyze compile_commands.json --dump-compiler-info-file <filename>

This could have created the given file. However, CodeChecker analyze has a mandatory -o flag:

CodeChecker analyze compile_commands.json --dump-compiler-info-file <filename> -o reports

Intuitively this tells me that the compiler info file will be created into reports folder. However, reports/compiler_info.json is created anyway. I didn't find it elegant, that this file is created twice in the report folder: with the name compiler_info.json and the given <filename>.
This led me to the current solution which simply renames the compiler_info.json to the given filename.

Another solution could have been not dumping compiler_info.json in the log_parser module, but here in the main() function. Maybe we could refactor it in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we do this instead?

CodeChecker analyze compile_commands.json --dump-compiler-info-file -o <filename>

after the -o flag the user could directly specify the compiler_info.json. Then we could avoid this unfortunate renaming trick.

@bruntib bruntib force-pushed the dump_compiler_info branch 2 times, most recently from 5595f30 to 09cf96b Compare November 29, 2025 23:39
Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think
CodeChecker analyze --dump-compiler-info-file -o compiler_info.json

would be a better invocation syntax.

if args.dump_compiler_info_file:
compiler_info = Path(args.output_path) / 'compiler_info.json'
try:
os.rename(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we do this instead?

CodeChecker analyze compile_commands.json --dump-compiler-info-file -o <filename>

after the -o flag the user could directly specify the compiler_info.json. Then we could avoid this unfortunate renaming trick.

@bruntib
Copy link
Contributor Author

bruntib commented Dec 1, 2025

Please, don't merge, but approve this PR. I'd like to squash the commits before merging. Thank you!

Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

A new flag is added to "CodeChecker analyze": --dump-compiler-info-file.
This flag is given a filename as parameter. This filename will be
created in the output folder. The file contains implicit include paths
and some other gcc-specific data that can be used to finetune analysis
later. When this flag is used, then analysis doesn't run.

The compiler_info.json was generated in the output directory by default.
Due to some bug, this file is empty in recent CodeChecker versions. The
reason is that parsing compile_commands.json is done in parallel with a
process pool. The dict object that collects this data must be handled by
multiprocessing.SyncManager() so it can be used in a process pool.
@bruntib bruntib force-pushed the dump_compiler_info branch from cfac124 to c863409 Compare December 2, 2025 12:54
@dkrupp dkrupp dismissed barnabasdomozi’s stale review December 2, 2025 15:02

all comments were addressed.

@dkrupp dkrupp merged commit 65c5db5 into Ericsson:master Dec 2, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants