]> git.ipfire.org Git - thirdparty/linux.git/commit
scripts/clang-tools: Handle included .c files in gen_compile_commands
authorPat Somaru <patso@likewhatevs.io>
Wed, 8 Oct 2025 00:45:28 +0000 (20:45 -0400)
committerNicolas Schier <nsc@kernel.org>
Sat, 8 Nov 2025 11:18:00 +0000 (12:18 +0100)
commit9362d34acf91a706c543d919ade3e651b9bd2d6f
tree802f5a1fe94c65169bebc96c991e57eacf1bb586
parent2d7eda1db504e98650c03706e8c551b35a468c34
scripts/clang-tools: Handle included .c files in gen_compile_commands

The gen_compile_commands.py script currently only creates entries for the
primary source files found in .cmd files, but some kernel source files
text-include others (i.e. kernel/sched/build_policy.c).

This prevents tools like clangd from working properly on text-included c
files, such as kernel/sched/ext.c because the generated compile_commands.json
does not have entries for them.

Extend process_line() to detect when a source file includes .c files, and
generate additional compile_commands.json entries for them. For included c
files, use the same compile flags as their parent and add their parents headers.

This enables lsp tools like clangd to work properly on files like
kernel/sched/ext.c

Signed-off-by: Pat Somaru <patso@likewhatevs.io>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Justin Stitt <justinstitt@google.com>
Tested-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://patch.msgid.link/20251008004615.2690081-1-patso@likewhatevs.io
Signed-off-by: Nicolas Schier <nsc@kernel.org>
scripts/clang-tools/gen_compile_commands.py