From nobody Thu Aug 13 09:24:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1785894807; cv=none; d=zohomail.com; s=zohoarc; b=dOQLtucFzKvBcfQrFR1k5n8vMIhztg/kXw1hX6F5THjvJJo9zA0aGAaf7OlCaFoV2T2yhfwRFIJZmCGqQBIezuCfoM1EO96V0RJJbRtyMvvY594QrH/B24d9Wauf+O2Jo2d/gEXR7wnGgdaX0X2+oK1YpIwPGHESJbHMNyJMgeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785894807; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Lee8YbDbDbQD/PEEAUhgQiCV3VG2M8ylKmtExRHl+xg=; b=VTx9x+mR+aPHMrBrikMecjBKCIUR5e2yue52B00qamYSFBCzCzglGD4MdjXd9TelwbwM/3P/dg9ZTRrkfozoMH1dtrS9ZXQFaEre+Yipcp+fgozGCY/IwH+kSldHlMGW0xHatDt+sLShAGEInMJQagX+BaHasXFRmWx/wdDRQMg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785894807697120.67048114804834; Tue, 4 Aug 2026 18:53:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382730.1626055 (Exim 4.92) (envelope-from ) id 1wrQoZ-0007Rm-23; Wed, 05 Aug 2026 01:53:03 +0000 Received: by outflank-mailman (output) from mailman id 1382730.1626055; Wed, 05 Aug 2026 01:53:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrQoY-0007Rf-Tc; Wed, 05 Aug 2026 01:53:02 +0000 Received: by outflank-mailman (input) for mailman id 1382730; Wed, 05 Aug 2026 01:53:01 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrQoX-0007RR-1v for xen-devel@lists.xenproject.org; Wed, 05 Aug 2026 01:53:01 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1wrQoV-0068PJ-2h; Wed, 05 Aug 2026 01:52:59 +0000 Received: from [203.221.94.45] (helo=Mac.tail87ea19.ts.net) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.96) (envelope-from ) id 1wrQoU-00CujO-3C; Wed, 05 Aug 2026 01:52:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=Lee8YbDbDbQD/PEEAUhgQiCV3VG2M8ylKmtExRHl+xg=; b=IqME4ytnnjn9USk2eu1wJs0TiW tVlwldlurKihxRUiDhT/sRbDNyQLAW29RBAymV6JhKTZvKReFxWYB8qdUAS5RwMxJ7MAgPEcZ+iKi Wa3Ne1hYbrZAvb8D/GtmLGnoPN1jDeR8tEoQjcpY8o1pm7H18R6xVZKYyMKDVwoIn12A=; From: George Dunlap To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH 1/3] xen/scripts: import gen_compile_commands.py from Linux Date: Wed, 5 Aug 2026 11:52:38 +1000 Message-ID: <20260805015247.41943-2-gwd@xenproject.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260805015247.41943-1-gwd@xenproject.org> References: <20260805015247.41943-1-gwd@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1785894809343158500 Content-Type: text/plain; charset="utf-8" Xen's Kbuild-derived build system records the exact command line used to compile each object in ..o.cmd files. That is everything needed to produce a compile_commands.json compilation database, the format clangd and other tooling consume to provide accurate cross-referencing (go to definition, find references, call hierarchy) in LSP-capable editors. Import scripts/clang-tools/gen_compile_commands.py from the Linux kernel, unmodified, so that the provenance of the code is easy to verify (commit 90efe2b9119f, Linux v6.16). As-is the script produces an empty database on a Xen tree, since Xen's compile command lines differ slightly from Linux's; the following patch adapts it. Assisted-by: LLM Signed-off-by: George Dunlap --- xen/scripts/gen_compile_commands.py | 228 ++++++++++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100755 xen/scripts/gen_compile_commands.py diff --git a/xen/scripts/gen_compile_commands.py b/xen/scripts/gen_compile_= commands.py new file mode 100755 index 0000000000..96e6e46ad1 --- /dev/null +++ b/xen/scripts/gen_compile_commands.py @@ -0,0 +1,228 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) Google LLC, 2018 +# +# Author: Tom Roeder +# +"""A tool for generating compile_commands.json in the Linux kernel.""" + +import argparse +import json +import logging +import os +import re +import subprocess +import sys + +_DEFAULT_OUTPUT =3D 'compile_commands.json' +_DEFAULT_LOG_LEVEL =3D 'WARNING' + +_FILENAME_PATTERN =3D r'^\..*\.cmd$' +_LINE_PATTERN =3D r'^(saved)?cmd_[^ ]*\.o :=3D (?P.* )(?P<= file_path>[^ ]*\.[cS]) *(;|$)' +_VALID_LOG_LEVELS =3D ['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. +_EXCLUDE_DIRS =3D ['.git', 'Documentation', 'include', 'tools'] + +def parse_arguments(): + """Sets up and parses command-line arguments. + + Returns: + log_level: A logging level to filter log output. + directory: The work directory where the objects were built. + ar: Command used for parsing .a archives. + output: Where to write the compile-commands JSON file. + paths: The list of files/directories to handle to find .cmd files. + """ + usage =3D 'Creates a compile_commands.json database from kernel .cmd f= iles' + parser =3D argparse.ArgumentParser(description=3Dusage) + + directory_help =3D ('specify the output directory used for the kernel = build ' + '(defaults to the working directory)') + parser.add_argument('-d', '--directory', type=3Dstr, default=3D'.', + help=3Ddirectory_help) + + output_help =3D ('path to the output command database (defaults to ' + + _DEFAULT_OUTPUT + ')') + parser.add_argument('-o', '--output', type=3Dstr, default=3D_DEFAULT_O= UTPUT, + help=3Doutput_help) + + log_level_help =3D ('the level of log messages to produce (defaults to= ' + + _DEFAULT_LOG_LEVEL + ')') + parser.add_argument('--log_level', choices=3D_VALID_LOG_LEVELS, + default=3D_DEFAULT_LOG_LEVEL, help=3Dlog_level_hel= p) + + ar_help =3D 'command used for parsing .a archives' + parser.add_argument('-a', '--ar', type=3Dstr, default=3D'llvm-ar', hel= p=3Dar_help) + + paths_help =3D ('directories to search or files to parse ' + '(files should be *.o, *.a, or modules.order). ' + 'If nothing is specified, the current directory is searc= hed') + parser.add_argument('paths', type=3Dstr, nargs=3D'*', help=3Dpaths_hel= p) + + args =3D parser.parse_args() + + return (args.log_level, + os.path.realpath(args.directory), + args.output, + args.ar, + args.paths if len(args.paths) > 0 else [args.directory]) + + +def cmdfiles_in_dir(directory): + """Generate the iterator of .cmd files found under the directory. + + Walk under the given directory, and yield every .cmd file found. + + Args: + directory: The directory to search for .cmd files. + + Yields: + The path to a .cmd file. + """ + + filename_matcher =3D re.compile(_FILENAME_PATTERN) + exclude_dirs =3D [ os.path.join(directory, d) for d in _EXCLUDE_DIRS ] + + for dirpath, dirnames, filenames in os.walk(directory, topdown=3DTrue): + # Prune unwanted directories. + if dirpath in exclude_dirs: + dirnames[:] =3D [] + continue + + for filename in filenames: + if filename_matcher.match(filename): + yield os.path.join(dirpath, filename) + + +def to_cmdfile(path): + """Return the path of .cmd file used for the given build artifact + + Args: + Path: file path + + Returns: + The path to .cmd file + """ + dir, base =3D os.path.split(path) + return os.path.join(dir, '.' + base + '.cmd') + + +def cmdfiles_for_a(archive, ar): + """Generate the iterator of .cmd files associated with the archive. + + Parse the given archive, and yield every .cmd file used to build it. + + Args: + archive: The archive to parse + + Yields: + The path to every .cmd file found + """ + for obj in subprocess.check_output([ar, '-t', archive]).decode().split= (): + yield to_cmdfile(obj) + + +def cmdfiles_for_modorder(modorder): + """Generate the iterator of .cmd files associated with the modules.ord= er. + + Parse the given modules.order, and yield every .cmd file used to build= the + contained modules. + + Args: + modorder: The modules.order file to parse + + Yields: + The path to every .cmd file found + """ + with open(modorder) as f: + for line in f: + obj =3D line.rstrip() + base, ext =3D os.path.splitext(obj) + if ext !=3D '.o': + sys.exit('{}: module path must end with .o'.format(obj)) + mod =3D base + '.mod' + # Read from *.mod, to get a list of objects that compose the m= odule. + with open(mod) as m: + for mod_line in m: + yield to_cmdfile(mod_line.rstrip()) + + +def process_line(root_directory, command_prefix, file_path): + """Extracts information from a .cmd line and creates an entry from it. + + Args: + root_directory: The directory that was searched for .cmd files. Us= ually + used directly in the "directory" entry in compile_commands.jso= n. + command_prefix: The extracted command line, up to the last element. + file_path: The .c file from the end of the extracted command. + Usually relative to root_directory, but sometimes absolute. + + Returns: + An entry to append to compile_commands. + + Raises: + ValueError: Could not find the extracted file based on file_path a= nd + root_directory or file_directory. + """ + # The .cmd files are intended to be included directly by Make, so they + # escape the pound sign '#' as '$(pound)'. The compile_commands.json f= ile + # is not interepreted by Make, so this code replaces the escaped versi= on + # with '#'. + prefix =3D command_prefix.replace('$(pound)', '#') + + # Return the canonical path, eliminating any symbolic links encountere= d in the path. + abs_path =3D os.path.realpath(os.path.join(root_directory, file_path)) + if not os.path.exists(abs_path): + raise ValueError('File %s not found' % abs_path) + return { + 'directory': root_directory, + 'file': abs_path, + 'command': prefix + file_path, + } + + +def main(): + """Walks through the directory and finds and parses .cmd files.""" + log_level, directory, output, ar, paths =3D parse_arguments() + + level =3D getattr(logging, log_level) + logging.basicConfig(format=3D'%(levelname)s: %(message)s', level=3Dlev= el) + + line_matcher =3D re.compile(_LINE_PATTERN) + + compile_commands =3D [] + + for path in paths: + # If 'path' is a directory, handle all .cmd files under it. + # Otherwise, handle .cmd files associated with the file. + # built-in objects are linked via vmlinux.a + # Modules are listed in modules.order. + if os.path.isdir(path): + cmdfiles =3D cmdfiles_in_dir(path) + elif path.endswith('.a'): + cmdfiles =3D cmdfiles_for_a(path, ar) + elif path.endswith('modules.order'): + cmdfiles =3D cmdfiles_for_modorder(path) + else: + sys.exit('{}: unknown file type'.format(path)) + + for cmdfile in cmdfiles: + with open(cmdfile, 'rt') as f: + result =3D line_matcher.match(f.readline()) + if result: + try: + entry =3D process_line(directory, result.group('co= mmand_prefix'), + result.group('file_path')) + compile_commands.append(entry) + except ValueError as err: + logging.info('Could not add line from %s: %s', + cmdfile, err) + + with open(output, 'wt') as f: + json.dump(sorted(compile_commands, key=3Dlambda x: x["file"]), f, = indent=3D2, sort_keys=3DTrue) + + +if __name__ =3D=3D '__main__': + main() --=20 2.55.0 From nobody Thu Aug 13 09:24:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1785894807; cv=none; d=zohomail.com; s=zohoarc; b=Z2jnQqsVGexaHkpnAyoELvoFoACFIGTVxwifN4vC0T4sLvfCZUL9xPX738/n9KnqlR/uarPxSFGCkpc0stvyiSRUaWF5d3GAiA86jYRer891dIg4xjotdYU4IRWs13UKsFOsAlmWqLkmv1rSje4gOaUAsJMNUbrJab7GY7/MY5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785894807; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EQ1BgccOExwdWoWHGsLFxtseXR3eMpL+XYbSkxSyAEo=; b=N0Pqprr5Tsmq0CFomXHfpE7ovS4iCX+zwa7Gh6rWLz3d5AZWkwOawZ3olATFoZ6nj8lnIjZWuIa3xnJlAvvDKkQnb0HHeu2GjT8xuapjj9XruxZA83XxYxjq4L72AWPN/It39IgqIBtaj5xdvOEOgFpSuYLbIZFcnT3R6hWOct8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785894806989557.9243499553658; Tue, 4 Aug 2026 18:53:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382731.1626063 (Exim 4.92) (envelope-from ) id 1wrQob-0007fE-6h; Wed, 05 Aug 2026 01:53:05 +0000 Received: by outflank-mailman (output) from mailman id 1382731.1626063; Wed, 05 Aug 2026 01:53:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrQob-0007f7-41; Wed, 05 Aug 2026 01:53:05 +0000 Received: by outflank-mailman (input) for mailman id 1382731; Wed, 05 Aug 2026 01:53:03 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrQoZ-0007eX-Sp for xen-devel@lists.xenproject.org; Wed, 05 Aug 2026 01:53:03 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1wrQoY-0068QR-2v; Wed, 05 Aug 2026 01:53:02 +0000 Received: from [203.221.94.45] (helo=Mac.tail87ea19.ts.net) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.96) (envelope-from ) id 1wrQoY-00CujO-0D; Wed, 05 Aug 2026 01:53:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=EQ1BgccOExwdWoWHGsLFxtseXR3eMpL+XYbSkxSyAEo=; b=f/HIkpQwJwcgU1rtgixLQ1KwFo pv5nECO/LoGehysoJ5oMBZ5X0DQmHceC3R+tDZn+i+ccIf/w9PmcXom0dA8SL2AlyaYhXsQGgRe8r KNJk2QtuimWrMjZImPtGV9YYrydccrjp2zE4DAn+Nnug8CbZ/B3OZ5pVXteIEkauUEAU=; From: George Dunlap To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH 2/3] xen/scripts: adapt gen_compile_commands.py to Xen Date: Wed, 5 Aug 2026 11:52:39 +1000 Message-ID: <20260805015247.41943-3-gwd@xenproject.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260805015247.41943-1-gwd@xenproject.org> References: <20260805015247.41943-1-gwd@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1785894809328158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 # -"""A tool for generating compile_commands.json in the Linux kernel.""" +"""A tool for generating compile_commands.json for the Xen hypervisor.""" =20 import argparse import json @@ -19,7 +19,10 @@ _DEFAULT_OUTPUT =3D 'compile_commands.json' _DEFAULT_LOG_LEVEL =3D 'WARNING' =20 _FILENAME_PATTERN =3D r'^\..*\.cmd$' -_LINE_PATTERN =3D r'^(saved)?cmd_[^ ]*\.o :=3D (?P.* )(?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". Capture the command up +# to and including "-c" plus the source file, and drop the remainder. +_LINE_PATTERN =3D r'^(saved)?cmd_[^ ]*\.o :=3D (?P.* -c )(= ?P[^ ]*\.[cS])( .*)?$' _VALID_LOG_LEVELS =3D ['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 =3D 'Creates a compile_commands.json database from kernel .cmd f= iles' + usage =3D 'Creates a compile_commands.json database from Xen .cmd file= s' parser =3D argparse.ArgumentParser(description=3Dusage) =20 - directory_help =3D ('specify the output directory used for the kernel = build ' + directory_help =3D ('specify the output directory used for the Xen bui= ld ' '(defaults to the working directory)') parser.add_argument('-d', '--directory', type=3Dstr, default=3D'.', help=3Ddirectory_help) --=20 2.55.0 From nobody Thu Aug 13 09:24:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1785894807; cv=none; d=zohomail.com; s=zohoarc; b=MldQPG/gzA6mf2ef9k0CmmUiDd1FebTvbVgp+Ede/XSqeUwGdHCccKY5oXEiq0ZDTga7RQOO0SrMgYzW/AwY3+5b2AJZauWON6T8fbfH5GxAN4E6qBhoDxAAcfCFMdLwxWqbEtjIIpjDl8apf1LttnWQ3JO5kfI48KsZVKx0zpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785894807; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+sgH7buv7ht5eYGRQ/eq/HiItqeiSBS/Osfxgw6BGz4=; b=be3HZemKJAuGA1BDgKxmDEnFBX9brUl6f2Ugn9bYnhFVQ7/wMFBFoBZ+r61W8RyzTLb6nUonIHb124GDuxY2wpZkn9nwUXQam2WyUgHJBkbZotFbkh8AYqWbkdeyAOwvGNhjP8f0e+cEPJwrybjQNyWhlu9fKuCHyt4eeG0x2xM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785894807301543.952775108209; Tue, 4 Aug 2026 18:53:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382732.1626071 (Exim 4.92) (envelope-from ) id 1wrQod-0007tg-D5; Wed, 05 Aug 2026 01:53:07 +0000 Received: by outflank-mailman (output) from mailman id 1382732.1626071; Wed, 05 Aug 2026 01:53:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrQod-0007tX-9v; Wed, 05 Aug 2026 01:53:07 +0000 Received: by outflank-mailman (input) for mailman id 1382732; Wed, 05 Aug 2026 01:53:06 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrQoc-0007t8-Th for xen-devel@lists.xenproject.org; Wed, 05 Aug 2026 01:53:06 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1wrQoc-0068Ru-0A; Wed, 05 Aug 2026 01:53:05 +0000 Received: from [203.221.94.45] (helo=Mac.tail87ea19.ts.net) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.96) (envelope-from ) id 1wrQob-00CujO-0m; Wed, 05 Aug 2026 01:53:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=+sgH7buv7ht5eYGRQ/eq/HiItqeiSBS/Osfxgw6BGz4=; b=lQ53XEufoqc9wMSfBo8QJ8NJ+6 JZSHlHlngaKGMD6BcpyCkI25g8GnpwGo/0lGkxge/wNU06nFkRJQKXgWlz8Td/uUpXpsPqRAqqIKe YUuN4jMGpTDetKyG9gZwTJpgyQDWVP54VAQ2p5w8qNuZLPrqc8VajPxFrYRH+sSYm3Pw=; From: George Dunlap To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH 3/3] build: add compile_commands.json target Date: Wed, 5 Aug 2026 11:52:40 +1000 Message-ID: <20260805015247.41943-4-gwd@xenproject.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260805015247.41943-1-gwd@xenproject.org> References: <20260805015247.41943-1-gwd@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1785894809309158500 Content-Type: text/plain; charset="utf-8" Add a phony convenience target generating the compilation database from a built object tree, alongside the other developer conveniences (tags, cscope, cloc -- the last of which already walks the same .cmd files): make -C xen compile_commands.json The output lands in the object tree root, where clangd and other consumers discover it automatically when opening files from an in-tree build. Note the database records the compiler invocations actually used. With a clang build it is consumable by clangd as-is; for a gcc build, clang-based tools may need a small .clangd configuration (CompileFlags: Remove/Add) dropping gcc-only flags. Also add the generated file to .gitignore. Assisted-by: LLM Signed-off-by: George Dunlap --- .gitignore | 1 + xen/Makefile | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index bfc7bdf043..0aa9b801de 100644 --- a/.gitignore +++ b/.gitignore @@ -192,6 +192,7 @@ xen/arch/*/include/generated xen/build-dir-cppcheck/ xen/common/config_data.S xen/common/config.gz +xen/compile_commands.json xen/cppcheck-htmlreport/ xen/cppcheck-report/ xen/cppcheck-misra.* diff --git a/xen/Makefile b/xen/Makefile index d39bdfdd53..f87240f33c 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -685,6 +685,10 @@ cloc: done; \ done | cloc --list-file=3D- =20 +.PHONY: compile_commands.json +compile_commands.json: + $(PYTHON) $(srctree)/scripts/gen_compile_commands.py -d $(objtree) + # Target used by xen-analysis.sh script to retrieve Xen build system varia= bles export-variable-%: $(info $*=3D$($*)) --=20 2.55.0