From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688862; cv=none; d=zohomail.com; s=zohoarc; b=AJLwqY5UkFEclJgN5BxtPFlmGHtCXijjFTfRdvcGeALzlWGk4aydd6Yze3Wvw1kVJ0t71hyqVKC5R3VInCxN8tpiFlZNtQn6cyAGDeQcL2/4K8oBbr5xgOk5weQ+rMXIlm6vgUlZbe/IZwyx8aB6ifwEGWEwWWorolWyHqTLEEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688862; h=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=q0jH9GG4Y9DVdkqF6zGXUYSm5Vmv2IR3Nw21G/qghzM=; b=HnbNXKVe089NN/xZl0IlG9L0niyvruQmQlDXPn6pOlQem4ucGX4qVh/WP4WTkmvKMMjGM6aYe95YaX1iTmS5Lo4EK/FGAO3xfC8vOr029sqFv4oHiKt+mKaeL/nCfECrVT4la83b16B2538z7HQ66tIszWlLduny3obBjubzkW0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688862213523.1472003820128; Fri, 15 Nov 2024 08:41:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzND-0006BF-7X; Fri, 15 Nov 2024 11:40:43 -0500 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 1tBzN7-00069s-BV for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:40:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzN5-0002IH-JW for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:40:36 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-KCK9K-OVMpSnh7tqZv_bnA-1; Fri, 15 Nov 2024 11:40:33 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43159603c92so13679235e9.2 for ; Fri, 15 Nov 2024 08:40:33 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ae31083sm4767995f8f.103.2024.11.15.08.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:40:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q0jH9GG4Y9DVdkqF6zGXUYSm5Vmv2IR3Nw21G/qghzM=; b=XEZzG78UR/GBztJBa12hl4YzDU1wkqSpTr665Diog+DMG9UN53FAnR9w+xzCk7y9gBoQFN AtDWzAgY+kn+tBhc8LiYff7unstpPND8dPiLjTuTOWdkBa38ZVqfindPd3bPvs55CofGt8 nSYXaE77nhDwu0VZDwRBynCkuK2/JGc= X-MC-Unique: KCK9K-OVMpSnh7tqZv_bnA-1 X-Mimecast-MFC-AGG-ID: KCK9K-OVMpSnh7tqZv_bnA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688827; x=1732293627; 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=q0jH9GG4Y9DVdkqF6zGXUYSm5Vmv2IR3Nw21G/qghzM=; b=eBu8XMfvEm3hiwHdsnw+bZEj9wsEB0jaQGKloBBjCc2/qzZISpM7OWSmh/0ZFSo9DP j4ieHMqf82WIlZnlCgVy/yfjI93Q8GewFJIAqz/XCj0Ci2lmgYIXRnYZYk9wmQUWAoRh VG9nDB7IlhON7TtZnVPK9I7w3fbVvqwlYKqxG/W3ETOVVAqGOGkEVKUprpe5cNG6GOYP oVUm0ceqQd+KWYZhIFgabsBsJs1HtcQ0sBK8/yF1uJ/q940P/dSUJv4IJK4nqHwbGqt0 Nntf1EyWziX4rTg1aT2bHRr2SHTAjqn848a4rVEYOWlMcjO+d+e8VqnbhXAiE1U3Ib4I sr7Q== X-Gm-Message-State: AOJu0YxFzeirfvh8zpEmD6fa8Gg21wDpexeMXTTj6ki1ZRP/LLVtwWme Pf+1FqwAEDCJU9kR/DoEjNQM9saRsldeBfKX71LqmAopwBwDTJxuI2mdpmnfuIImkL3DUZZCYMC r9geNtGqConoik8Yv9fsj4pTrXMys//XxNcDee9c/Vr8uDVkGcAQXrssx3UoRgPUVUHa7/adR0W /hjAqd/3h6K86njBFXd5FsIT7PZBUGoGDb0TJl+CY= X-Received: by 2002:a05:600c:c08:b0:432:7c08:d121 with SMTP id 5b1f17b1804b1-432df741a8bmr31015985e9.12.1731688827310; Fri, 15 Nov 2024 08:40:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBKskmKUgKodxYS6R/cBZhBf0NpqATQwq/de+/8v91CxLYcSq5FmIQyXdc0P7L+2GmjRASdA== X-Received: by 2002:a05:600c:c08:b0:432:7c08:d121 with SMTP id 5b1f17b1804b1-432df741a8bmr31015755e9.12.1731688826890; Fri, 15 Nov 2024 08:40:26 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 01/12] rust: apply --cfg MESON to all crates Date: Fri, 15 Nov 2024 17:40:14 +0100 Message-ID: <20241115164025.1917618-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H2=-0.658, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1731688863169116600 Content-Type: text/plain; charset="utf-8" We might have more uses for --cfg MESON, even though right now it's only qemu-api that has generated files. Since we're going to add more flags to the add_project_arguments calls for Rust, it makes sense to also add --cfg MESON everywhere. Signed-off-by: Paolo Bonzini --- meson.build | 7 ++++--- rust/qemu-api/meson.build | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index e0b880e4e13..a6172524287 100644 --- a/meson.build +++ b/meson.build @@ -3422,10 +3422,11 @@ if have_rust # is safe; https://github.com/rust-lang/rust/pull/54675 says that # passing -nodefaultlibs to the linker "was more ideological to # start with than anything". - add_project_arguments(rustc_args + ['-C', 'default-linker-libraries'], + add_project_arguments(rustc_args + + ['--cfg', 'MESON', '-C', 'default-linker-libraries'], native: false, language: 'rust') - - add_project_arguments(rustc_args, native: true, language: 'rust') + add_project_arguments(rustc_args + ['--cfg', 'MESON'], + native: true, language: 'rust') endif =20 hxtool =3D find_program('scripts/hxtool') diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 6f637af7b1b..cad9ac4844e 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -1,4 +1,4 @@ -_qemu_api_cfg =3D ['--cfg', 'MESON'] +_qemu_api_cfg =3D [] # _qemu_api_cfg +=3D ['--cfg', 'feature=3D"allocator"'] if rustc.version().version_compare('>=3D1.77.0') _qemu_api_cfg +=3D ['--cfg', 'has_offset_of'] --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688888; cv=none; d=zohomail.com; s=zohoarc; b=a6rNfgM4kdB18tBJQXP+GEUXZV7ErTok8xr5kjHK8OVAE3DrWXq7ItyXuJtbQgqxv29jvhdGIbHJUM1A4HG471aTyBx3p/pKW9/5G7ZI4SZG47D6qkFbvgYiOxGfTCLdceYvLEpCYMFNHTQiDLuUbqEk5U5RcJcqYHonRK458WU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688888; h=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=gxrtk5aMMaKYzRzX6De6/Aykasa/8z/jP3nArnuWvHc=; b=EJ0Xa+1sKwRA2aRrRLiESyU8V16mSjceJChkYMvDgOdlaMPQK6gbklf/9jwQIFgCZPfGaEvew34Wg2r0p8skwyyhHQKV79DApOjjKFFK7oTK6S+1VzW9YDtuSICymwx03zwnWPd8brCtHcEzHFrKqnEFbxiSYHZ/FmbvT0uFyLU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688888832823.3285615890363; Fri, 15 Nov 2024 08:41:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzNi-0006WQ-8u; Fri, 15 Nov 2024 11:41:14 -0500 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 1tBzNJ-0006Gm-2K for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:40:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzNE-0002Jk-Ls for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:40:47 -0500 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-141-93DbIRBSMXe-nVDZS_GfyA-1; Fri, 15 Nov 2024 11:40:38 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d45f1e935so1124745f8f.0 for ; Fri, 15 Nov 2024 08:40:37 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38229b6e2fasm1218830f8f.40.2024.11.15.08.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:40:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gxrtk5aMMaKYzRzX6De6/Aykasa/8z/jP3nArnuWvHc=; b=DDFuhswRhKkYvloTB5+R+6A2X8PoMZj/v0d/GfFrb0akGbIJxNdEO36w+Bwrdvsv5H2yJ/ IUm4hHFm1R1jbl/I3KB6FoSpyrOFbzXjyywmAcwW0X7KZkUOymUHGk12CFtsPT9toFj/Yt kMFNlTKu/L7c869ighz4LnP0IVPVVOA= X-MC-Unique: 93DbIRBSMXe-nVDZS_GfyA-1 X-Mimecast-MFC-AGG-ID: 93DbIRBSMXe-nVDZS_GfyA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688833; x=1732293633; 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=gxrtk5aMMaKYzRzX6De6/Aykasa/8z/jP3nArnuWvHc=; b=wAwAo19SiWv+0QI7L8YzW7GpCslO/slI/YWXVjiFOA2KmKdMt3GjKZakXBD4b57YqB TzpODUx//Bq0jTEbg3EoeGgt/diu3haaOms7pmfVrtuERPbxBX4PlLoAkJrgr6m2X6XD VcXKyLQH/m+dqZxN1FA0kJLIkRajgBFkcEP3RoSV+wBnlHff+kP1EHxgUIXusSbsxfrD 2wvtn2lFMtFQlyhYlP9B95haItL6hJf56Wzehd5FQ7AX7zKvY0J+sLdxj+ftUF7B5oPO jYCRHfuSMNgafmI7sSZpeq6ydQgli4DCMJ6ea0i2nEo/oOt45Sxv8vRbWHvZ7CWMKr6r vduA== X-Gm-Message-State: AOJu0YxFrOzZ9kEnvuAJRj6Kbv859Hu5A/mguxC1hQFjFoLpzaIqpB6y gI3nm+hd5pOcXDRIyAfZ31YoAvvVK6Ys4np2ialdD89haCoZ8+oTQcKxhqC8mE/Nx4sCTNcqF6R k8rfchKXY1nUSNWI3MkEqQU5uLUD1PJQFghNTXB1uLrTs/eysZg6K8NWyCh52FWogG8n0o8IsLQ gV/MK5lwnZ6DuHTwEadwYuFzbJ+Coi4vRxjdA9ONg= X-Received: by 2002:a05:6000:a0c:b0:382:1ade:83ee with SMTP id ffacd0b85a97d-3822590646emr2974182f8f.23.1731688832586; Fri, 15 Nov 2024 08:40:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYj3w5nuQz4f9pxFQUHSDBKEbvnUwx0bl56+NOw6uuR2PC31PB65FEaoVu9xjpUGyi33sPBA== X-Received: by 2002:a05:6000:a0c:b0:382:1ade:83ee with SMTP id ffacd0b85a97d-3822590646emr2974151f8f.23.1731688831965; Fri, 15 Nov 2024 08:40:31 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 02/12] rust: allow using build-root bindings.rs from cargo Date: Fri, 15 Nov 2024 17:40:15 +0100 Message-ID: <20241115164025.1917618-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H2=-0.658, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1731688889390116600 Content-Type: text/plain; charset="utf-8" Right now, using cargo with QEMU requires copying by hand the bindings.rs t= o the source tree. Instead, we can use an include file to escape the cage of car= go's mandated source directory structure. By running cargo within meson's "devenv" and adding a MESON_BUILD_ROOT environment variable, it is easy for build.rs to find the file. However, t= he file must be symlinked into cargo's output directory for rust-analyzer to f= ind it. Suggested-by: Junjie Mao Signed-off-by: Paolo Bonzini --- meson.build | 4 +++- rust/hw/char/pl011/.gitignore | 2 -- rust/qemu-api/.gitignore | 2 +- rust/qemu-api/README.md | 4 ++-- rust/qemu-api/build.rs | 34 +++++++++++++++++++++++++++------- rust/qemu-api/meson.build | 1 + rust/qemu-api/src/bindings.rs | 29 +++++++++++++++++++++++++++++ rust/qemu-api/src/lib.rs | 22 ---------------------- 8 files changed, 63 insertions(+), 35 deletions(-) delete mode 100644 rust/hw/char/pl011/.gitignore create mode 100644 rust/qemu-api/src/bindings.rs diff --git a/meson.build b/meson.build index a6172524287..8def5f67bb5 100644 --- a/meson.build +++ b/meson.build @@ -3,6 +3,8 @@ project('qemu', ['c'], meson_version: '>=3D1.5.0', 'b_staticpic=3Dfalse', 'stdsplit=3Dfalse', 'opti= mization=3D2', 'b_pie=3Dtrue'], version: files('VERSION')) =20 +meson.add_devenv({ 'MESON_BUILD_ROOT' : meson.project_build_root() }) + add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: = true) add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=3D= 1', 'SPEED=3Dslow']) add_test_setup('thorough', env: ['G_TEST_SLOW=3D1', 'SPEED=3Dthorough']) @@ -4090,7 +4092,7 @@ if have_rust bindings_rs =3D rust.bindgen( input: 'rust/wrapper.h', dependencies: common_ss.all_dependencies(), - output: 'bindings.rs', + output: 'bindings.inc.rs', include_directories: include_directories('.', 'include'), bindgen_version: ['>=3D0.60.0'], args: bindgen_args, diff --git a/rust/hw/char/pl011/.gitignore b/rust/hw/char/pl011/.gitignore deleted file mode 100644 index 71eaff2035d..00000000000 --- a/rust/hw/char/pl011/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore generated bindings file overrides. -src/bindings.rs.inc diff --git a/rust/qemu-api/.gitignore b/rust/qemu-api/.gitignore index b9e7e004c86..df6c2163e03 100644 --- a/rust/qemu-api/.gitignore +++ b/rust/qemu-api/.gitignore @@ -1,2 +1,2 @@ # Ignore generated bindings file overrides. -src/bindings.rs +/src/bindings.inc.rs diff --git a/rust/qemu-api/README.md b/rust/qemu-api/README.md index 7588fa29ef3..53810f48882 100644 --- a/rust/qemu-api/README.md +++ b/rust/qemu-api/README.md @@ -5,7 +5,7 @@ This library exports helper Rust types, Rust macros and C F= FI bindings for inter The C bindings can be generated with `bindgen`, using this build target: =20 ```console -$ ninja bindings.rs +$ ninja bindings.inc.rs ``` =20 ## Generate Rust documentation @@ -13,5 +13,5 @@ $ ninja bindings.rs To generate docs for this crate, including private items: =20 ```sh -cargo doc --no-deps --document-private-items +pyvenv/bin/meson devenv -w ../rust cargo doc --no-deps --document-private-= items ``` diff --git a/rust/qemu-api/build.rs b/rust/qemu-api/build.rs index 20f8f718b90..06e79082b5f 100644 --- a/rust/qemu-api/build.rs +++ b/rust/qemu-api/build.rs @@ -2,22 +2,42 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use std::path::Path; +#[cfg(unix)] +use std::os::unix::fs::symlink as symlink_file; +#[cfg(windows)] +use std::os::windows::fs::symlink_file; +use std::{env, fs::remove_file, io::Result, path::Path}; =20 use version_check as rustc; =20 -fn main() { - if !Path::new("src/bindings.rs").exists() { - panic!( - "No generated C bindings found! Either build them manually wit= h bindgen or with meson \ - (`ninja bindings.rs`) and copy them to src/bindings.rs, or bu= ild through meson." - ); +fn main() -> Result<()> { + // Placing bindings.inc.rs in the source directory is supported + // but not documented or encouraged. + let path =3D env::var("MESON_BUILD_ROOT") + .unwrap_or_else(|_| format!("{}/src", env!("CARGO_MANIFEST_DIR"))); + + let file =3D format!("{}/bindings.inc.rs", path); + let file =3D Path::new(&file); + if !Path::new(&file).exists() { + panic!(concat!( + "No generated C bindings found! If you want to run `cargo`, st= art a subshell\n", + "with `meson devenv`, or point MESON_BUILD_ROOT to the top of = the build tree." + )); } =20 + let out_dir =3D env::var("OUT_DIR").unwrap(); + let dest_path =3D format!("{}/bindings.inc.rs", out_dir); + let dest_path =3D Path::new(&dest_path); + if dest_path.symlink_metadata().is_ok() { + remove_file(dest_path)?; + } + symlink_file(file, dest_path)?; + // Check for available rustc features if rustc::is_min_version("1.77.0").unwrap_or(false) { println!("cargo:rustc-cfg=3Dhas_offset_of"); } =20 println!("cargo:rerun-if-changed=3Dbuild.rs"); + Ok(()) } diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index cad9ac4844e..3be7b7e5ced 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -9,6 +9,7 @@ _qemu_api_rs =3D static_library( structured_sources( [ 'src/lib.rs', + 'src/bindings.rs', 'src/c_str.rs', 'src/definitions.rs', 'src/device_class.rs', diff --git a/rust/qemu-api/src/bindings.rs b/rust/qemu-api/src/bindings.rs new file mode 100644 index 00000000000..0b76ec58bee --- /dev/null +++ b/rust/qemu-api/src/bindings.rs @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#![allow( + dead_code, + improper_ctypes_definitions, + improper_ctypes, + non_camel_case_types, + non_snake_case, + non_upper_case_globals, + unsafe_op_in_unsafe_fn, + clippy::missing_const_for_fn, + clippy::too_many_arguments, + clippy::approx_constant, + clippy::use_self, + clippy::useless_transmute, + clippy::missing_safety_doc +)] + +#[cfg(MESON)] +include!("bindings.inc.rs"); + +#[cfg(not(MESON))] +include!(concat!(env!("OUT_DIR"), "/bindings.inc.rs")); + +unsafe impl Send for Property {} +unsafe impl Sync for Property {} +unsafe impl Sync for TypeInfo {} +unsafe impl Sync for VMStateDescription {} +unsafe impl Sync for VMStateField {} +unsafe impl Sync for VMStateInfo {} diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index aa8d16ec94b..440aff3817d 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -4,31 +4,9 @@ =20 #![cfg_attr(not(MESON), doc =3D include_str!("../README.md"))] =20 -#[allow( - dead_code, - improper_ctypes_definitions, - improper_ctypes, - non_camel_case_types, - non_snake_case, - non_upper_case_globals, - unsafe_op_in_unsafe_fn, - clippy::missing_const_for_fn, - clippy::too_many_arguments, - clippy::approx_constant, - clippy::use_self, - clippy::useless_transmute, - clippy::missing_safety_doc, -)] #[rustfmt::skip] pub mod bindings; =20 -unsafe impl Send for bindings::Property {} -unsafe impl Sync for bindings::Property {} -unsafe impl Sync for bindings::TypeInfo {} -unsafe impl Sync for bindings::VMStateDescription {} -unsafe impl Sync for bindings::VMStateField {} -unsafe impl Sync for bindings::VMStateInfo {} - pub mod c_str; pub mod definitions; pub mod device_class; --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688909; cv=none; d=zohomail.com; s=zohoarc; b=RfBewTtBW94BSCbteF8hHNQ1Vq/MnOjAum2P5uwryrz4gCiy/oxgXf7PmyiybhRDsZtSNgfRiNP/t39FnAhVBi0jP5Obtex0pJMHCPOMOcv+xxsMM7b0SAm1JxecYWxX9VZ90lUHKd/AK2fXz2wDQDGldifhdJtU+hfi8HwxHTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688909; h=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=HbWA/NqYdtTCVn8KZ9HlSCULmXdgsjBOnjTg7LOXBL8=; b=e9K5PhAh9WogiBUahPX4SZric7FZ5DGOs7WTpDgyzbQfOach2Bk88TkSPSyv59OZnn/kTbwHy3F8rJBlMNGq3zP/FHi6Q17d6p9OaQXbY/sAy3rXbHHl9Ha/2vruKgwl4RbDz5vdD4acKRh3VtX6lDkFToDAxwNpb7dDMVziPis= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688909931382.4433839612351; Fri, 15 Nov 2024 08:41:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzNk-0006Ys-Nr; Fri, 15 Nov 2024 11:41:19 -0500 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 1tBzNF-0006Er-7i for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:40:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzND-0002Jd-Ex for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:40:45 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-WumHOI_KM_mF-tzcfL1nAg-1; Fri, 15 Nov 2024 11:40:40 -0500 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d531a19a9so531979f8f.1 for ; Fri, 15 Nov 2024 08:40:40 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ae3101fsm4751409f8f.92.2024.11.15.08.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:40:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HbWA/NqYdtTCVn8KZ9HlSCULmXdgsjBOnjTg7LOXBL8=; b=LMqKWAB+cyXZxy8qpAOqrnXAEjeilqqJ7cvzNohogatgggtU7oLQ4m+jmkWMUaIVHLseF9 /KslMAAsGdO5+a7mveJ36qq6wULnBnpqshnxzQlFzltP1sPWe8osd6n35tOu1qJpaRKxcm 5lGL5yYQzlq2s2nQe9/XKtpAaMd8BbA= X-MC-Unique: WumHOI_KM_mF-tzcfL1nAg-1 X-Mimecast-MFC-AGG-ID: WumHOI_KM_mF-tzcfL1nAg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688838; x=1732293638; 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=HbWA/NqYdtTCVn8KZ9HlSCULmXdgsjBOnjTg7LOXBL8=; b=ZdCXMrgDwqyEPZlBCxilu1KDOdTEqa3t9Vv/b14wHNKOiC/4bvnGieHUGF5v12oy7w plbeS/z4SqRwSXdB8dp81hnaoWuIgYeVIPpt/93Tm7tf5D0U9WAkFcpJQ34zj1c70DzC VOKTgyu6KJR5b07DZ/W17YH/4JOMzU8+5au+BToLOWyrSg7OzxW6U53eGmkWGDCeCtOJ 0rf3a/5oKOORWPDypU7I+LAImGyHq+J5j8o1FJIuZFSI9Yzd3agdExh+UmTbNyhiSJ0Q SYbZG0xJS416Yo8jWSFnLioMU/mLdn2aQ6BEmKQNFNXb3w+CElJZr5omzxRTLgvd3YLv 9nTw== X-Gm-Message-State: AOJu0YzLhK/ZOpNNcSUu3weEVkBwX98YtzWs91WP3xv3L8P0fEkZCoLh Kz44PZpQ2xla/mpIJSHGTG1MwxitbsZ7NpyqsDmwiqR8lCHUjvL3rpvxRhUaDPi45WOzdZ3G+44 UoWlkKRi4XRfFy8TSIjThkHqXEARpKJivq9nzNkcDBVSK82qZAkgA3LLM61VrbdMnvayaKtYodB gPc3XqdDwE3D3Hh7HTjgu+opFJ0+KVTvl1pwrt6SE= X-Received: by 2002:a5d:5988:0:b0:37c:cc67:8b1f with SMTP id ffacd0b85a97d-38225aaef32mr2844830f8f.48.1731688838395; Fri, 15 Nov 2024 08:40:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOggsLwRV/smU53pSVTKPtU3W4+VGJ3TX8Z5EHHjcW70P0zNZljTV0CQojkcMUM/6/O0moWg== X-Received: by 2002:a5d:5988:0:b0:37c:cc67:8b1f with SMTP id ffacd0b85a97d-38225aaef32mr2844805f8f.48.1731688837987; Fri, 15 Nov 2024 08:40:37 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 03/12] rust: build: move rustc_args.py invocation to qemu-api crate Date: Fri, 15 Nov 2024 17:40:16 +0100 Message-ID: <20241115164025.1917618-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H2=-0.658, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1731688911613116600 Content-Type: text/plain; charset="utf-8" Only qemu-api needs access to the symbols in config-host.h. Remove the temptation to use them elsewhere by limiting the --cfg arguments to the qemu-api crate. Per-crate invocation of the script will also be needed to add --check-cfg options for each crate's features (when more complex, build-time configurable devices are added in the future). Signed-off-by: Paolo Bonzini --- meson.build | 56 +++++++++++++++++---------------------- rust/qemu-api/meson.build | 5 +++- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/meson.build b/meson.build index 8def5f67bb5..b51add16d2f 100644 --- a/meson.build +++ b/meson.build @@ -120,7 +120,30 @@ if have_rust endif =20 if have_rust + rustc_args =3D find_program('scripts/rust/rustc_args.py') rustfmt =3D find_program('rustfmt', required: false) + + # Prohibit code that is forbidden in Rust 2024 + rustc_lint_args =3D ['-D', 'unsafe_op_in_unsafe_fn'] + + # Occasionally, we may need to silence warnings and clippy lints that + # were only introduced in newer Rust compiler versions. Do not croak + # in that case; a CI job with rust_strict_lints =3D=3D true ensures that + # we do not have misspelled allow() attributes. + if not get_option('strict_rust_lints') + rustc_lint_args +=3D ['-A', 'unknown_lints'] + endif + + # Apart from procedural macros, our Rust executables will often link + # with C code, so include all the libraries that C code needs. This + # is safe; https://github.com/rust-lang/rust/pull/54675 says that + # passing -nodefaultlibs to the linker "was more ideological to + # start with than anything". + add_project_arguments(rustc_lint_args + + ['--cfg', 'MESON', '-C', 'default-linker-libraries'], + native: false, language: 'rust') + add_project_arguments(rustc_lint_args + ['--cfg', 'MESON'], + native: true, language: 'rust') endif =20 dtrace =3D not_found @@ -3399,37 +3422,8 @@ endif # Generated sources # ##################### =20 -genh +=3D configure_file(output: 'config-host.h', configuration: config_ho= st_data) - -if have_rust - rustc_args =3D run_command( - find_program('scripts/rust/rustc_args.py'), - '--config-headers', meson.project_build_root() / 'config-host.h', - capture : true, - check: true).stdout().strip().split() - - # Prohibit code that is forbidden in Rust 2024 - rustc_args +=3D ['-D', 'unsafe_op_in_unsafe_fn'] - - # Occasionally, we may need to silence warnings and clippy lints that - # were only introduced in newer Rust compiler versions. Do not croak - # in that case; a CI job with rust_strict_lints =3D=3D true ensures that - # we do not have misspelled allow() attributes. - if not get_option('strict_rust_lints') - rustc_args +=3D ['-A', 'unknown_lints'] - endif - - # Apart from procedural macros, our Rust executables will often link - # with C code, so include all the libraries that C code needs. This - # is safe; https://github.com/rust-lang/rust/pull/54675 says that - # passing -nodefaultlibs to the linker "was more ideological to - # start with than anything". - add_project_arguments(rustc_args + - ['--cfg', 'MESON', '-C', 'default-linker-libraries'], - native: false, language: 'rust') - add_project_arguments(rustc_args + ['--cfg', 'MESON'], - native: true, language: 'rust') -endif +config_host_h =3D configure_file(output: 'config-host.h', configuration: c= onfig_host_data) +genh +=3D config_host_h =20 hxtool =3D find_program('scripts/hxtool') shaderinclude =3D find_program('scripts/shaderinclude.py') diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 3be7b7e5ced..5df6b35bf88 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -1,4 +1,7 @@ -_qemu_api_cfg =3D [] +_qemu_api_cfg =3D run_command(rustc_args, + '--config-headers', config_host_h, + capture: true, check: true).stdout().strip().split() + # _qemu_api_cfg +=3D ['--cfg', 'feature=3D"allocator"'] if rustc.version().version_compare('>=3D1.77.0') _qemu_api_cfg +=3D ['--cfg', 'has_offset_of'] --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688955; cv=none; d=zohomail.com; s=zohoarc; b=LMn/+OMT9IHXyLdrsDYoNIRT6fNv+tS98L4828UIa9MgL/3qggWeZaFrshBe6pGpTeawZwHikZrw8S0EWFnNcaEUgDr9GU1YjusDyi6jpFp8Qme5QeN+2Ilk59z7pkXUcwDBYPXixKAvHVvYbUjn2S5Tyh4691Sj/CQooHSUJo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688955; h=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=ttI9dVImUyRrjtz3o3qxzgGlyU5nv6rQoiRqrRQPUqI=; b=Sfm/d7273px7UOikON2gqs4HM18UnBhntbTDw6r//ws293qVbfiX5K6Ezz06r41ivhzd4vIBJ7+Qf/RKFq/Lfh+PeSIYCRAO7BDTYodJKbi9zZHAqrWgAUEH77aKDkfQpwBIVC6iIP9OfUNlnHoepZ4KcVQBD1yU9ShAu9v2qog= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688955338657.2309979695335; Fri, 15 Nov 2024 08:42:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzOE-0006z4-HK; Fri, 15 Nov 2024 11:41:46 -0500 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 1tBzNK-0006Gz-Rx for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:40:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzNH-0002KJ-Jy for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:40:50 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-tRQXkvEXPZer5Vwt0Lu6yA-1; Fri, 15 Nov 2024 11:40:45 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43152cd2843so12849545e9.3 for ; Fri, 15 Nov 2024 08:40:45 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ae161b5sm4892018f8f.74.2024.11.15.08.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ttI9dVImUyRrjtz3o3qxzgGlyU5nv6rQoiRqrRQPUqI=; b=Tco+8VUjf0H7VPgH++n/1gOrQLHht+3brHcLmveeTKx1QD6nqPfCh7CcgakS5pkNqd4Cuk dNiFTuj7ozoEkzevDY+faEI6qw7jL1kR44KrzaWmrd8mj7b2e2f82PmIe09AQn0QZxeImz PDN5hlySd6kqXtgrNPuSN9zgB1J1mQs= X-MC-Unique: tRQXkvEXPZer5Vwt0Lu6yA-1 X-Mimecast-MFC-AGG-ID: tRQXkvEXPZer5Vwt0Lu6yA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688842; x=1732293642; 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=ttI9dVImUyRrjtz3o3qxzgGlyU5nv6rQoiRqrRQPUqI=; b=EWoC5mp0MPbL0QEHE/CAcDGmbc4jHTGik9yx+bnhca2dlg+hk0xlWGX5n11dNSRiPF P5jUWbm28lEKOMwe8P9qbJDlgNjcy1lSTz3e5ilMNW9r6I7AvmhVvYO9UbJGXkv2ESCD af9Gud+KOmAbDRY+1ssX4jST0lq4MJT+swcbtUWHwNh6QEkjH9wyKHYExPHSjkJlDtRE 3/FWQ3HbvmWy3mjHres6Ec18EpW5gJpAMeBT8NEg+jd5WvWVj/NMvDlvv0GzLq1pk+LV U2j/QJROowdK4GhXOpiqgfcjwO3zi5ZHSOB22TGKMGzaPphFxq3z0YTsOTC+zICqZ19x e03Q== X-Gm-Message-State: AOJu0Yzygsr9Q/db8WcX5pnQ2/qY2QBAan10QFGZd1Q+G3IuGO6q9CHq 5v4IADwxdtEID/RDeTcZZw5GNtainRxrqINRBe1r+KfjhFJzPdb6CMa9tQup+mxQC6+oM5FncHt JexRf/bKy2zZPWWSRhHNWjyzjqAYEgeoG2bx1Il0wCOLTo/gGJswmz6Ya1g7WszUV/gwuQC1SLB MwRXHx6iH8KAxrKoNm0N0Rss7kfB+6OZ4oQPV1GrU= X-Received: by 2002:a5d:6c69:0:b0:382:6f3:a20f with SMTP id ffacd0b85a97d-382258f4d91mr3050996f8f.11.1731688842431; Fri, 15 Nov 2024 08:40:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbjPKT/LMKZ/4JwGWK8XBEKmjP6sXHXYpuanOi9qYVQTOTzGhPffo+TjZ9fjygxVLjVnZeog== X-Received: by 2002:a5d:6c69:0:b0:382:6f3:a20f with SMTP id ffacd0b85a97d-382258f4d91mr3050970f8f.11.1731688841992; Fri, 15 Nov 2024 08:40:41 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 04/12] rust: build: restrict --cfg generation to only required symbols Date: Fri, 15 Nov 2024 17:40:17 +0100 Message-ID: <20241115164025.1917618-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H2=-0.658, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1731688955659116600 Content-Type: text/plain; charset="utf-8" Parse the Cargo.toml file, looking for the unexpected_cfgs configuration. When generating --cfg options from the config-host.h file, only use those that are included in the configuration. Signed-off-by: Paolo Bonzini --- rust/qemu-api/meson.build | 2 +- scripts/rust/rustc_args.py | 61 ++++++++++++++++++++++++++++---------- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 5df6b35bf88..2ff6d2ce3d0 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -1,5 +1,5 @@ _qemu_api_cfg =3D run_command(rustc_args, - '--config-headers', config_host_h, + '--config-headers', config_host_h, files('Cargo.toml'), capture: true, check: true).stdout().strip().split() =20 # _qemu_api_cfg +=3D ['--cfg', 'feature=3D"allocator"'] diff --git a/scripts/rust/rustc_args.py b/scripts/rust/rustc_args.py index e4cc9720e16..942dd2b2bab 100644 --- a/scripts/rust/rustc_args.py +++ b/scripts/rust/rustc_args.py @@ -26,30 +26,51 @@ =20 import argparse import logging +from pathlib import Path +from typing import Any, Iterable, Mapping, Optional, Set =20 -from typing import List +try: + import tomllib +except ImportError: + import tomli as tomllib =20 =20 -def generate_cfg_flags(header: str) -> List[str]: +class CargoTOML: + tomldata: Mapping[Any, Any] + check_cfg: Set[str] + + def __init__(self, path: str): + with open(path, 'rb') as f: + self.tomldata =3D tomllib.load(f) + + self.check_cfg =3D set(self.find_check_cfg()) + + def find_check_cfg(self) -> Iterable[str]: + toml_lints =3D self.lints + rust_lints =3D toml_lints.get("rust", {}) + cfg_lint =3D rust_lints.get("unexpected_cfgs", {}) + return cfg_lint.get("check-cfg", []) + + @property + def lints(self) -> Mapping[Any, Any]: + return self.get_table("lints") + + def get_table(self, key: str) -> Mapping[Any, Any]: + table =3D self.tomldata.get(key, {}) + + return table + + +def generate_cfg_flags(header: str, cargo_toml: CargoTOML) -> Iterable[str= ]: """Converts defines from config[..].h headers to rustc --cfg flags.""" =20 - def cfg_name(name: str) -> str: - """Filter function for C #defines""" - if ( - name.startswith("CONFIG_") - or name.startswith("TARGET_") - or name.startswith("HAVE_") - ): - return name - return "" - with open(header, encoding=3D"utf-8") as cfg: config =3D [l.split()[1:] for l in cfg if l.startswith("#define")] =20 cfg_list =3D [] for cfg in config: - name =3D cfg_name(cfg[0]) - if not name: + name =3D cfg[0] + if f'cfg({name})' not in cargo_toml.check_cfg: continue if len(cfg) >=3D 2 and cfg[1] !=3D "1": continue @@ -59,7 +80,6 @@ def cfg_name(name: str) -> str: =20 =20 def main() -> None: - # pylint: disable=3Dmissing-function-docstring parser =3D argparse.ArgumentParser() parser.add_argument("-v", "--verbose", action=3D"store_true") parser.add_argument( @@ -71,12 +91,21 @@ def main() -> None: required=3DFalse, default=3D[], ) + parser.add_argument( + metavar=3D"TOML_FILE", + action=3D"store", + dest=3D"cargo_toml", + help=3D"path to Cargo.toml file", + ) args =3D parser.parse_args() if args.verbose: logging.basicConfig(level=3Dlogging.DEBUG) logging.debug("args: %s", args) + + cargo_toml =3D CargoTOML(args.cargo_toml) + for header in args.config_headers: - for tok in generate_cfg_flags(header): + for tok in generate_cfg_flags(header, cargo_toml): print(tok) =20 =20 --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688964; cv=none; d=zohomail.com; s=zohoarc; b=Knwp+RPcTHNVoEh3HmzMQEyGUx1ZExtQOm/cKu7ATbuWRmzHTJeza5062dVK+vgnBhLRaJ9tgd43mXwfK+/ozSZhadylocyaQgzZRNR1ccGk/5N06WCaI9OqWPp12ODFT6SyJcpnob7tV+FRWQjPjmN50ocGmdGh2AturfRPf8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688964; h=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=vkYYZlCmzff3dR5RmcXgSbe21mI5H667ZMFVY4crkxI=; b=Lsupa7BJnyJddpzHWHJdD9iO2VFwfxhaGzbCTcVfFEqMA2Bijo4lhec+8/uVJmwsmz4fwmQYr7swccqZDTym7EnphAvDoJs7OEr12FeOCdD5Gyk54zR27KysicSD/I3/YKq7crgp7Vg0sGntGisBNOL5YtRf25QUhMoGqCN74+8= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688964936728.8853585094661; Fri, 15 Nov 2024 08:42:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzOG-0007EE-NK; Fri, 15 Nov 2024 11:41:49 -0500 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 1tBzNQ-0006IX-Sv for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzNO-0002L4-Sq for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:40:56 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-ApDuHmALPSGnD11lKH7Fyg-1; Fri, 15 Nov 2024 11:40:51 -0500 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-38218576e86so1104947f8f.0 for ; Fri, 15 Nov 2024 08:40:51 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821adadba4sm4761340f8f.24.2024.11.15.08.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:40:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vkYYZlCmzff3dR5RmcXgSbe21mI5H667ZMFVY4crkxI=; b=fvCNor6Eea/mOPe115GSYiicog4vgYKBsG/DAJ5fBMHIXPBy+SWzQ8P1RQhbhgN8OBvT6i rv6axhjnb8Ie1x13UW9D/FB1ZhdleDZLGJn9IM9XX173AVg/j9ogy24JKLt7EyXNKHcaQs jx/dCTpI4L02AI1RTryb9TO1qRvAcVU= X-MC-Unique: ApDuHmALPSGnD11lKH7Fyg-1 X-Mimecast-MFC-AGG-ID: ApDuHmALPSGnD11lKH7Fyg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688846; x=1732293646; 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=vkYYZlCmzff3dR5RmcXgSbe21mI5H667ZMFVY4crkxI=; b=VtMcPAQ+Wf3OYiuu2uzMjxCMEhxOiAQ116JA5XYf1K6YELHUSet83UhNMhQ2s/5GuA cCktfyZCoT2zwVZqKk8rz20cDr4nkNH38cqvr/o9onfTw6jsKElvs40GSAhVc2PPmTM2 CEpS0N7o3P2C0aWKZlpTSjN7aW8TRAH19gQjbiy632+Tyv+9i/khNwTZMZZWQ1SJ7d2F OP9Tu0od/H31cqVkIDEBpI7lGXq+XELGIihj1xMjPd73u+Vpmv/P/x9aPpzJnG+538nr 9F0xnykhV/HB/WdELFt87ZpycpZ44MklhdFDjkYSToUtiYm3GcLB1zkrJi+zHUo//WRl ttxw== X-Gm-Message-State: AOJu0Yz7vuJ2HSts/GX+4QuSuCIRGeTLLAj+zk4DyI+RJ1eDDn0xTaQL ZQpw+wUgx1w36w+JRp8QDoVS2mBcB2FVl+ryvoGQR72+yJtmpRfFASi137jsPsHRGXa2ubxiB1C a0Y3mTPi0MAqqqLM/ROsPxMXd0NFLD4g7nGqLy3VBqcXpdmVwb/+vtz1T2HwdbjjKsIPWDG1zY/ 5cyXy64xqjyFikPnJ7dA3XNk0t/s7xNi1JYzXxczc= X-Received: by 2002:a5d:59a2:0:b0:37d:47ef:17d0 with SMTP id ffacd0b85a97d-38224f861c6mr3489514f8f.13.1731688846609; Fri, 15 Nov 2024 08:40:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWJyVNk4KS0t+9VWpoN0zr6vN/lTUh+y464BFJtsL/8dWi4V2mO1PcZFai8U/PcM0V3yvhYA== X-Received: by 2002:a5d:59a2:0:b0:37d:47ef:17d0 with SMTP id ffacd0b85a97d-38224f861c6mr3489482f8f.13.1731688846161; Fri, 15 Nov 2024 08:40:46 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 05/12] rust: build: generate lint flags from Cargo.toml Date: Fri, 15 Nov 2024 17:40:18 +0100 Message-ID: <20241115164025.1917618-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H2=-0.658, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1731688965608116600 Content-Type: text/plain; charset="utf-8" Cargo.toml makes it possible to describe the desired lint level settings in a nice format. We can extend this to Meson-built crates, by teaching rustc_args.py to fetch lint and --check-cfg arguments from Cargo.toml. --check-cfg arguments come from the unexpected_cfgs lint as well as crate features Start with qemu-api, since it already has a [lints.rust] table and an invocation of rustc_args.py. Signed-off-by: Paolo Bonzini --- meson.build | 3 +- rust/qemu-api/meson.build | 4 +- scripts/rust/rustc_args.py | 83 +++++++++++++++++++++++++++++++++++++- 3 files changed, 86 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index b51add16d2f..231fccf3928 100644 --- a/meson.build +++ b/meson.build @@ -120,7 +120,8 @@ if have_rust endif =20 if have_rust - rustc_args =3D find_program('scripts/rust/rustc_args.py') + rustc_args =3D [find_program('scripts/rust/rustc_args.py'), + '--rustc-version', rustc.version()] rustfmt =3D find_program('rustfmt', required: false) =20 # Prohibit code that is forbidden in Rust 2024 diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 2ff6d2ce3d0..1ed79672cc9 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -1,6 +1,6 @@ _qemu_api_cfg =3D run_command(rustc_args, - '--config-headers', config_host_h, files('Cargo.toml'), - capture: true, check: true).stdout().strip().split() + '--config-headers', config_host_h, '--features', '--lints', files('Cargo= .toml'), + capture: true, check: true).stdout().strip().splitlines() =20 # _qemu_api_cfg +=3D ['--cfg', 'feature=3D"allocator"'] if rustc.version().version_compare('>=3D1.77.0') diff --git a/scripts/rust/rustc_args.py b/scripts/rust/rustc_args.py index 942dd2b2bab..9b9778a1cac 100644 --- a/scripts/rust/rustc_args.py +++ b/scripts/rust/rustc_args.py @@ -25,9 +25,10 @@ """ =20 import argparse +from dataclasses import dataclass import logging from pathlib import Path -from typing import Any, Iterable, Mapping, Optional, Set +from typing import Any, Iterable, List, Mapping, Optional, Set =20 try: import tomllib @@ -61,6 +62,45 @@ def get_table(self, key: str) -> Mapping[Any, Any]: return table =20 =20 +@dataclass +class LintFlag: + flags: List[str] + priority: int + + +def generate_lint_flags(cargo_toml: CargoTOML) -> Iterable[str]: + """Converts Cargo.toml lints to rustc -A/-D/-F/-W flags.""" + + toml_lints =3D cargo_toml.lints + + lint_list =3D [] + for k, v in toml_lints.items(): + prefix =3D "" if k =3D=3D "rust" else k + "::" + for lint, data in v.items(): + level =3D data if isinstance(data, str) else data["level"] + priority =3D 0 if isinstance(data, str) else data.get("priorit= y", 0) + if level =3D=3D "deny": + flag =3D "-D" + elif level =3D=3D "allow": + flag =3D "-A" + elif level =3D=3D "warn": + flag =3D "-W" + elif level =3D=3D "forbid": + flag =3D "-F" + else: + raise Exception(f"invalid level {level} for {prefix}{lint}= ") + + # This may change if QEMU ever invokes clippy-driver or rustdo= c by + # hand. For now, check the syntax but do not add non-rustc li= nts to + # the command line. + if k =3D=3D "rust": + lint_list.append(LintFlag(flags=3D[flag, prefix + lint], p= riority=3Dpriority)) + + lint_list.sort(key=3Dlambda x: x.priority) + for lint in lint_list: + yield from lint.flags + + def generate_cfg_flags(header: str, cargo_toml: CargoTOML) -> Iterable[str= ]: """Converts defines from config[..].h headers to rustc --cfg flags.""" =20 @@ -97,13 +137,54 @@ def main() -> None: dest=3D"cargo_toml", help=3D"path to Cargo.toml file", ) + parser.add_argument( + "--features", + action=3D"store_true", + dest=3D"features", + help=3D"generate --check-cfg arguments for features", + required=3DFalse, + default=3DNone, + ) + parser.add_argument( + "--lints", + action=3D"store_true", + dest=3D"lints", + help=3D"generate arguments from [lints] table", + required=3DFalse, + default=3DNone, + ) + parser.add_argument( + "--rustc-version", + metavar=3D"VERSION", + dest=3D"rustc_version", + action=3D"store", + help=3D"version of rustc", + required=3DFalse, + default=3D"1.0.0", + ) args =3D parser.parse_args() if args.verbose: logging.basicConfig(level=3Dlogging.DEBUG) logging.debug("args: %s", args) =20 + rustc_version =3D tuple((int(x) for x in args.rustc_version.split('.')= [0:2])) cargo_toml =3D CargoTOML(args.cargo_toml) =20 + if args.lints: + for tok in generate_lint_flags(cargo_toml): + print(tok) + + if rustc_version >=3D (1, 80): + if args.lints: + for cfg in sorted(cargo_toml.check_cfg): + print("--check-cfg") + print(cfg) + if args.features: + for feature in cargo_toml.get_table("features"): + if feature !=3D "default": + print("--check-cfg") + print(f'cfg(feature,values("{feature}"))') + for header in args.config_headers: for tok in generate_cfg_flags(header, cargo_toml): print(tok) --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688927; cv=none; d=zohomail.com; s=zohoarc; b=furTJgxPhgZmLXgxEc/30faCG5Rvlpa3kKljTz2b0VbWCbmgNVevA5Sig50+g3yOE+JiRfXcg2nOq93N/v8p5P4c/oF3lbk+whaQOwOMqytjWzN9n5Q3KuT3ufAlCQOy4Nh2SRDtwym8l9SwN7ykZOpDiNo9uFHsEXHIEctQ6I4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688927; h=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=lbZfDGVI8qqVsTKqZdaFZ6xvk03TszV2nYSfM9yNsD8=; b=agQSJho6PrBJNDdKZ7izMt6K63+XQsid0MoCHzwRpt5vm3TcmznGamLKJwedZ5yKtJSWA6e0ULzHP/8TwKsk6N94tc5y9NKEG+W5vvee4zwy4oUianMnjOBe5ZmC23p5itdWcKbu2TCvsxmnc9rmjLefmYYsDPLJah5/G+E7T3A= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688927966751.4245343423974; Fri, 15 Nov 2024 08:42:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzOB-0006tA-Jo; Fri, 15 Nov 2024 11:41:45 -0500 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 1tBzNV-0006Kk-RL for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:06 -0500 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 1tBzNS-0002LQ-RP for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:00 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-246-otmxhjtqPTKXdRFs8CmPRQ-1; Fri, 15 Nov 2024 11:40:55 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43163a40ee0so13295095e9.0 for ; Fri, 15 Nov 2024 08:40:55 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432da29ffe9sm63379635e9.44.2024.11.15.08.40.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:40:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lbZfDGVI8qqVsTKqZdaFZ6xvk03TszV2nYSfM9yNsD8=; b=ViKvGUQTsDW7VN7OSjVo/8XUB+q9Sf4HwJxA7127/xmPV+fT6emnZj7raLBKzreHwoctH6 1LAyG75m0V5RFhYe6WIP4ZfSJT3PJnbypZCwR0mYc6z9r1bfp6Xh7HF10uy0Jc2vZUTrpI zZIRg7K3+4vuKiG8VLfv3S2f3jEcLT8= X-MC-Unique: otmxhjtqPTKXdRFs8CmPRQ-1 X-Mimecast-MFC-AGG-ID: otmxhjtqPTKXdRFs8CmPRQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688852; x=1732293652; 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=lbZfDGVI8qqVsTKqZdaFZ6xvk03TszV2nYSfM9yNsD8=; b=GAPDz7Mqi2s/CBR8lAGhpUrcrBZjlKzb1IcIyMsoTtqib6MTOP3Ua91N79vjLM52cy gOeaja/w1byqFUsFK3QuxOh1+yt//t2L2GQWtlrEgzlweV+LqptXS7G5E96P0E3TUo5r OSz0cfUK9DZ8ay7acieF0XNus5bbX+5+rICmzCippWEqxFQue7u2/5CaPQlhqPk9COtZ TfttJaHhTlVf0gBOrkI3/njVFK5AxXEkWKzKRh3JqCTnmW76PkRJ/A6iLDqJGwF7MS6L DMRdkXZIhE3IUghYE3C6NQtaKWNfJ8oeAbV+9OrTAYeLnmAlvZKPff+JI6IKeEiMbX+E Nvsw== X-Gm-Message-State: AOJu0Yxk9HDULAOMxz1umntGiedwjWcGdoUzooAj7YN4nLfpyNA6eR/g vEH1CZBhf3GNvGSfAna45zhmwGTcv46aDOqn9llS5s9Ikt7AYtADutVqU244rdkB5UbK9RAUCW9 LS737tRCCOt2Mfg3fP7KAsxYO1Dq0bKW3NZSfdlQHxRb2OZmxVzJgJdmlD+xvMHFrn5pqjuUPeh I82M3Up3FyABmRx/LFGpZaBfLi7IEgluCCErAmagU= X-Received: by 2002:a05:600c:cc4:b0:431:40ca:ce6e with SMTP id 5b1f17b1804b1-432df791da4mr29207125e9.31.1731688852289; Fri, 15 Nov 2024 08:40:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPE235lKKtHkSitgD1Vq1+M6hakvsORC3AamjxpSikVwAiPuc+b+sSHNLkap53hOKc5FZPrQ== X-Received: by 2002:a05:600c:cc4:b0:431:40ca:ce6e with SMTP id 5b1f17b1804b1-432df791da4mr29206865e9.31.1731688851849; Fri, 15 Nov 2024 08:40:51 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 06/12] rust: cargo: store desired warning levels in workspace Cargo.toml Date: Fri, 15 Nov 2024 17:40:19 +0100 Message-ID: <20241115164025.1917618-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1731688929507116600 Content-Type: text/plain; charset="utf-8" An extra benefit of workspaces is that they allow to place lint level settings in a single Cargo.toml; the settings are then inherited by packages in the workspace. Correspondingly, teach rustc_args.py to get the unexpected_cfgs configuration from the workspace Cargo.toml. Note that it is still possible to allow or deny warnings per crate or module, via the #![] attribute syntax. The rust/qemu-api/src/bindings.rs file is an example. Signed-off-by: Paolo Bonzini --- meson.build | 7 +++--- rust/Cargo.toml | 8 +++++++ rust/hw/char/pl011/Cargo.toml | 3 +++ rust/qemu-api-macros/Cargo.toml | 3 +++ rust/qemu-api/Cargo.toml | 5 ++--- rust/qemu-api/meson.build | 2 +- scripts/rust/rustc_args.py | 38 +++++++++++++++++++++++++++------ 7 files changed, 53 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index 231fccf3928..21e2a332d6c 100644 --- a/meson.build +++ b/meson.build @@ -121,11 +121,12 @@ endif =20 if have_rust rustc_args =3D [find_program('scripts/rust/rustc_args.py'), - '--rustc-version', rustc.version()] + '--rustc-version', rustc.version(), + '--workspace', meson.project_source_root() / 'rust'] rustfmt =3D find_program('rustfmt', required: false) =20 - # Prohibit code that is forbidden in Rust 2024 - rustc_lint_args =3D ['-D', 'unsafe_op_in_unsafe_fn'] + rustc_lint_args =3D run_command(rustc_args, '--lints', + capture: true, check: true).stdout().strip().splitlines() =20 # Occasionally, we may need to silence warnings and clippy lints that # were only introduced in newer Rust compiler versions. Do not croak diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 0c94d5037da..4bb52bf0bd5 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -5,3 +5,11 @@ members =3D [ "qemu-api", "hw/char/pl011", ] + +[workspace.lints.rust] +unexpected_cfgs =3D { level =3D "deny", check-cfg =3D [ + 'cfg(MESON)', 'cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)', + 'cfg(has_offset_of)'] } + +# Prohibit code that is forbidden in Rust 2024 +unsafe_op_in_unsafe_fn =3D "deny" diff --git a/rust/hw/char/pl011/Cargo.toml b/rust/hw/char/pl011/Cargo.toml index a373906b9fb..58f3e859f7e 100644 --- a/rust/hw/char/pl011/Cargo.toml +++ b/rust/hw/char/pl011/Cargo.toml @@ -21,3 +21,6 @@ bilge =3D { version =3D "0.2.0" } bilge-impl =3D { version =3D "0.2.0" } qemu_api =3D { path =3D "../../../qemu-api" } qemu_api_macros =3D { path =3D "../../../qemu-api-macros" } + +[lints] +workspace =3D true diff --git a/rust/qemu-api-macros/Cargo.toml b/rust/qemu-api-macros/Cargo.t= oml index a8f7377106b..5a27b52ee6e 100644 --- a/rust/qemu-api-macros/Cargo.toml +++ b/rust/qemu-api-macros/Cargo.toml @@ -20,3 +20,6 @@ proc-macro =3D true proc-macro2 =3D "1" quote =3D "1" syn =3D { version =3D "2", features =3D ["extra-traits"] } + +[lints] +workspace =3D true diff --git a/rust/qemu-api/Cargo.toml b/rust/qemu-api/Cargo.toml index cc716d75d46..669f288d1cb 100644 --- a/rust/qemu-api/Cargo.toml +++ b/rust/qemu-api/Cargo.toml @@ -23,6 +23,5 @@ version_check =3D "~0.9" default =3D [] allocator =3D [] =20 -[lints.rust] -unexpected_cfgs =3D { level =3D "warn", check-cfg =3D ['cfg(MESON)', 'cfg(= HAVE_GLIB_WITH_ALIGNED_ALLOC)', - 'cfg(has_offset_of)'] } +[lints] +workspace =3D true diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 1ed79672cc9..d719c13f46d 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -1,5 +1,5 @@ _qemu_api_cfg =3D run_command(rustc_args, - '--config-headers', config_host_h, '--features', '--lints', files('Cargo= .toml'), + '--config-headers', config_host_h, '--features', files('Cargo.toml'), capture: true, check: true).stdout().strip().splitlines() =20 # _qemu_api_cfg +=3D ['--cfg', 'feature=3D"allocator"'] diff --git a/scripts/rust/rustc_args.py b/scripts/rust/rustc_args.py index 9b9778a1cac..9df131a02bd 100644 --- a/scripts/rust/rustc_args.py +++ b/scripts/rust/rustc_args.py @@ -38,11 +38,21 @@ =20 class CargoTOML: tomldata: Mapping[Any, Any] + workspace_data: Mapping[Any, Any] check_cfg: Set[str] =20 - def __init__(self, path: str): - with open(path, 'rb') as f: - self.tomldata =3D tomllib.load(f) + def __init__(self, path: Optional[str], workspace: Optional[str]): + if path is not None: + with open(path, 'rb') as f: + self.tomldata =3D tomllib.load(f) + else: + self.tomldata =3D {"lints": {"workspace": True}} + + if workspace is not None: + with open(workspace, 'rb') as f: + self.workspace_data =3D tomllib.load(f) + if "workspace" not in self.workspace_data: + self.workspace_data["workspace"] =3D {} =20 self.check_cfg =3D set(self.find_check_cfg()) =20 @@ -54,10 +64,12 @@ def find_check_cfg(self) -> Iterable[str]: =20 @property def lints(self) -> Mapping[Any, Any]: - return self.get_table("lints") + return self.get_table("lints", True) =20 - def get_table(self, key: str) -> Mapping[Any, Any]: + def get_table(self, key: str, can_be_workspace: bool =3D False) -> Map= ping[Any, Any]: table =3D self.tomldata.get(key, {}) + if can_be_workspace and table.get("workspace", False) is True: + table =3D self.workspace_data["workspace"].get(key, {}) =20 return table =20 @@ -136,6 +148,16 @@ def main() -> None: action=3D"store", dest=3D"cargo_toml", help=3D"path to Cargo.toml file", + nargs=3D'?', + ) + parser.add_argument( + "--workspace", + metavar=3D"DIR", + action=3D"store", + dest=3D"workspace", + help=3D"path to root of the workspace", + required=3DFalse, + default=3DNone, ) parser.add_argument( "--features", @@ -168,7 +190,11 @@ def main() -> None: logging.debug("args: %s", args) =20 rustc_version =3D tuple((int(x) for x in args.rustc_version.split('.')= [0:2])) - cargo_toml =3D CargoTOML(args.cargo_toml) + if args.workspace: + workspace_cargo_toml =3D Path(args.workspace, "Cargo.toml").resolv= e() + cargo_toml =3D CargoTOML(args.cargo_toml, str(workspace_cargo_toml= )) + else: + cargo_toml =3D CargoTOML(args.cargo_toml, None) =20 if args.lints: for tok in generate_lint_flags(cargo_toml): --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688976; cv=none; d=zohomail.com; s=zohoarc; b=B8BD02lZ6YbZt6Xy7ED2SRapHd+6A/IGVqTEjC/2tY8rzL7hKGOBCyUc6ISQeY4ijFZdRdaeRvUGfUr9YAw9Ht/H5nQvLGjDlJh+pxgj8tIAte7F3gimKLHs2QDBLyCmNeJ7c9/bQxDpqSPdHr3pY5SBTDgS20uxs8nVSTDcVQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688976; h=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=B477qYom1cMNghuMK5V25JfYZq7LHn73PEI0iXzCXHc=; b=UPSViwnxG43LmqdlPkUDbGHj4u9ZzZdznHvwowIZT3y0Fic9bXInTh1kE0babt+5aljuaGTEdIZkFTU8UKP9vXMXkVZq73eFkPlGJ/1X52+gg4rqpUVfwL2eo/rJAw2c+mRxVNLyn6iUL7AvohOITCsBAGyQTpkRSkyi6jYs5Mo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688976789604.9792086348671; Fri, 15 Nov 2024 08:42:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzOJ-0007T0-Vg; Fri, 15 Nov 2024 11:41:52 -0500 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 1tBzNX-0006Nh-Su for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzNV-0002Ln-Jb for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:03 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-673-AZYDMrddOgW_vzHynh82VQ-1; Fri, 15 Nov 2024 11:40:58 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315eaa3189so18239145e9.1 for ; Fri, 15 Nov 2024 08:40:57 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821adadf8fsm4767251f8f.39.2024.11.15.08.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:40:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688859; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B477qYom1cMNghuMK5V25JfYZq7LHn73PEI0iXzCXHc=; b=Z9A5guEiImYaQZ+OEiI1MWfzvNxghiMJqgRpQR5JdaWAJviDCW3WRpZykQDNj4lOZryLJ7 Jupvgvdqc2wckkydDtsx7eS8ZyY8SzDA5I90CLxftwN9Onzwa5k35cCDQfwplfsNrJnrLy 5+i+jh+jcZB+Ls6NHvpLgxYgEOK+i74= X-MC-Unique: AZYDMrddOgW_vzHynh82VQ-1 X-Mimecast-MFC-AGG-ID: AZYDMrddOgW_vzHynh82VQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688856; x=1732293656; 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=B477qYom1cMNghuMK5V25JfYZq7LHn73PEI0iXzCXHc=; b=ON1Yd2BteAZuQIvokNI9SDFD8An7dkHbCimDTi5y0LmxEGHzC36p5cqntXlATUCD83 ZZAVXg5/HZ9hvSilH0rGaGNgWlqLssSVm9PtWoBcNxyVP2WUcOHPDqeFtEq8cL2DwhSL mASpuyiwHXQ0uyxp8fMUMvGkd3k6iRKdOUdmN1mxJQqZuDNb8foSmRt3KLW5cly8OXKd yv5GvThYAWiRVOSkP9O8EN0Vy7AMJYqTlyW/oOP/2EofP9sga4kJlJcq8Lv7hbGUPGyL msYgsFqoK2zV4m9YVumhuVmKeH04xqHIglLyNVDwulfxsYNSXeiFpd7RJPENDR9P9I6C lmeg== X-Gm-Message-State: AOJu0YwsO/IDNaScGooZ59oKrQNSLlyInsOxI8w1Up7v63/SrOv3XZks 5G96sEGciD+xN7v0ltl19OBb9hTl8pzplhXW3THAgY5DklFSJj5Bq5XhfEbBZj8xLnTmLhi3E5p eO+7A/YroaWofPFr0LIJM3LeHSO9i97XXe5gFnzcD1NUDydbb4khxSDzS4Tc875sR8AaUf0CzwX fZzcHoq4R95jTV5eEejNov0XUe3qEWUzaM9gtEkXg= X-Received: by 2002:a05:6000:460b:b0:37c:c51b:8d9c with SMTP id ffacd0b85a97d-38225ab7a2fmr3242825f8f.38.1731688856034; Fri, 15 Nov 2024 08:40:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzvBtQ5DyN+msSdT2CcFq/LvPuSGI/CnwTo6bEw3j60bIFWXzvJI0yuSRlQfaAQWN/8m8ycA== X-Received: by 2002:a05:6000:460b:b0:37c:c51b:8d9c with SMTP id ffacd0b85a97d-38225ab7a2fmr3242799f8f.38.1731688855530; Fri, 15 Nov 2024 08:40:55 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 07/12] rust: build: move strict lints handling to rustc_args.py Date: Fri, 15 Nov 2024 17:40:20 +0100 Message-ID: <20241115164025.1917618-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H2=-0.658, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1731688977652116600 Content-Type: text/plain; charset="utf-8" Make Cargo use unknown_lints =3D "allow" as well. This is more future proof as we might add new lints to rust/Cargo.toml that are not supported by older versions of rustc or clippy. Signed-off-by: Paolo Bonzini --- meson.build | 12 ++++-------- rust/Cargo.toml | 6 ++++++ scripts/rust/rustc_args.py | 19 ++++++++++++++++--- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 21e2a332d6c..a807e2a6354 100644 --- a/meson.build +++ b/meson.build @@ -123,19 +123,15 @@ if have_rust rustc_args =3D [find_program('scripts/rust/rustc_args.py'), '--rustc-version', rustc.version(), '--workspace', meson.project_source_root() / 'rust'] + if get_option('strict_rust_lints') + rustc_args +=3D ['--strict-lints'] + endif + rustfmt =3D find_program('rustfmt', required: false) =20 rustc_lint_args =3D run_command(rustc_args, '--lints', capture: true, check: true).stdout().strip().splitlines() =20 - # Occasionally, we may need to silence warnings and clippy lints that - # were only introduced in newer Rust compiler versions. Do not croak - # in that case; a CI job with rust_strict_lints =3D=3D true ensures that - # we do not have misspelled allow() attributes. - if not get_option('strict_rust_lints') - rustc_lint_args +=3D ['-A', 'unknown_lints'] - endif - # Apart from procedural macros, our Rust executables will often link # with C code, so include all the libraries that C code needs. This # is safe; https://github.com/rust-lang/rust/pull/54675 says that diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 4bb52bf0bd5..358c517bc56 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -11,5 +11,11 @@ unexpected_cfgs =3D { level =3D "deny", check-cfg =3D [ 'cfg(MESON)', 'cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)', 'cfg(has_offset_of)'] } =20 +# Occasionally, we may need to silence warnings and clippy lints that +# were only introduced in newer Rust compiler versions. Do not croak +# in that case; a CI job with rust_strict_lints =3D=3D true disables this +# and ensures that we do not have misspelled allow() attributes. +unknown_lints =3D "allow" + # Prohibit code that is forbidden in Rust 2024 unsafe_op_in_unsafe_fn =3D "deny" diff --git a/scripts/rust/rustc_args.py b/scripts/rust/rustc_args.py index 9df131a02bd..5525b3886fa 100644 --- a/scripts/rust/rustc_args.py +++ b/scripts/rust/rustc_args.py @@ -35,6 +35,8 @@ except ImportError: import tomli as tomllib =20 +STRICT_LINTS =3D {"unknown_lints", "warnings"} + =20 class CargoTOML: tomldata: Mapping[Any, Any] @@ -80,7 +82,7 @@ class LintFlag: priority: int =20 =20 -def generate_lint_flags(cargo_toml: CargoTOML) -> Iterable[str]: +def generate_lint_flags(cargo_toml: CargoTOML, strict_lints: bool) -> Iter= able[str]: """Converts Cargo.toml lints to rustc -A/-D/-F/-W flags.""" =20 toml_lints =3D cargo_toml.lints @@ -105,9 +107,13 @@ def generate_lint_flags(cargo_toml: CargoTOML) -> Iter= able[str]: # This may change if QEMU ever invokes clippy-driver or rustdo= c by # hand. For now, check the syntax but do not add non-rustc li= nts to # the command line. - if k =3D=3D "rust": + if k =3D=3D "rust" and not (strict_lints and lint in STRICT_LI= NTS): lint_list.append(LintFlag(flags=3D[flag, prefix + lint], p= riority=3Dpriority)) =20 + if strict_lints: + for lint in STRICT_LINTS: + lint_list.append(LintFlag(flags=3D["-D", lint], priority=3D100= 0000)) + lint_list.sort(key=3Dlambda x: x.priority) for lint in lint_list: yield from lint.flags @@ -184,6 +190,13 @@ def main() -> None: required=3DFalse, default=3D"1.0.0", ) + parser.add_argument( + "--strict-lints", + action=3D"store_true", + dest=3D"strict_lints", + help=3D"apply stricter checks (for nightly Rust)", + default=3DFalse, + ) args =3D parser.parse_args() if args.verbose: logging.basicConfig(level=3Dlogging.DEBUG) @@ -197,7 +210,7 @@ def main() -> None: cargo_toml =3D CargoTOML(args.cargo_toml, None) =20 if args.lints: - for tok in generate_lint_flags(cargo_toml): + for tok in generate_lint_flags(cargo_toml, args.strict_lints): print(tok) =20 if rustc_version >=3D (1, 80): --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688972; cv=none; d=zohomail.com; s=zohoarc; b=Kc1dhUKz1rUDns3yNOjn6duuiP7k6DWTwbitnJ0Ah+CDy2zc93I1q+a9a3reyrzD1dj6qCZfk2Y3yWK3Rv0zDNalNDJrNjkwNJJJsiJ17rb6UY3UrMjmbNI643LzJNGPC47uX7VfA+DyKQuv/8PT2NRGgeMdL6jPxLAWHgXsiUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688972; h=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=WSsBp8Ew5NQp7MzYfq8I541wWmJ8ybUUCSw8jpZVemg=; b=XhQuW1RRH+i+wSBY4kwaEdv084zh4SON2AmCRMbPa8zdmjW2IidvksPiCXlFsdhJ3nHYCITeoBkqg1jSspCOZzKr1H4FlEKz1ifj+4gpOjMEz1Mvuv6YdmV7x2bfAlmW0XKjlE6Ak1s12W9MAOwEtV2ic+tcVaEAcKYLDRdnKnE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173168897228527.60728344673737; Fri, 15 Nov 2024 08:42:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzNt-0006eu-OJ; Fri, 15 Nov 2024 11:41:27 -0500 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 1tBzNZ-0006No-Sz for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzNY-0002MG-CK for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:05 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-TXtdRpJWOm6cFwpLzoKBaA-1; Fri, 15 Nov 2024 11:41:02 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d4a211177so1055205f8f.0 for ; Fri, 15 Nov 2024 08:41:02 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821adbbd82sm4777246f8f.52.2024.11.15.08.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:40:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WSsBp8Ew5NQp7MzYfq8I541wWmJ8ybUUCSw8jpZVemg=; b=Ay+aAyPhaZrwmGz6fwSRFhUWeO1BJZbax7oW6EHDVPyuPEwW0wsJY2ziAZrRLMsXoJYZkl bBsgZpW6FU1e18hva0d7ktuVTXIOwwRBGN+Ge4Cv9JxbSMowGrKyGuhga2DJG0sXMgh/Zm jDCoehebBMp8NI7FBMDwwQsTYaKbEAc= X-MC-Unique: TXtdRpJWOm6cFwpLzoKBaA-1 X-Mimecast-MFC-AGG-ID: TXtdRpJWOm6cFwpLzoKBaA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688860; x=1732293660; 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=WSsBp8Ew5NQp7MzYfq8I541wWmJ8ybUUCSw8jpZVemg=; b=q/wApzbOApqaWvJ8TPkW7BQ83gOlPyw5/szrks8dCKltZvWbB3VTsdVAo2mR1M0LOb tW8zy7I7b6/16tOZAbjFaA8n1kp4quOu18zu0lxQygxhyHulQ9Cz+AC3mDNphhrZ07Eq p9DnjdnoRQluJjcXz2vCV4VOessTt4jzEk2p5k5u0CvmZ3QM1wxRueUkJmLuq6ZK7iHo 4gczIml7+Ff0o6NLNSxfeaYZKu7FcwEV6ol8kv1U2RxYIHkx2+arDef2V3aVYOBiHyiN 6T1jcKC7Wv4uBjXGCZBoKpPrE/NeNMsHTsE+DInFqyA6fIK3MVr/4pQVbbkFCRrnlOAh 1oJQ== X-Gm-Message-State: AOJu0YwkwZpyhdtaPTRRqSsLc/X2s4Y7MCcBKYIwlJd380pTzleqblhh WZ0ZDo9XCuM3Jx7voVy7roBQVcdtByyK2G53ywARS4qngy7CoTDn63nqujsY4jc5Yb0+c8QE256 knnQVXk9frqw3xPC+qDxkF+kn6ZRJKD/rt4wd8jAmia3cbXV04gNZ/RofftBjpDJmLlZNJ8vpZG FM8G9Jjj09u1EM1tgiTREdJE2JeZ3MFEJPsdEvqd0= X-Received: by 2002:a05:6000:491d:b0:371:8319:4dbd with SMTP id ffacd0b85a97d-382259063b5mr2481232f8f.17.1731688859831; Fri, 15 Nov 2024 08:40:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9ya/7jEKZ7UNJ/r7lIVCPBSxiM5E7y0IXZZfBCxd2cWZmn85OA/9rCUoRJ7zHpXqAREZEcw== X-Received: by 2002:a05:6000:491d:b0:371:8319:4dbd with SMTP id ffacd0b85a97d-382259063b5mr2481214f8f.17.1731688859379; Fri, 15 Nov 2024 08:40:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 08/12] rust: fix a couple style issues from clippy Date: Fri, 15 Nov 2024 17:40:21 +0100 Message-ID: <20241115164025.1917618-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H2=-0.658, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1731688973611116600 Content-Type: text/plain; charset="utf-8" These are reported as clippy::semicolon_inside_block and clippy::as_ptr_cas= t_mut. clippy::semicolon_inside_block can be configured not to lint single-line blocks; just go with the default. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 8 +++++--- rust/hw/char/pl011/src/memory_ops.rs | 4 +++- rust/qemu-api/tests/tests.rs | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 6556865fc22..e582a31e4d3 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -2,7 +2,7 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use core::ptr::{addr_of, addr_of_mut, NonNull}; +use core::ptr::{addr_of_mut, NonNull}; use std::{ ffi::CStr, os::raw::{c_int, c_uchar, c_uint, c_void}, @@ -499,7 +499,9 @@ pub fn update(&self) { let flags =3D self.int_level & self.int_enabled; for (irq, i) in self.interrupts.iter().zip(IRQMASK) { // SAFETY: self.interrupts have been initialized in init(). - unsafe { qemu_set_irq(*irq, i32::from(flags & i !=3D 0)) }; + unsafe { + qemu_set_irq(*irq, i32::from(flags & i !=3D 0)); + } } } =20 @@ -601,7 +603,7 @@ pub fn post_load(&mut self, _version_id: u32) -> Result= <(), ()> { let sysbus: *mut SysBusDevice =3D dev.cast::(); =20 qdev_prop_set_chr(dev, c_str!("chardev").as_ptr(), chr); - sysbus_realize_and_unref(sysbus, addr_of!(error_fatal) as *mut *mu= t Error); + sysbus_realize_and_unref(sysbus, addr_of_mut!(error_fatal)); sysbus_mmio_map(sysbus, 0, addr); sysbus_connect_irq(sysbus, 0, irq); dev diff --git a/rust/hw/char/pl011/src/memory_ops.rs b/rust/hw/char/pl011/src/= memory_ops.rs index 169d485a4d2..c4e8599ba43 100644 --- a/rust/hw/char/pl011/src/memory_ops.rs +++ b/rust/hw/char/pl011/src/memory_ops.rs @@ -33,7 +33,9 @@ // SAFETY: self.char_backend is a valid CharBackend instance a= fter it's been // initialized in realize(). let cb_ptr =3D unsafe { core::ptr::addr_of_mut!(state.as_mut()= .char_backend) }; - unsafe { qemu_chr_fe_accept_input(cb_ptr) }; + unsafe { + qemu_chr_fe_accept_input(cb_ptr); + } =20 val } diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 43a4827de12..925f5a3c77b 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -74,6 +74,6 @@ impl Class for DummyClass { =20 unsafe { module_call_init(module_init_type::MODULE_INIT_QOM); - object_unref(object_new(DummyState::TYPE_NAME.as_ptr()) as *mut _); + object_unref(object_new(DummyState::TYPE_NAME.as_ptr()).cast()); } } --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688961; cv=none; d=zohomail.com; s=zohoarc; b=m7jtOnw3ny+EVmaSBCImTZZF+Tu/jAbrep3W741+ypSLauNyH7BZAjo1B8FGTySqk1RMxzRjf3L28agfBw5NXZDJ3+1kD6TaqgENNsKm5VFxKlyOQ2SODT4mHVeaNLUtBQSdGeClB4MSTttNR6FUUxqD3LoKvH2LurO5eDP1JAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688961; h=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=WKxjJcV0JChOUSaR9ARk6UGjcpUxEbTMXigv0cQguQU=; b=NK0X6qUlDxGsjIvS5YvWdJy5IN4f+JUZl0/rt3rXbeK9qv3WskZodmgLStxu3+wwDP0IJOnq1Qjen8AJ/ibuseeaIlS5v6IKFQws4bohKUQP0+6XD9fjIbXjNUQ3elx47Goq4YdSjU6HPDzIYObCMcGxa5WiQsKr0MpniP/PC9M= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688961723938.6902545752471; Fri, 15 Nov 2024 08:42:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzOM-0007jB-Lt; Fri, 15 Nov 2024 11:41:54 -0500 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 1tBzNd-0006TP-Kh for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:10 -0500 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 1tBzNb-0002Me-UM for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:09 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-314-_iOvyWHgOIWPMmxE2LTVZQ-1; Fri, 15 Nov 2024 11:41:06 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-38223a3262bso501037f8f.0 for ; Fri, 15 Nov 2024 08:41:05 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ada3e65sm4768683f8f.13.2024.11.15.08.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:41:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WKxjJcV0JChOUSaR9ARk6UGjcpUxEbTMXigv0cQguQU=; b=Gi7oRxpWzZoFxSTWLHTqvBxC+5yRDpjySP2urBNiQu7dGtQJmPVi80hVBGA9brAyhwF0Dq dIKBu3wyF/Gr2Cqmzz2WJSqeU92e8LScyg/F6d6aK2AiZh384FrxxugU/y/Q7BK1MKtJPN fpQmLjhpq6605W5WLQHgXKjrWOgVbV0= X-MC-Unique: _iOvyWHgOIWPMmxE2LTVZQ-1 X-Mimecast-MFC-AGG-ID: _iOvyWHgOIWPMmxE2LTVZQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688864; x=1732293664; 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=WKxjJcV0JChOUSaR9ARk6UGjcpUxEbTMXigv0cQguQU=; b=n/+95ucs91BWGz+8UusAK78fn1Y9lvtQcnR9OV5og/WZWpaVAm/jiSlTIG8EA9pg5A gr5OxBLOLUBdt6EQnrRLtVJbVjCrnOwNs2pl6CUIfAcX9Z01eVtkXz6jtZ5o/T66Xgtv 9KSZIuJIkHx5i0oWB1GrFJlpzCGCiIKhETkT7U+/8P7tOC17zzvjniwx/deTS3QdWxgX igYD0Inv3J8eI/8+1HzSAzPx63GZx65sqkeh0CeNSYkmCHvDRmR0Qw6s4Xb86OMGsmWT cchjfTzxzHpeyNTrYGTLHDlChUJbcXuMTrTOaiN154xi8xi8Lu2wwmqNjEl6sZpl8Mr5 X+wA== X-Gm-Message-State: AOJu0Yzr4jkdaMSHdNOuohbO4h1cDcWP61XFmDma+L22lN1no+27cXtN dL8mVEjiubzjQv+2Ys96mYRZ2ICesrgozJ4mVK9U5BM05ucfQm57hHBEvXYMkTnhinc3iFPj0J7 45PLgS9lC6L67XAknAaenEk4mRF41hCEiR1JmGhYqW4ZgL7l/8gveCjrquSckUxu3B18qn53hZe LpIx6Lec/Mmv3SUllJorOeFVE8cPBVsTcZ9qRW+GY= X-Received: by 2002:a05:6000:782:b0:37c:f3e0:b436 with SMTP id ffacd0b85a97d-38225a3999dmr2298718f8f.30.1731688863846; Fri, 15 Nov 2024 08:41:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFT2sxcga4Kr7D6NafnKd1hr4plVsuaoNEaJe4ZsnJtodjW2mk49DUZE6GhxKC1S4X4YgCufg== X-Received: by 2002:a05:6000:782:b0:37c:f3e0:b436 with SMTP id ffacd0b85a97d-38225a3999dmr2298694f8f.30.1731688863459; Fri, 15 Nov 2024 08:41:03 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 09/12] rust: build: establish a baseline of lints across all crates Date: Fri, 15 Nov 2024 17:40:22 +0100 Message-ID: <20241115164025.1917618-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1731688963638116600 Content-Type: text/plain; charset="utf-8" Many lints that default to allow can be helpful in detecting bugs or keeping the code style homogeneous. Add them liberally, though perhaps not as liberally as in hw/char/pl011/src/lib.rs. In particular, enabling entire groups can be problematic because of bitrot when new links are added in the future. For Clippy, this is actually a feature that is only present in Cargo 1.74.0 but, since we are not using Cargo to *build* QEMU, only developers will need a new-enough cargo and only to run tools such as clippy. The requirement does not apply to distros that are building QEMU. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini --- rust/Cargo.toml | 65 +++++++++++++++++++++++++++++++++++ rust/hw/char/pl011/src/lib.rs | 19 ++-------- rust/qemu-api/src/bindings.rs | 6 ++-- 3 files changed, 71 insertions(+), 19 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 358c517bc56..c3f7142d264 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -19,3 +19,68 @@ unknown_lints =3D "allow" =20 # Prohibit code that is forbidden in Rust 2024 unsafe_op_in_unsafe_fn =3D "deny" + +[workspace.lints.rustdoc] +broken_intra_doc_links =3D "deny" +invalid_html_tags =3D "deny" +invalid_rust_codeblocks =3D "deny" +bare_urls =3D "deny" +unescaped_backticks =3D "deny" +redundant_explicit_links =3D "deny" + +[workspace.lints.clippy] +# default-warn lints +result_unit_err =3D "allow" +should_implement_trait =3D "deny" + +# default-allow lints +as_underscore =3D "deny" +assertions_on_result_states =3D "deny" +bool_to_int_with_if =3D "deny" +borrow_as_ptr =3D "deny" +cast_lossless =3D "deny" +dbg_macro =3D "deny" +debug_assert_with_mut_call =3D "deny" +derive_partial_eq_without_eq =3D "deny" +doc_markdown =3D "deny" +empty_structs_with_brackets =3D "deny" +ignored_unit_patterns =3D "deny" +implicit_clone =3D "deny" +macro_use_imports =3D "deny" +missing_const_for_fn =3D "deny" +missing_safety_doc =3D "deny" +multiple_crate_versions =3D "deny" +mut_mut =3D "deny" +needless_bitwise_bool =3D "deny" +needless_pass_by_ref_mut =3D "deny" +no_effect_underscore_binding =3D "deny" +option_option =3D "deny" +or_fun_call =3D "deny" +ptr_as_ptr =3D "deny" +pub_underscore_fields =3D "deny" +redundant_clone =3D "deny" +redundant_closure_for_method_calls =3D "deny" +redundant_else =3D "deny" +redundant_pub_crate =3D "deny" +ref_binding_to_reference =3D "deny" +ref_option_ref =3D "deny" +return_self_not_must_use =3D "deny" +same_name_method =3D "deny" +semicolon_inside_block =3D "deny" +shadow_unrelated =3D "deny" +significant_drop_in_scrutinee =3D "deny" +significant_drop_tightening =3D "deny" +suspicious_operation_groupings =3D "deny" +transmute_ptr_to_ptr =3D "deny" +transmute_undefined_repr =3D "deny" +type_repetition_in_bounds =3D "deny" +unused_self =3D "deny" +used_underscore_binding =3D "deny" + +# nice to have, but cannot be enabled yet +#wildcard_imports =3D "deny" # still have many bindings::* imports +#ptr_cast_constness =3D "deny" # needs 1.65.0 for cast_mut()/cast_const() + +# these may have false positives +#option_if_let_else =3D "deny" +cognitive_complexity =3D "deny" diff --git a/rust/hw/char/pl011/src/lib.rs b/rust/hw/char/pl011/src/lib.rs index cd0a49acb91..4dc0e8f345f 100644 --- a/rust/hw/char/pl011/src/lib.rs +++ b/rust/hw/char/pl011/src/lib.rs @@ -14,28 +14,15 @@ //! the [`registers`] module for register types. =20 #![deny( - rustdoc::broken_intra_doc_links, - rustdoc::redundant_explicit_links, clippy::correctness, clippy::suspicious, clippy::complexity, clippy::perf, clippy::cargo, clippy::nursery, - clippy::style, - // restriction group - clippy::dbg_macro, - clippy::as_underscore, - clippy::assertions_on_result_states, - // pedantic group - clippy::doc_markdown, - clippy::borrow_as_ptr, - clippy::cast_lossless, - clippy::option_if_let_else, - clippy::missing_const_for_fn, - clippy::cognitive_complexity, - clippy::missing_safety_doc, - )] + clippy::style +)] +#![allow(clippy::upper_case_acronyms)] #![allow(clippy::result_unit_err)] =20 extern crate bilge; diff --git a/rust/qemu-api/src/bindings.rs b/rust/qemu-api/src/bindings.rs index 0b76ec58bee..8a9b821bb91 100644 --- a/rust/qemu-api/src/bindings.rs +++ b/rust/qemu-api/src/bindings.rs @@ -7,10 +7,10 @@ non_snake_case, non_upper_case_globals, unsafe_op_in_unsafe_fn, + clippy::pedantic, + clippy::restriction, + clippy::style, clippy::missing_const_for_fn, - clippy::too_many_arguments, - clippy::approx_constant, - clippy::use_self, clippy::useless_transmute, clippy::missing_safety_doc )] --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688973; cv=none; d=zohomail.com; s=zohoarc; b=X8Sj3bE4FpCrnyeGYpTn6RwZTdoGu5e2H7ffNZ9EiKTKln7YlLyiOIjrZNPxuMJpu7KLRLX33vB886bRjG9Ye8Oj5fh6wnd4dOyXFI1QeyI5Z81sVh7cYRv7R2Qsm+RsvxXtuJHjjg5HKsuENm1Qn+84tAMAb/zRDkadjtEaN9g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688973; h=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=21GUR4wAO6jBo8H2QNojVW9mDn5/11rbisElFvTu3Ac=; b=Qe9qKFtf1y9Lixm1U5QzytgSABKF5DZdD+hc5jLh926jX5g5llizPmlfZ0D6iqzHbJE8FQT8Ze34AS9lU8Xh/tPGODL9vkh6DlU+sVC300Eh5mSycpsoeR0h5HAGf033trRrG6/YNwRnbAqPGl4yoabN+Yr0QOnvKiGLE8Any7k= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17316889730021005.1085116976793; Fri, 15 Nov 2024 08:42:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzOE-00071v-NL; Fri, 15 Nov 2024 11:41:47 -0500 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 1tBzNk-0006aR-Fc for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:19 -0500 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 1tBzNh-0002NO-K2 for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:16 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-288-xhTJKQNgMh6bbdd4Vsexeg-1; Fri, 15 Nov 2024 11:41:11 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-432d9bb0f19so12053475e9.1 for ; Fri, 15 Nov 2024 08:41:11 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432da28bc11sm61758915e9.31.2024.11.15.08.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688873; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=21GUR4wAO6jBo8H2QNojVW9mDn5/11rbisElFvTu3Ac=; b=O5iBOantgcMRRkvYxy/ZajPJIu59OZa1PnKSnQ8hyN0BKfoQkXcDscGOgg9gWoPqmG6WWd tsgMgSHEeB5rLeHCKxmLmzXIVQLcwmSAVwkYz+p+taJhDkPOiuSVkcNtP8jATg2mjpFoEF 0DjcDbZ0D+pHXCnN/4msijrARMFnByE= X-MC-Unique: xhTJKQNgMh6bbdd4Vsexeg-1 X-Mimecast-MFC-AGG-ID: xhTJKQNgMh6bbdd4Vsexeg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688868; x=1732293668; 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=21GUR4wAO6jBo8H2QNojVW9mDn5/11rbisElFvTu3Ac=; b=Qo63AfI8hdexbeIPiCtasz7zTQaMsZfafLAQmzTN3sQ1FJ1gtTjdxlpLTY1+cAOlPF nS7uD/ox/eAstVWF/W4xPDph67obNBxKcYu0joNo5c2UHDcxrPvQXia6ZZReLmTQQunR 6MfkizlkD6qO9oJ4owNObLKo7z2qTtYZnmiyubHvIU9PKKykNDqkpl9ATrpDXhrhXPgN 6olcRPtcWA4js0UyDmRgTvCP+la1PUUAuHlWVcTpFCl5pYBo1Id4LmwGU3/12JCSW3IR ayqFhUF1hktxqxpnCv0DAPZOotzPln6quyLoYM1byQgB19v+/hF97stFeGQfo9lDWkiI vkOQ== X-Gm-Message-State: AOJu0YzW/QFo7vEZx65dQctwgfJmNRH+rVSFogAwn86ovNGk3yiTOUF8 0CGlJLyz8p5oMShMXYm/iUtwvHUbv6mTK3kseQTTcgZD9ZLbSMySLgPgbELSdXrw8F4xyWr7t6K mDm6CurPdd76C7E+WVw7OJeTOg3uafoMU5eZ23LN9msHNVEUIirZHF9T61CTONpoAdNCM3wFFd8 9T7JkWhRTJS1I6zMo9t15EI6lqHlFLEy4x0XzI7QA= X-Received: by 2002:a05:600c:1c2a:b0:432:7c30:abf3 with SMTP id 5b1f17b1804b1-432d974a829mr75294155e9.7.1731688868584; Fri, 15 Nov 2024 08:41:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzhsQ+zoIdjAo89HZudwP7NIBS+t5yLbVTYFq13I7ZnhEC0s+mPpebu63A/9+ErVsY9h45gA== X-Received: by 2002:a05:600c:1c2a:b0:432:7c30:abf3 with SMTP id 5b1f17b1804b1-432d974a829mr75293945e9.7.1731688868197; Fri, 15 Nov 2024 08:41:08 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 10/12] rust: build: add "make clippy", "make rustfmt", "make rustdoc" Date: Fri, 15 Nov 2024 17:40:23 +0100 Message-ID: <20241115164025.1917618-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1731688973620116600 Content-Type: text/plain; charset="utf-8" Abstract common invocations of "cargo", that do not require copying the generated bindgen file or setting up MESON_BUILD_ROOT. In the future these could also do completely without cargo and invoke the underlying programs directly. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini --- rust/meson.build | 22 ++++++++++++++++++++++ rust/qemu-api/README.md | 10 ++++++---- rust/qemu-api/build.rs | 9 +++++++-- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/rust/meson.build b/rust/meson.build index def77389cdd..91e52b8fb8e 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -2,3 +2,25 @@ subdir('qemu-api-macros') subdir('qemu-api') =20 subdir('hw') + +cargo =3D find_program('cargo', required: false) + +if cargo.found() + run_target('clippy', + command: [config_host['MESON'], 'devenv', + '--workdir', '@CURRENT_SOURCE_DIR@', + cargo, 'clippy', '--tests'], + depends: bindings_rs) + + run_target('rustfmt', + command: [config_host['MESON'], 'devenv', + '--workdir', '@CURRENT_SOURCE_DIR@', + cargo, 'fmt'], + depends: bindings_rs) + + run_target('rustdoc', + command: [config_host['MESON'], 'devenv', + '--workdir', '@CURRENT_SOURCE_DIR@', + cargo, 'doc', '--no-deps', '--document-private-items'], + depends: bindings_rs) +endif diff --git a/rust/qemu-api/README.md b/rust/qemu-api/README.md index 53810f48882..ed1b7ab263d 100644 --- a/rust/qemu-api/README.md +++ b/rust/qemu-api/README.md @@ -5,13 +5,15 @@ This library exports helper Rust types, Rust macros and C= FFI bindings for inter The C bindings can be generated with `bindgen`, using this build target: =20 ```console -$ ninja bindings.inc.rs +$ make bindings.inc.rs ``` =20 ## Generate Rust documentation =20 -To generate docs for this crate, including private items: +Common Cargo tasks can be performed from the QEMU build directory =20 -```sh -pyvenv/bin/meson devenv -w ../rust cargo doc --no-deps --document-private-= items +```console +$ make clippy +$ make rustfmt +$ make rustdoc ``` diff --git a/rust/qemu-api/build.rs b/rust/qemu-api/build.rs index 06e79082b5f..33e7968ee76 100644 --- a/rust/qemu-api/build.rs +++ b/rust/qemu-api/build.rs @@ -20,8 +20,13 @@ fn main() -> Result<()> { let file =3D Path::new(&file); if !Path::new(&file).exists() { panic!(concat!( - "No generated C bindings found! If you want to run `cargo`, st= art a subshell\n", - "with `meson devenv`, or point MESON_BUILD_ROOT to the top of = the build tree." + "\n", + " No generated C bindings found! Maybe you wanted one of\n", + " `make clippy`, `make rustfmt`, `make rustdoc`?\n", + "\n", + " For other uses of `cargo`, start a subshell with\n", + " `pyvenv/bin/meson devenv`, or point MESON_BUILD_ROOT to\n= ", + " the top of the build tree." )); } =20 --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688979; cv=none; d=zohomail.com; s=zohoarc; b=ii0D9bHw1mgBBZGRzYjHc3mPE4ZPyr+zx741ZWhX2H54JHdHoPu44xoZtYuNZtqg987xtgx1k29GzDBpWXmfPG/z8C0dZNZ3zfFRqRde1flWWl3nZneRm/qqd3jcYjRTJFr58D894TeBk6nA18Qb5tTKSXQEHnpgfAf85+NVwMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688979; h=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=R9drXR6Ude9Syf7XBgbJFTV9jiXiqgiqWNTd79QJqvw=; b=nJ5WuVDH3np1+zmbUW9v/lo+KjV8Z+qqgbOs92yevtbGjUK+Oeq549SL9YSlR4ylHuGmV+I5ulQrRemno5KTziaqj+IPlrhM0fd74+zvjpjXTqcHBDqm425nLeGboC9POU1yI8kGhG/hTOQX1+S2y68OytCOSmkTwIEpYkelmlk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688979360335.448512112044; Fri, 15 Nov 2024 08:42:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzOG-0007EK-N3; Fri, 15 Nov 2024 11:41:49 -0500 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 1tBzNr-0006fX-LE for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:25 -0500 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 1tBzNq-0002O1-4t for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:23 -0500 Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-492-rPKb8cCfOXK6365n2uWKgQ-1; Fri, 15 Nov 2024 11:41:19 -0500 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539e13b8143so887074e87.0 for ; Fri, 15 Nov 2024 08:41:17 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dab78881sm58647175e9.13.2024.11.15.08.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:41:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R9drXR6Ude9Syf7XBgbJFTV9jiXiqgiqWNTd79QJqvw=; b=Ro4lcg7hidbLeLSLXRgRGZ5x8P8XYxb48kmgJVGHMj1fSZoiscH3mUxrwla63Hq05hDuJP 0Pbuca2nwN6LrlL7nO0zL56yweW+QdB2YDUww7DojSYqdfHPB2ZMm/WKKi2jDGN0ue2tV/ GDdrP3PoH3YM9HfJW/9EBnH1DV2Il4M= X-MC-Unique: rPKb8cCfOXK6365n2uWKgQ-1 X-Mimecast-MFC-AGG-ID: rPKb8cCfOXK6365n2uWKgQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688873; x=1732293673; 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=R9drXR6Ude9Syf7XBgbJFTV9jiXiqgiqWNTd79QJqvw=; b=T+xYvhdT0JLK8iaOS3Nk7DwGxb+I9kB18xnmNrOnkLf+EFZLZDCRZTAFopO7uRrfTe sUbQY2V2AG2gvhGL9V4/InKxEJplZ6XBZLBeHDSJulu5vHHkKa4HpmloIVOfV1w3UBQV ZMoMebOK3UiCJDBc3IrqV3tI2TZQ3w4BR4aDPeqOiU43AdusQlHQnjCiE9vd+EipZR5R wymBT1MxJ3fkB5bCrXCP+1bkXwf46AK1OryOochkLOyUPFmILiIe6Dl+aXC5Q1LpMDWe w9lzv41QiJL4cqFZQbXLtLYGyGIPtG0Xdwmcj5zbHZ0ZB6MimV2BhPXfZym7Bzb4Wf8b T7mQ== X-Gm-Message-State: AOJu0YwkNfyT01JOqFRsDj15L6y27umW3bVQqF+MWrw5GxuA7bjoGVy5 zFzs3Vn03TEyp7uX1Z2G4zJBQHR+zPnb7mhoGZMJsaFTTZijaff2QkpntIueEu0ao7eJn7k1M9Y d6A2o4c2pr9haJ6aHrX7XyxgWxSsvh1Tbs9k7LFTroVp42adYLHYlxdyQ7Wm7i/r1eZLTaxDiZQ HUb66SfdQR/mG4V8Nk7RLoCSfNdb3VRUjYyb0XQvs= X-Received: by 2002:a05:6512:a8b:b0:53d:a4ff:31d7 with SMTP id 2adb3069b0e04-53dab3bf5a5mr1798644e87.40.1731688872742; Fri, 15 Nov 2024 08:41:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBxdEuDpU02hegQikxa2pwFvauIp8Gy2nDC9GIpzg2YewMmP3fd8pNPe7EWiYWovEJeeHCLQ== X-Received: by 2002:a05:6512:a8b:b0:53d:a4ff:31d7 with SMTP id 2adb3069b0e04-53dab3bf5a5mr1798622e87.40.1731688872258; Fri, 15 Nov 2024 08:41:12 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 11/12] rust: ci: add job that runs Rust tools Date: Fri, 15 Nov 2024 17:40:24 +0100 Message-ID: <20241115164025.1917618-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1731688979668116600 Content-Type: text/plain; charset="utf-8" Code checks, as well as documentation generation, are not yet tied to "make check" because they need new version of the Rust toolchain (even nightly in the case of "rustfmt"). Run them in CI using the existing nightly-Rust container. Signed-off-by: Paolo Bonzini --- .gitlab-ci.d/static_checks.yml | 23 +++++++++++++++++++ .../dockerfiles/fedora-rust-nightly.docker | 4 ++++ tests/lcitool/refresh | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/.gitlab-ci.d/static_checks.yml b/.gitlab-ci.d/static_checks.yml index ad9f426a52f..f6f22875265 100644 --- a/.gitlab-ci.d/static_checks.yml +++ b/.gitlab-ci.d/static_checks.yml @@ -46,3 +46,26 @@ check-python-tox: QEMU_JOB_OPTIONAL: 1 needs: job: python-container + +check-rust-tools-nightly: + extends: .base_job_template + stage: test + image: $CI_REGISTRY_IMAGE/qemu/fedora-rust-nightly:$QEMU_CI_CONTAINER_TAG + script: + - source scripts/ci/gitlab-ci-section + - section_start test "Running Rust code checks" + - cd build + - pyvenv/bin/meson devenv -w ../rust ${CARGO-cargo} fmt --check + - make clippy + - make rustdoc + - section_end test + variables: + GIT_DEPTH: 1 + needs: + - job: build-system-fedora-rust-nightly + artifacts: true + artifacts: + when: on_success + expire_in: 2 days + paths: + - rust/target/doc diff --git a/tests/docker/dockerfiles/fedora-rust-nightly.docker b/tests/do= cker/dockerfiles/fedora-rust-nightly.docker index 9180c8b5222..a8e4fb279a7 100644 --- a/tests/docker/dockerfiles/fedora-rust-nightly.docker +++ b/tests/docker/dockerfiles/fedora-rust-nightly.docker @@ -155,6 +155,7 @@ ENV PYTHON "/usr/bin/python3" RUN dnf install -y wget ENV RUSTUP_HOME=3D/usr/local/rustup CARGO_HOME=3D/usr/local/cargo ENV RUSTC=3D/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/= bin/rustc +ENV CARGO=3D/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/= bin/cargo RUN set -eux && \ rustArch=3D'x86_64-unknown-linux-gnu' && \ rustupSha256=3D'6aeece6993e902708983b209d04c0d1dbb14ebb405ddb87def578d41= f920f56d' && \ @@ -165,10 +166,13 @@ RUN set -eux && \ ./rustup-init -y --no-modify-path --profile default --default-toolchain = nightly --default-host ${rustArch} && \ chmod -R a+w $RUSTUP_HOME $CARGO_HOME && \ /usr/local/cargo/bin/rustup --version && \ + /usr/local/cargo/bin/rustup run nightly cargo --version && \ /usr/local/cargo/bin/rustup run nightly rustc --version && \ + test "$CARGO" =3D "$(/usr/local/cargo/bin/rustup +nightly which cargo)" = && \ test "$RUSTC" =3D "$(/usr/local/cargo/bin/rustup +nightly which rustc)" ENV PATH=3D$CARGO_HOME/bin:$PATH RUN /usr/local/cargo/bin/rustup run nightly cargo install bindgen-cli +RUN $CARGO --list # As a final step configure the user (if env is defined) ARG USER ARG UID diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh index 51012783c0f..6720516b942 100755 --- a/tests/lcitool/refresh +++ b/tests/lcitool/refresh @@ -121,6 +121,7 @@ fedora_rustup_nightly_extras =3D [ "RUN dnf install -y wget\n", "ENV RUSTUP_HOME=3D/usr/local/rustup CARGO_HOME=3D/usr/local/cargo\n", "ENV RUSTC=3D/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux= -gnu/bin/rustc\n", + "ENV CARGO=3D/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux= -gnu/bin/cargo\n", "RUN set -eux && \\\n", " rustArch=3D'x86_64-unknown-linux-gnu' && \\\n", " rustupSha256=3D'6aeece6993e902708983b209d04c0d1dbb14ebb405ddb87def5= 78d41f920f56d' && \\\n", @@ -131,10 +132,13 @@ fedora_rustup_nightly_extras =3D [ " ./rustup-init -y --no-modify-path --profile default --default-toolc= hain nightly --default-host ${rustArch} && \\\n", " chmod -R a+w $RUSTUP_HOME $CARGO_HOME && \\\n", " /usr/local/cargo/bin/rustup --version && \\\n", + " /usr/local/cargo/bin/rustup run nightly cargo --version && \\\n", " /usr/local/cargo/bin/rustup run nightly rustc --version && \\\n", + ' test "$CARGO" =3D "$(/usr/local/cargo/bin/rustup +nightly which car= go)" && \\\n', ' test "$RUSTC" =3D "$(/usr/local/cargo/bin/rustup +nightly which rus= tc)"\n', 'ENV PATH=3D$CARGO_HOME/bin:$PATH\n', 'RUN /usr/local/cargo/bin/rustup run nightly cargo install bindgen-cli= \n', + 'RUN $CARGO --list\n', ] =20 ubuntu2204_bindgen_extras =3D [ --=20 2.47.0 From nobody Sat Nov 23 17:06:18 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731688916; cv=none; d=zohomail.com; s=zohoarc; b=aoTMAuYvPvU1cItYNe/Azkcf7Je3t3fF6+MZAG7FEeoQKv4CCSoaj8CFs4hSmU35E6PQ5ah46MH9hjMOF5H2EDZVNaTCuAIgBoeEflACIay6wNBwUkRSio2uULPhAMkgyiP21wXuMLsTG8wkGChPR7ZAX6pzEbEAJWQ7sVUccoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731688916; h=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=lNF/kcmKbI8KDX0YtdYyqZMFkG7Dt2MJ7WbIuixbzu0=; b=Vn9u0CQonseaw6FKh555VQH+RT1umIEm55MlTaEpPA1abz/x1HvmcJOSpp4N7sqs0HbLBDhlUBOnfAAZ5jCchiw6Kxbly0o2isppdV9jA5x84NRuvsvJyn2wR0mXbYT1MeUYr8yfGhMEDjKPo4A1DnQID6MZH9MJB+m+osOWCSw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731688916826378.43212046643964; Fri, 15 Nov 2024 08:41:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzO6-0006mn-48; Fri, 15 Nov 2024 11:41:39 -0500 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 1tBzNs-0006fq-Rb for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzNr-0002O7-G1 for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:41:24 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-zQSW2y76OzKNC2GWNhtDeQ-1; Fri, 15 Nov 2024 11:41:21 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4314a22ed8bso6157915e9.1 for ; Fri, 15 Nov 2024 08:41:21 -0800 (PST) Received: from [192.168.10.3] ([151.49.84.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821b461a84sm4659639f8f.34.2024.11.15.08.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731688882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lNF/kcmKbI8KDX0YtdYyqZMFkG7Dt2MJ7WbIuixbzu0=; b=ZT4f/eDrNSnCBcKKXAw2Mx8TXPDWn2Ok1809tzvpMfyD2Gl9o9kQ6L2v6/U8EOfcVLnxjk uoXBybNdVKOI7w1Lm+SJijAfwp+c1U3X9Q4dTMgtxdhwvzOC1/Lx3+Lsggew9VlrE7W23B bGqEdY3Pqt4eu5zcBCxZPC17GZmy/aY= X-MC-Unique: zQSW2y76OzKNC2GWNhtDeQ-1 X-Mimecast-MFC-AGG-ID: zQSW2y76OzKNC2GWNhtDeQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731688878; x=1732293678; 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=lNF/kcmKbI8KDX0YtdYyqZMFkG7Dt2MJ7WbIuixbzu0=; b=IYFuXAWFGh2KI2FVL7dz+Gw62w1tggRzusa++5emSi6U2rhkfUjuPVRQc+cccVrbhU 7mK1/Y67JiBg1h92SFJF21xY5MuVIMCcbqnmL9fg1wvqQ5f0RNmg1U1br/Sy75VT7Dlf o0hmQii46/gHLvSHSFo9tChaJbYRXqpSt/Q65GrNP/Vcx6TySY2X1285kOLows2zGdS7 arNtVgAfBl4ioW05DbV1ENAmqR0ZIufQtlnRUUZNTG4PBzAOLvBNqV7qHmkjLRHTyaHf ApxNcEnlJVIUXxmXy+fOIcOl8VWYNS9gUQAtDkUblPpvKgk2WfgmmeVw5XUBfVBP1VS3 JjAA== X-Gm-Message-State: AOJu0YzmolDtHMGnOa1gruPyKK28kMIXOey6YZL/uXi3epJ54EoEoY6y OhWAvCoN1jCCuS2G0zKeuxDX4Jmp3VrnkmhUiInQVs4ncl7O6jj6MoHf6IzQwq4LAgyxpCGxN6k mNTkxfMYCsLWn87/pp/bRFaezFJJ6UTJThp0yFff4QYpkzza09NojOfKqjHdfterug6NLsFeGFn qVW3dbRKUGq3EQL6GYygQpn8f4ys9m6BeY5cOJ7IM= X-Received: by 2002:a05:600c:35d2:b0:42c:c401:6d67 with SMTP id 5b1f17b1804b1-432df71e8d0mr27732245e9.6.1731688878559; Fri, 15 Nov 2024 08:41:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYIOmwqMaZc9Jpmv3POLb6H0rLNE34fZGiIM3liWc2MH5JMcADQ/llNm6desKG+DqCpuOlxQ== X-Received: by 2002:a05:600c:35d2:b0:42c:c401:6d67 with SMTP id 5b1f17b1804b1-432df71e8d0mr27732005e9.6.1731688878150; Fri, 15 Nov 2024 08:41:18 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, berrange@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, kwolf@redhat.com Subject: [PATCH 12/12] rust: fix doc test syntax Date: Fri, 15 Nov 2024 17:40:25 +0100 Message-ID: <20241115164025.1917618-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115163944.1917393-1-pbonzini@redhat.com> References: <20241115163944.1917393-1-pbonzini@redhat.com> MIME-Version: 1.0 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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.12, 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_H2=-0.658, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1731688917354116600 Content-Type: text/plain; charset="utf-8" Allow "cargo test --doc" to pass. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/zeroable.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/qemu-api/src/zeroable.rs b/rust/qemu-api/src/zeroable.rs index 13cdb2ccba5..6125aeed8b4 100644 --- a/rust/qemu-api/src/zeroable.rs +++ b/rust/qemu-api/src/zeroable.rs @@ -7,9 +7,9 @@ /// behavior. This trait in principle could be implemented as just: /// /// ``` -/// const ZERO: Self =3D unsafe { -/// ::core::mem::MaybeUninit::<$crate::bindings::Property>::zeroed= ().assume_init() -/// }, +/// pub unsafe trait Zeroable: Default { +/// const ZERO: Self =3D unsafe { ::core::mem::MaybeUninit::::ze= roed().assume_init() }; +/// } /// ``` /// /// The need for a manual implementation is only because `zeroed()` cannot --=20 2.47.0