From: Eduard Zingerman <eddyz87@gmail.com>
To: Pat Somaru <patso@likewhatevs.io>
Cc: justinstitt@google.com, linux-kbuild@vger.kernel.org,
llvm@lists.linux.dev, morbo@google.com, nathan@kernel.org,
nick.desaulniers+lkml@gmail.com, nsc@kernel.org
Subject: Re: [PATCH v2] scripts/clang-tools: Handle included .c files in gen_compile_commands
Date: Fri, 17 Oct 2025 10:21:26 -0700 [thread overview]
Message-ID: <46370bb8fcb2f01bce5402a6f7937426731fa450.camel@gmail.com> (raw)
In-Reply-To: <20251008004615.2690081-1-patso@likewhatevs.io>
On Tue, 2025-10-07 at 20:45 -0400, Pat Somaru wrote:
> 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-includedd 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>
> Tested-by: Justin Stitt <justinstitt@google.com>
> ---
I tested navigation to work in emacs+clangd combination with this
patch for the following files:
- kernel/sched/pelt.c
- kernel/sched/cputime.c
- kernel/sched/deadline.c
All included from the kernel/sched/build_policy.c.
Navigation works for entities declared in the same file, entities
declared in headers included from build_policy.c, entities declared in
headers included from {pelt,cputime,deadline}.c.
Note that sched/ code [ab]uses the pattern with .c file includes a
lot. W/o this patch clangd is completely oblivious to the content of
the above files. Jump to definition is almost useless, who-calls
queries ignore functions declared in these files etc.
Tested-by: Eduard Zingerman <eddyz87@gmail.com>
[...]
next prev parent reply other threads:[~2025-10-17 17:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 2:45 [PATCH] scripts/clang-tools: Handle included .c files in gen_compile_commands Pat Somaru
2025-10-07 16:33 ` Nathan Chancellor
2025-10-07 19:55 ` Justin Stitt
2025-10-07 19:59 ` Justin Stitt
2025-10-08 0:09 ` Pat Somaru
2025-10-08 0:37 ` Pat Somaru
2025-10-08 0:45 ` [PATCH v2] " Pat Somaru
2025-10-17 17:21 ` Eduard Zingerman [this message]
2025-10-31 22:56 ` Nathan Chancellor
2025-11-05 21:30 ` Nicolas Schier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46370bb8fcb2f01bce5402a6f7937426731fa450.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=justinstitt@google.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=nsc@kernel.org \
--cc=patso@likewhatevs.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox