Re: [PATCH] gen_compile_commands: include targets not end with .o

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 24, 2023 at 12:10:29PM -0700, Nick Desaulniers wrote:
> On Sun, May 14, 2023 at 3:19 AM Hu Weiwen <huww98@xxxxxxxxxxx> wrote:
> >
> > From: Hu Weiwen <sehuww@xxxxxxxxxxxxxxxx>
> 
> Hi Hu,
> Sorry, for the delay. I'm usually faster to respond to patches. It was
> my mistake this fell through the cracks, and thank you for the patch.
> 
> I received this email from <huww98@xxxxxxxxxxx>. Do you mind resending
> with your signed off by tag set to the email address from which you
> are sending patches?  This patch looks benign to me, but it makes me a
> little uneasy when author != sender.
> 
> Please also cc
> - Masahiro Yamada <masahiroy@xxxxxxxxxx>
> - linux-kbuild@xxxxxxxxxxxxxxx
> 
> As this would go in via the kbuild tree.

OK, will resend.

> >
> > Currently, we only extract commands for targets end with '.o'. But we
> 
> s/end/ending/
> 
> 
> With this patch applies\d, I get the same word count for
> compile_commands.json when running:
> $ make LLVM=1 -j128 defconfig compile_commands.json
> 
> on my x86_64 host. Is that expected?  Is there a specific arch or set
> of configs for which such .c files produce executables directly?

`make compile_commands.json' will invoke this script as 
`gen_compile_commands.py ... vmlinux.a modules.order'. So only '.o'
targets are included.  To include .c files that produce executable, run
the script directly after a successful build:
$ python3 scripts/clang-tools/gen_compile_commands.py

Some examples of such file:
* scripts/unifdef.c
* scripts/asn1_compiler.c
* scripts/kallsyms.c
* scripts/basic/fixdep.c
* samples/connector/ucon.c

Thanks,
Hu Weiwen

> > also have many standalone executables built in-tree.
> >
> > Remove this restriction. And to avoid some false matching, exclude
> > targets end with '.c' or '.h' when directly walking the directory.
> >
> > Signed-off-by: Hu Weiwen <sehuww@xxxxxxxxxxxxxxxx>
> > ---
> >  scripts/clang-tools/gen_compile_commands.py | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/clang-tools/gen_compile_commands.py b/scripts/clang-tools/gen_compile_commands.py
> > index 15ba56527acd..6e88c7e166fc 100755
> > --- a/scripts/clang-tools/gen_compile_commands.py
> > +++ b/scripts/clang-tools/gen_compile_commands.py
> > @@ -18,8 +18,8 @@ import sys
> >  _DEFAULT_OUTPUT = 'compile_commands.json'
> >  _DEFAULT_LOG_LEVEL = 'WARNING'
> >
> > -_FILENAME_PATTERN = r'^\..*\.cmd$'
> > -_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)'
> > +_FILENAME_PATTERN = r'^\..*(?<!\.(c|h))\.cmd$'
> > +_LINE_PATTERN = r'^savedcmd_[^ ]* := (.* )([^ ]*\.c) *(;|$)'
> >  _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
> >  # The tools/ directory adopts a different build system, and produces .cmd
> >  # files in a different format. Do not support it.
> > --
> > 2.25.1
> >
> >
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux