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

Re: [PATCH 2/3] xen/scripts: adapt gen_compile_commands.py to Xen



On Wed, Aug 05, 2026 at 11:52:39AM +1000, George Dunlap wrote:
> Two changes from the Linux original:
> 
>  - Linux's compiler invocations end with the source file
>    ("... -c -o foo.o foo.c"), and the script's line pattern relies
>    on that; Xen's cmd_cc_o_c places "-c $<" before "-o" and "-MQ",
>    so on a Xen object tree the unmodified script matches nothing and
>    produces an empty database.  Adjust _LINE_PATTERN to capture the
>    command up to and including "-c" plus the source file, dropping
>    the remainder, which database consumers do not need.
> 
>  - Reword the docstring and help text to refer to Xen.
> 
> The support for reading object lists from archives and modules.order
> is unused in Xen but retained to minimise divergence from the
> original.
> 
> Assisted-by: LLM
> Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
> ---
>  xen/scripts/gen_compile_commands.py | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/scripts/gen_compile_commands.py 
> b/xen/scripts/gen_compile_commands.py
> index 96e6e46ad1..9abc6410c1 100755
> --- a/xen/scripts/gen_compile_commands.py
> +++ b/xen/scripts/gen_compile_commands.py
> @@ -5,7 +5,7 @@
>  #
>  # Author: Tom Roeder <tmroeder@xxxxxxxxxx>
>  #
> -"""A tool for generating compile_commands.json in the Linux kernel."""
> +"""A tool for generating compile_commands.json for the Xen hypervisor."""
>  
>  import argparse
>  import json
> @@ -19,7 +19,10 @@ _DEFAULT_OUTPUT = 'compile_commands.json'
>  _DEFAULT_LOG_LEVEL = 'WARNING'
>  
>  _FILENAME_PATTERN = r'^\..*\.cmd$'
> -_LINE_PATTERN = r'^(saved)?cmd_[^ ]*\.o := (?P<command_prefix>.* 
> )(?P<file_path>[^ ]*\.[cS]) *(;|$)'
> +# Unlike Linux, Xen's compile commands do not end with the source file:
> +# cmd_cc_o_c places "-c $<" before "-o" and "-MQ".

This looks like a comment for the patch rather than the pattern in the
following line. So it doesn't seems useful here.

>                                                      Capture the command up
> +# to and including "-c" plus the source file, and drop the remainder.

Here, I think it would be worth it to explain what the remainder is,
which in turn would help explain why it is dropped at all.

Besides that, the patch description and the other changes looks fine to
me.

> +_LINE_PATTERN = r'^(saved)?cmd_[^ ]*\.o := (?P<command_prefix>.* -c 
> )(?P<file_path>[^ ]*\.[cS])( .*)?$'
>  _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.
> @@ -35,10 +38,10 @@ def parse_arguments():
>          output: Where to write the compile-commands JSON file.
>          paths: The list of files/directories to handle to find .cmd files.
>      """
> -    usage = 'Creates a compile_commands.json database from kernel .cmd files'
> +    usage = 'Creates a compile_commands.json database from Xen .cmd files'
>      parser = argparse.ArgumentParser(description=usage)
>  
> -    directory_help = ('specify the output directory used for the kernel 
> build '
> +    directory_help = ('specify the output directory used for the Xen build '
>                        '(defaults to the working directory)')
>      parser.add_argument('-d', '--directory', type=str, default='.',
>                          help=directory_help)

Thanks,


--
Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.