From nobody Sat Nov 15 22:25:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747076821; cv=none; d=zohomail.com; s=zohoarc; b=idEehcg+zbJoN0fvNVrayM8qr4izhK+x8STKLH2AV+3oOgMgvQdwK8sxyypj/bzmd6NkT+D2BlWHH4+PZ8BZIVQiBU6dmTZa17RaJDkjtuuveJ85eh6/v7gl6jWWl/NjqkjOCKoJqOszW3H/ohRABA/w/XvLYoWvqk0mWeRGOpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747076821; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0ehf2YgaMXoxb+fwp0uJKFVwZBOJsson/HPg8rmycXI=; b=Pk2XOuKBbOH4sOdkJdJUCMy2CDRQKtJt2s+a/yWWL7JRfo2is23SE+o/SCzQzDyvdEV0fbEbKv2vjVCH/usEbWmhLLUhtdqwO//C4BMeM9mP27S2O3R4/iFrJU++u9D5xQEp+NJVicP6fRtrLD+ryHf0HG/Yw7ep2/KMZqvAEdA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747076821828509.9976062995987; Mon, 12 May 2025 12:07:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEYTG-0005Ta-Se; Mon, 12 May 2025 15:05:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uEYT8-0005Rx-EX for qemu-devel@nongnu.org; Mon, 12 May 2025 15:05:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uEYT5-0007UN-8l for qemu-devel@nongnu.org; Mon, 12 May 2025 15:05:41 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-454-9m9jfK4dNpC5eJphH3B6RQ-1; Mon, 12 May 2025 15:05:36 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a0b7ceaa20so1569796f8f.1 for ; Mon, 12 May 2025 12:05:36 -0700 (PDT) Received: from [192.168.122.1] ([151.95.45.141]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a1f5a4cc39sm13200196f8f.100.2025.05.12.12.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 May 2025 12:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747076738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ehf2YgaMXoxb+fwp0uJKFVwZBOJsson/HPg8rmycXI=; b=dT8r8fHY+mvQOV83yyBjiB3470tnlkjsGriS1lNMSm8QtsEhWG5af/uPy1y8Pok1/hnV4/ AXtqCY2B2KEVTYlcl9iLmsFpVNWlE28N+imHB6OvTrblVljugaVfEg11VHL6LJQcsJ8WnZ H5Me3sT3p2xIs4bE31UcYHQdI4yz2zc= X-MC-Unique: 9m9jfK4dNpC5eJphH3B6RQ-1 X-Mimecast-MFC-AGG-ID: 9m9jfK4dNpC5eJphH3B6RQ_1747076736 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747076735; x=1747681535; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0ehf2YgaMXoxb+fwp0uJKFVwZBOJsson/HPg8rmycXI=; b=TnGegcU5vox6UALmToVL++IdcCw84DWge1Mz76BrmoLaigMQiRrUfJ30lHh39RUoD0 /dY+QBVyndZji+N5zTNUy6pjryEGwn0uRfh4WJzbB+CZS8yvrKDB7YraqGL3v6QCcmHw 4n0TBhF1wGsiW/ScCzXKKIP5+089RKPO/ZaVj58wr0s0IzhzUcFBMI4VI9zjGn4u9K87 sLwFsSyTLtduCpI+mbY0cBzKh16ersNL1RNXt9OngrO9Q30D93gY6bNXsnZChEd9K2aj NAwqwfpnLZ8KaqPFk78yDauxqvPj82Ls0MRuXZb7yLFG8Yr2VxYFEvkw03YODTTZXrYL NJPQ== X-Gm-Message-State: AOJu0YxpTr35QizE/neoSUXle9O5uigS0rNOPOKFkWiFq9JW9vU0mgnC D/7YE0B8goLpAMRXyyLCMSUFGQhZlCKUQfUeUqSqxS6MjZ2yWiJssIOl8OaszbUH1VrBXEGQJZI AiY5o0yzEkexhFus49E0TMuxvi91NyoHI64asdjAxIhY1Hex1GgwxIm3gtBoKahRjbiErCuvPv/ 5ekUBa3H/FNWimodFQZ60PXWAgmz8b8GKOhRDQ X-Gm-Gg: ASbGncsyh6nEyII5x3tTRsqXqj/V2wv7KNAbaVhgIvsiSWWZyZ6GXNUURjFYagDKviv QGtz4ANhJlMaQJfV1LnXCQL3FHVsbl6An6CUHSTgfLemLyJpWVIGiRYlYS2ccrzfLjy2+O/YtpY woPxk5iMeoGYXZ9b26BWnddP2naic9bh/8S3Elvxo/u9ijNq+TsLMCo6jpKramBLFPB4DkxXUbs WPPwnj/DtsW91hAbV7XMQKUKZZ0VE6gGWA6HHm2Hzu7MhF0310cFz8lgC+K7Xs6kFr2S3gIxMRz NG8OOrfDpehHIlY= X-Received: by 2002:a5d:64c3:0:b0:3a0:b84c:7dab with SMTP id ffacd0b85a97d-3a1f6421db3mr11717083f8f.4.1747076735246; Mon, 12 May 2025 12:05:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGW8Liwga4/tnsWeFSOBmclzDh3G/rvAefR3Es7wI0TZLg5k88r2e7qnWyCOrphUuQ+XwIRyw== X-Received: by 2002:a5d:64c3:0:b0:3a0:b84c:7dab with SMTP id ffacd0b85a97d-3a1f6421db3mr11717060f8f.4.1747076734867; Mon, 12 May 2025 12:05:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 04/16] modinfo: lookup compile_commands.json by object Date: Mon, 12 May 2025 21:05:12 +0200 Message-ID: <20250512190524.179419-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512190524.179419-1-pbonzini@redhat.com> References: <20250512190524.179419-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.551, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747076822350019000 Since modinfo support was added, Meson fixed several issues with extract_objects and compile_commands.json lookups can be simplified. If the lookup uses the object file as key, there is no need to use the command line to distinguish among all entries for a given source. Ninja 1.9 is required in order to produce the 'output' key in compile_commands.json; it is available in CentOS Stream 9, Debian 11, SLES 15.2, Ubuntu 20.04 and in all recent BSD distros. Samurai also has it. Cc: Gerd Hoffmann Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- meson.build | 14 ++++---------- scripts/modinfo-collect.py | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/meson.build b/meson.build index a2cebd44656..7f91500bb73 100644 --- a/meson.build +++ b/meson.build @@ -3903,16 +3903,11 @@ foreach d, list : modules install: true, install_dir: qemu_moddir) if module_ss.sources() !=3D [] - # FIXME: Should use sl.extract_all_objects(recursive: true) as - # input. Sources can be used multiple times but objects are - # unique when it comes to lookup in compile_commands.json. - # Depnds on a mesion version with - # https://github.com/mesonbuild/meson/pull/8900 modinfo_files +=3D custom_target(d + '-' + m + '.modinfo', output: d + '-' + m + '.modinfo', - input: module_ss.sources() + genh, + input: sl.extract_all_objects(recur= sive: true), capture: true, - command: [modinfo_collect, module_s= s.sources()]) + command: [modinfo_collect, '@INPUT@= ']) endif else if d =3D=3D 'block' @@ -3951,12 +3946,11 @@ foreach d, list : target_modules dependencies: target_module_ss.dependencies(), install: true, install_dir: qemu_moddir) - # FIXME: Should use sl.extract_all_objects(recursive: true) to= o. modinfo_files +=3D custom_target(module_name + '.modinfo', output: module_name + '.modinfo= ', - input: target_module_ss.sources= () + genh, + input: sl.extract_all_objects(r= ecursive: true), capture: true, - command: [modinfo_collect, '--t= arget', target, target_module_ss.sources()]) + command: [modinfo_collect, '--t= arget', target, '@INPUT@']) endif endif endforeach diff --git a/scripts/modinfo-collect.py b/scripts/modinfo-collect.py index 4e7584df667..48bd92bd618 100644 --- a/scripts/modinfo-collect.py +++ b/scripts/modinfo-collect.py @@ -7,15 +7,6 @@ import shlex import subprocess =20 -def find_command(src, target, compile_commands): - for command in compile_commands: - if command['file'] !=3D src: - continue - if target !=3D '' and command['command'].find(target) =3D=3D -1: - continue - return command['command'] - return 'false' - def process_command(src, command): skip =3D False out =3D [] @@ -43,14 +34,22 @@ def main(args): print("MODINFO_DEBUG target %s" % target) arch =3D target[:-8] # cut '-softmmu' print("MODINFO_START arch \"%s\" MODINFO_END" % arch) + with open('compile_commands.json') as f: - compile_commands =3D json.load(f) - for src in args: + compile_commands_json =3D json.load(f) + compile_commands =3D { x['output']: x for x in compile_commands_json } + + for obj in args: + entry =3D compile_commands.get(obj, None) + if not entry: + sys.stderr.print('modinfo: Could not find object file', obj) + sys.exit(1) + src =3D entry['file'] if not src.endswith('.c'): print("MODINFO_DEBUG skip %s" % src) continue + command =3D entry['command'] print("MODINFO_DEBUG src %s" % src) - command =3D find_command(src, target, compile_commands) cmdline =3D process_command(src, command) print("MODINFO_DEBUG cmd", cmdline) result =3D subprocess.run(cmdline, stdout =3D subprocess.PIPE, --=20 2.49.0