From nobody Tue Oct 22 23:34:19 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=1729591998; cv=none; d=zohomail.com; s=zohoarc; b=Y+jiV6VyJlljB3yPaRmhCTDLthXznyyKV3uVFmamC1LvUvgNYToLMT+qD8hoYNSw1wD3MCnbsCJT9Qx7nL8IapCEsC/Uw/CMk7GuRSdb2fsXSrzF4yhC73anhVVac9VlXVH4vC0EkSlRZn91R21rbVj9kFruh4ixzQZx/lphdUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591998; 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=wbBj01caC6lJt2jK3U2GIrbaj1k0y4qahoaWSgkgdlg=; b=RUPGB7J0LjQp+Ult0lJGdhm7LnHgEO5L7FqvB15gey8F27w7i7IWOOU5vzji9PXkBMSQT3KtJXoUaSUgdBNd3fuzqeYsc5f9InOOiEsw3blMeXvjSm9bm860ZaF1eR10XlDPRfTLQNVP/RNIKuSrpV8p3byd2OV9uobeFZb6AC4= 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 1729591998949159.44539696735637; Tue, 22 Oct 2024 03:13:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3Bq8-0004qY-LR; Tue, 22 Oct 2024 06:10:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bq6-0004pK-Hs for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:10 -0400 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 1t3Bq4-0004Mh-R9 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:10 -0400 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-323-pztrLJLRPbm3S_bPACgvYw-1; Tue, 22 Oct 2024 06:10:05 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4316e350d6aso19324655e9.3 for ; Tue, 22 Oct 2024 03:10:05 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f57fdb2sm82969035e9.20.2024.10.22.03.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591807; 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=wbBj01caC6lJt2jK3U2GIrbaj1k0y4qahoaWSgkgdlg=; b=PUHrMeskO0+SWuOZFxhz1iXYaqKyfcJvKrxwx+9PEPkR/Ye6vNcAjP3/oq/dnUTyQx6qG5 /dbCpnWi38AHbr5TVZCiDcCYA2XNcanEye4dRkavrtM9TlBcnoLaik+deOmUFXA8xnmkvg MU53fq4pNti1ThSmzJ/AdFd5KbfH5kU= X-MC-Unique: pztrLJLRPbm3S_bPACgvYw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591804; x=1730196604; 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=wbBj01caC6lJt2jK3U2GIrbaj1k0y4qahoaWSgkgdlg=; b=Ffk1JYO+dRtnj7Dzv9/X2KhkdtzlrDk+MTjNmbCY8Yv/VFuzUHn5GfTB5vCvx8KqZP CiXKAvzkpV2pEIORXR7FxWxG1VDA0gut5M7O3PrCWJ+PYq8ve1d6mZA7aVkaRIZt+ruB 2FHoJCPz6pC8zWBEz43NYjcMKSXFtJgy3M6GlyTSikX2yJeq18qBSOiWr+dTPIBlZro2 cUna4bhLDBIbqetJMiGS7llwLglfkuIlPBB4vKnTv7TfZ/4VuIsscfeVSPf9sl9IZ1t+ fdkkkEQ7rNntIdlLpoPoB/LJE71BA01f41Jo/I+4hj88mZynAGmKbkS8b8qEZ+tuJJww J81g== X-Gm-Message-State: AOJu0Yw1lITSWVqf+inamYTzd3XkQvjAj3B/xVuisFlCPzy5KVQPSrSY +/IckGmsvMXNsNgrO9OV5iYwNQdvciaNaNs/x4Cs6+sxw/ECrfHJCo/yN59gGYh7J8d7c/9zG4t q6udUUcq8KiZeqAnut0MuM7dxQhZMFN6Wy69xr//oWR+zziPwQ/S/JBpqsrPwkGbR4mOm7fBn2A DbR0VC4dbUfLLIXLfc86Jw65p5yucJf/HLqIck/3Q= X-Received: by 2002:a7b:ce07:0:b0:431:251a:9dc9 with SMTP id 5b1f17b1804b1-4317ed25874mr11360845e9.25.1729591803826; Tue, 22 Oct 2024 03:10:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDj51YiXUYWxiG6Ym1Hu15udjnbMb0pqij8oKFiKRX2OJ1LRaQYKCnThPzMhv/tJL+PiO5gw== X-Received: by 2002:a7b:ce07:0:b0:431:251a:9dc9 with SMTP id 5b1f17b1804b1-4317ed25874mr11360535e9.25.1729591803366; Tue, 22 Oct 2024 03:10:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, Zhao Liu Subject: [PATCH v2 01/14] rust: patch bilge-impl to allow compilation with 1.63.0 Date: Tue, 22 Oct 2024 12:09:42 +0200 Message-ID: <20241022100956.196657-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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=-1.699, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729592000158116600 Content-Type: text/plain; charset="utf-8" Apply a patch that removes "let ... else" constructs, replacing them with "if let ... else" or "let ... =3D match ...". "let ... else" was stabilize= d in Rust 1.65.0. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- .gitattributes | 2 + subprojects/bilge-impl-0.2-rs.wrap | 1 + subprojects/packagefiles/.gitattributes | 1 + .../packagefiles/bilge-impl-1.63.0.patch | 45 +++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 subprojects/packagefiles/.gitattributes create mode 100644 subprojects/packagefiles/bilge-impl-1.63.0.patch diff --git a/.gitattributes b/.gitattributes index 6dc6383d3d1..9ce7a19581a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,3 +5,5 @@ *.rs diff=3Drust *.rs.inc diff=3Drust Cargo.lock diff=3Dtoml merge=3Dbinary + +*.patch -text -whitespace diff --git a/subprojects/bilge-impl-0.2-rs.wrap b/subprojects/bilge-impl-0.= 2-rs.wrap index eefb10c36c2..b24c34a9043 100644 --- a/subprojects/bilge-impl-0.2-rs.wrap +++ b/subprojects/bilge-impl-0.2-rs.wrap @@ -5,3 +5,4 @@ source_filename =3D bilge-impl-0.2.0.tar.gz source_hash =3D feb11e002038ad243af39c2068c8a72bcf147acf05025dcdb916fcc000= adb2d8 #method =3D cargo patch_directory =3D bilge-impl-0.2-rs +diff_files =3D bilge-impl-1.63.0.patch diff --git a/subprojects/packagefiles/.gitattributes b/subprojects/packagef= iles/.gitattributes new file mode 100644 index 00000000000..bf5b766d75d --- /dev/null +++ b/subprojects/packagefiles/.gitattributes @@ -0,0 +1 @@ +/*.patch -text diff --git a/subprojects/packagefiles/bilge-impl-1.63.0.patch b/subprojects= /packagefiles/bilge-impl-1.63.0.patch new file mode 100644 index 00000000000..987428a6d65 --- /dev/null +++ b/subprojects/packagefiles/bilge-impl-1.63.0.patch @@ -0,0 +1,45 @@ +--- a/src/shared/discriminant_assigner.rs ++++ b/src/shared/discriminant_assigner.rs +@@ -26,20 +26,20 @@ + let discriminant_expr =3D &discriminant.1; + let variant_name =3D &variant.ident; +=20 +- let Expr::Lit(ExprLit { lit: Lit::Int(int), .. }) =3D discriminan= t_expr else { ++ if let Expr::Lit(ExprLit { lit: Lit::Int(int), .. }) =3D discrimi= nant_expr { ++ let discriminant_value: u128 =3D int.base10_parse().unwrap_or= _else(unreachable); ++ if discriminant_value > self.max_value() { ++ abort!(variant, "Value of variant exceeds the given numbe= r of bits") ++ } ++ ++ Some(discriminant_value) ++ } else { + abort!( + discriminant_expr, + "variant `{}` is not a number", variant_name; + help =3D "only literal integers currently supported" + ) +- }; +- +- let discriminant_value: u128 =3D int.base10_parse().unwrap_or_els= e(unreachable); +- if discriminant_value > self.max_value() { +- abort!(variant, "Value of variant exceeds the given number of= bits") + } +- +- Some(discriminant_value) + } +=20 + fn assign(&mut self, variant: &Variant) -> u128 { +--- a/src/shared/fallback.rs ++++ b/src/shared/fallback.rs +@@ -22,8 +22,9 @@ + } + Unnamed(fields) =3D> { + let variant_fields =3D fields.unnamed.iter(); +- let Ok(fallback_value) =3D variant_fields.exactly_one() e= lse { +- abort!(variant, "fallback variant must have exactly o= ne field"; help =3D "use only one field or change to a unit variant") ++ let fallback_value =3D match variant_fields.exactly_one()= { ++ Ok(ok) =3D> ok, ++ _ =3D> abort!(variant, "fallback variant must have ex= actly one field"; help =3D "use only one field or change to a unit variant") + }; +=20 + if !is_last_variant { --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591856; cv=none; d=zohomail.com; s=zohoarc; b=cnwcXFejUiTaezSQEYo8Y+89us+FwqiaWJk6dNltEdixs+Gzl20E9TRxRg7ykREKOySHmhF0ppop35p6wjVJ3Rsh8wCV8JFI5lIjRUiUPBF2dx2h8Tewg8Ypw+dwHf9FrnfzIhHO+HJ/t4iyKXZ8iNia74Jnf4dUJSoHTk1ngZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591856; 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=u45iLCwaL6UDPFZFrxkclA/Jz3UXse/PWIiVqr58mZQ=; b=VjEVYXxluvVdeM+nbg7YlYdMzxQtP4xpRJZImF8ySjXhkuiHLdvp6XwE/1RfuvHkTyg0pyc2WlSX1x021di4FH30/uCz+/KN+6l6ovuHQfKqIkEtAmzx0PskMt258Yrs7LDKKE/PexCrp6DDeOYEmdUEcrD5bYEOQWy3yU4jzQ4= 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 1729591856129766.5436565452637; Tue, 22 Oct 2024 03:10:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3BqE-0004rI-Aw; Tue, 22 Oct 2024 06:10:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqC-0004r8-CK for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:16 -0400 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 1t3BqA-0004NE-SO for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:16 -0400 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-225-_hK7ADmUNLm6XC5qoDbmlw-1; Tue, 22 Oct 2024 06:10:09 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4315afcae6cso29594755e9.0 for ; Tue, 22 Oct 2024 03:10:09 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58adffsm83761815e9.22.2024.10.22.03.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591814; 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=u45iLCwaL6UDPFZFrxkclA/Jz3UXse/PWIiVqr58mZQ=; b=RR61zs4pLORMz20pcKLFZMssjZQjKQZcDlo5TJtVmV4gdV8/zoPCLcp/GkEy7gW1v+nG2O wo7a4oYf787mRzkOgx4ONqD7Im9wmfS0CaaZwD6HFVkhX6ho/kQDQtjljxgm2/cMOFb2bk lbZklHvVL4tcohToyQUGA2rHhzBD0JU= X-MC-Unique: _hK7ADmUNLm6XC5qoDbmlw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591807; x=1730196607; 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=u45iLCwaL6UDPFZFrxkclA/Jz3UXse/PWIiVqr58mZQ=; b=Lpy/Yd9hK+UHIl1/8EQW0n19srpPIGyx0POB8Iw5zp5WHI8sU1YNDsIio7iACbfWyO etcC6hG/rulEiwjrp9n5aJnm94xfApVtc+fNPEvUEEmln94x0ZLzgeFAPfmlU+uReu2W 3jeC0QLfrR8l2Mqoc/+5+GGCDgkPh9kYYwK15HGg3K/78Pu6E6Fy17D8S+oltaUtMtTJ CQfgXNd4SUi7AFZfTVanT3TWMzJE0JwEx9eEGrkKUTpT6F+LRyOI58m+r8eE+lS7jgLL /12He+U2xSBYlcGnnU6s562JmHwbhVDpESSeWLsfgioktlJFxijAMMd4243a6kqIHPiP dhYg== X-Gm-Message-State: AOJu0Yz0fhMazyr1wKDl1gLg6c2sXqfBmlVlf76GSAzYSsFiOu5yI0/d hvegL05yOUEYCpdXnPy5nHipJXCOWSHq1KkGxXlCtaSWOdcvAbLD0uReaz8tx++X4UUj8LjAA7/ 6wZZyOoj+7Onof/C+HwKP5FJ4D7EKRL5DCl/IAfk98CInEGru2h8keGn1ZCnHJA2ldaQMPV/mAu AbRbdzzqCqW96GacVzh4R2x+8WR4zlYG6egJ8A+xU= X-Received: by 2002:a05:600c:1994:b0:42c:b8c9:16c8 with SMTP id 5b1f17b1804b1-4317bd8e3c4mr17016705e9.10.1729591807574; Tue, 22 Oct 2024 03:10:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGH60NolRXgjd8lCXnosS+yJVsDidGmozsXZ3YAcdeEYVg2JuEcF+eJ+c4J62IzOGesgIEaaQ== X-Received: by 2002:a05:600c:1994:b0:42c:b8c9:16c8 with SMTP id 5b1f17b1804b1-4317bd8e3c4mr17016445e9.10.1729591807125; Tue, 22 Oct 2024 03:10:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 02/14] rust: fix cfgs of proc-macro2 for 1.63.0 Date: Tue, 22 Oct 2024 12:09:43 +0200 Message-ID: <20241022100956.196657-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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=-1.699, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591857746116600 Content-Type: text/plain; charset="utf-8" Replay the configuration that would be computed by build.rs when compiling on a 1.63.0 compiler. Signed-off-by: Paolo Bonzini --- subprojects/packagefiles/proc-macro2-1-rs/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subprojects/packagefiles/proc-macro2-1-rs/meson.build b/subpro= jects/packagefiles/proc-macro2-1-rs/meson.build index 818ec59336b..8e601b50ccc 100644 --- a/subprojects/packagefiles/proc-macro2-1-rs/meson.build +++ b/subprojects/packagefiles/proc-macro2-1-rs/meson.build @@ -15,7 +15,9 @@ _proc_macro2_rs =3D static_library( rust_abi: 'rust', rust_args: [ '--cfg', 'feature=3D"proc-macro"', - '--cfg', 'span_locations', + '--cfg', 'no_literal_byte_character', + '--cfg', 'no_literal_c_string', + '--cfg', 'no_source_text', '--cfg', 'wrap_proc_macro', ], dependencies: [ --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591969; cv=none; d=zohomail.com; s=zohoarc; b=OeazRJMqibb0Gjyoau/z1nEolLfK1vA/tTNBPaT5qsqLo9HA1Rf6yTL5fX6qmGhu6pgZrCT6RzgBeGXKqZten8SfZANCghMdxY36EMkhqdOTAziN820MZJ+1yy8N8FQ47M3Ly2qufp9kdClt10kEpmmhywPgIpKnawHFcGnkmk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591969; 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=QP7e8UEKzoE0KB/7pMJdUtY48ENaf+OvkadNUEq9q/I=; b=dchutQADwT1BQ1VaaDffPG/8LmqdyVl+pEW8gpXDwtHrGPNxrNKLeMJtaOEg9EUNtGAQY7Z0mqSpKRsBibBZ1XYFFo4VB68L2X8sSS0ETFYmM651Z3ohOoQ5zQkwvu4nf8YFu2phku1OWcsy3/zoEuOr6D1fP3SuPAJZb3tXiZo= 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 172959196968555.22940195381841; Tue, 22 Oct 2024 03:12:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3BqN-0004sE-Vf; Tue, 22 Oct 2024 06:10:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqH-0004rg-Hn for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqF-0004NT-KF for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:21 -0400 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-290-72yTXa1zMeCcGtSN-8kvGQ-1; Tue, 22 Oct 2024 06:10:14 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4315af466d9so37788005e9.3 for ; Tue, 22 Oct 2024 03:10:13 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58f0efsm84440045e9.26.2024.10.22.03.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591818; 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=QP7e8UEKzoE0KB/7pMJdUtY48ENaf+OvkadNUEq9q/I=; b=i5ClNuk8EW9YOCsPXla+Ysdqq5sspTwHqfA7+m7CDx8lwiHvpFk07zfvvGe21VFhDPE6ni 8AHqER5Jxs40kDt4CQy/4xHViqc/z27zcyBbIFE/WZG27SaymKUafQGFsrGyu7NcAA5iNG pS4mEpurjlZR+PgfPKAlTAgo445qn+I= X-MC-Unique: 72yTXa1zMeCcGtSN-8kvGQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591811; x=1730196611; 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=QP7e8UEKzoE0KB/7pMJdUtY48ENaf+OvkadNUEq9q/I=; b=bgVs2Mge0SV76PshRipqKu4MbPWKIo81pGbcGOvU87bS5eWAMU4whSpcFBgMEY8KLw GDK8+CxsrM8yRBuB2L+yaSMoXlbXjwTxQhHI+nOzGfN60BWdtCHfapMHS6/pzEckFPgG Y/YonjPg1eKV46KML8SwQJxLypdR1R6p4tGX77w/whIfsxak13bU+YOnyewOMGU1zzOB wz1T77HxBO74HrQU6yVM8Dze9Wb7Sv7oNAumh3JiOLVnIAWOWZMTqOHMas2uBerm95KE x7NUBTqVdKn/yyiZPdH2W9PUqdW5xdCgPQiw3P1rmKHm0aRf+NblO1Hc5ZyQgIQ9pjKk t8Ag== X-Gm-Message-State: AOJu0YzrprFsY3IZ0NKg1LYYBIWMcHy9Tq0p0qN3guZ9ZsUUdGDVL1j9 x/vfxxqh7AplIfAUJh7qxELUFXWd/RqmCOL6B54tWjR8yZ9A0HBtf0QXEgqMUS7KQzV6f0EXBgb ThJuc+ORaupuvad3lNMqTN/ZxaiYNa20rkZvY6BmCfIRyl+Ft8+YjJKLCyZR0UeUtGiFx43DlPf iXbCLMLb03198PLmDlpJWUgWqzEtW1clfSHJ2S7c8= X-Received: by 2002:a05:600c:5121:b0:431:4b88:d408 with SMTP id 5b1f17b1804b1-4316163520emr125197345e9.5.1729591810586; Tue, 22 Oct 2024 03:10:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJv4+Fr3Onxrgwi+Sa76xEiyaIS92rbONOREWRZWq3Lwox9lcdRK9+O73Eb9AYtVl+pPT6Yg== X-Received: by 2002:a05:600c:5121:b0:431:4b88:d408 with SMTP id 5b1f17b1804b1-4316163520emr125197025e9.5.1729591810012; Tue, 22 Oct 2024 03:10:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org, Zhao Liu Subject: [PATCH v2 03/14] rust: use std::os::raw instead of core::ffi Date: Tue, 22 Oct 2024 12:09:44 +0200 Message-ID: <20241022100956.196657-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591970147116600 Content-Type: text/plain; charset="utf-8" core::ffi::c_* types were introduced in Rust 1.64.0. Use the older types in std::os::raw, which are now aliases of the types in core::ffi. There is no need to compile QEMU as no_std, so this is acceptable as long as we supp= ort a version of Debian with Rust 1.63.0. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- meson.build | 3 +-- rust/hw/char/pl011/src/device.rs | 20 +++++++++++--------- rust/hw/char/pl011/src/lib.rs | 2 +- rust/hw/char/pl011/src/memory_ops.rs | 10 ++++++---- rust/qemu-api/src/definitions.rs | 2 +- rust/qemu-api/src/device_class.rs | 8 ++++---- rust/qemu-api/src/lib.rs | 11 +++++++---- rust/qemu-api/tests/tests.rs | 9 ++++----- 8 files changed, 35 insertions(+), 30 deletions(-) diff --git a/meson.build b/meson.build index 3c71d129494..94f30033f68 100644 --- a/meson.build +++ b/meson.build @@ -3933,14 +3933,13 @@ if have_rust and have_system bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', - '--ctypes-prefix', 'core::ffi', + '--ctypes-prefix', 'std::os::raw', '--formatter', 'rustfmt', '--generate-block', '--generate-cstr', '--impl-debug', '--merge-extern-blocks', '--no-doc-comments', - '--use-core', '--with-derive-default', '--no-layout-tests', '--no-prepend-enum-name', diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index b3d8bc004e0..7be21769ae4 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -2,9 +2,11 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use core::{ - ffi::{c_int, c_uchar, c_uint, c_void, CStr}, - ptr::{addr_of, addr_of_mut, NonNull}, +use core::ptr::{addr_of, addr_of_mut, NonNull}; + +use std::{ + ffi::CStr, + os::raw::{c_int, c_uchar, c_uint, c_void} }; =20 use qemu_api::{ @@ -89,10 +91,10 @@ pub struct PL011Class { =20 impl qemu_api::definitions::Class for PL011Class { const CLASS_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut c_void), > =3D Some(crate::device_class::pl011_class_init); const CLASS_BASE_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut c_void), > =3D None; } =20 @@ -151,7 +153,7 @@ pub unsafe fn init(&mut self) { pub fn read( &mut self, offset: hwaddr, - _size: core::ffi::c_uint, + _size: c_uint, ) -> std::ops::ControlFlow { use RegisterOffset::*; =20 @@ -530,9 +532,9 @@ pub fn update(&self) { /// /// The buffer and size arguments must also be valid. pub unsafe extern "C" fn pl011_receive( - opaque: *mut core::ffi::c_void, + opaque: *mut c_void, buf: *const u8, - size: core::ffi::c_int, + size: c_int, ) { unsafe { debug_assert!(!opaque.is_null()); @@ -552,7 +554,7 @@ pub fn update(&self) { /// We expect the FFI user of this function to pass a valid pointer, that = has /// the same size as [`PL011State`]. We also expect the device is /// readable/writeable from one thread at any time. -pub unsafe extern "C" fn pl011_event(opaque: *mut core::ffi::c_void, event= : QEMUChrEvent) { +pub unsafe extern "C" fn pl011_event(opaque: *mut c_void, event: QEMUChrEv= ent) { unsafe { debug_assert!(!opaque.is_null()); let mut state =3D NonNull::new_unchecked(opaque.cast::= ()); diff --git a/rust/hw/char/pl011/src/lib.rs b/rust/hw/char/pl011/src/lib.rs index 2939ee50c99..2b157868b0f 100644 --- a/rust/hw/char/pl011/src/lib.rs +++ b/rust/hw/char/pl011/src/lib.rs @@ -45,7 +45,7 @@ pub mod device_class; pub mod memory_ops; =20 -pub const TYPE_PL011: &::core::ffi::CStr =3D c"pl011"; +pub const TYPE_PL011: &::std::ffi::CStr =3D c"pl011"; =20 /// Offset of each register from the base memory address of the device. /// diff --git a/rust/hw/char/pl011/src/memory_ops.rs b/rust/hw/char/pl011/src/= memory_ops.rs index 24ac9c870c1..6d822027d51 100644 --- a/rust/hw/char/pl011/src/memory_ops.rs +++ b/rust/hw/char/pl011/src/memory_ops.rs @@ -4,6 +4,8 @@ =20 use core::ptr::NonNull; =20 +use std::os::raw::{c_uint, c_void}; + use qemu_api::{ bindings::*, zeroable::Zeroable @@ -26,9 +28,9 @@ }; =20 unsafe extern "C" fn pl011_read( - opaque: *mut core::ffi::c_void, + opaque: *mut c_void, addr: hwaddr, - size: core::ffi::c_uint, + size: c_uint, ) -> u64 { assert!(!opaque.is_null()); let mut state =3D unsafe { NonNull::new_unchecked(opaque.cast::()) }; @@ -47,10 +49,10 @@ } =20 unsafe extern "C" fn pl011_write( - opaque: *mut core::ffi::c_void, + opaque: *mut c_void, addr: hwaddr, data: u64, - _size: core::ffi::c_uint, + _size: c_uint, ) { unsafe { assert!(!opaque.is_null()); diff --git a/rust/qemu-api/src/definitions.rs b/rust/qemu-api/src/definitio= ns.rs index 064afe60549..26597934bbd 100644 --- a/rust/qemu-api/src/definitions.rs +++ b/rust/qemu-api/src/definitions.rs @@ -4,7 +4,7 @@ =20 //! Definitions required by QEMU when registering a device. =20 -use ::core::ffi::{c_void, CStr}; +use std::{ffi::CStr, os::raw::c_void}; =20 use crate::bindings::{Object, ObjectClass, TypeInfo}; =20 diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index ed2d7ce1a54..5c305d945d3 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -7,7 +7,7 @@ macro_rules! device_class_init { ($func:ident, props =3D> $props:ident, realize_fn =3D> $realize_fn:exp= r, legacy_reset_fn =3D> $legacy_reset_fn:expr, vmsd =3D> $vmsd:ident$(,)*) = =3D> { pub unsafe extern "C" fn $func( klass: *mut $crate::bindings::ObjectClass, - _: *mut ::core::ffi::c_void, + _: *mut ::std::os::raw::c_void, ) { let mut dc =3D ::core::ptr::NonNull::new(klass.cast::<$crate::bindings::D= eviceClass>()).unwrap(); @@ -26,7 +26,7 @@ macro_rules! define_property { ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr, default = =3D $defval:expr$(,)*) =3D> { $crate::bindings::Property { // use associated function syntax for type checking - name: ::core::ffi::CStr::as_ptr($name), + name: ::std::ffi::CStr::as_ptr($name), info: $prop, offset: ::core::mem::offset_of!($state, $field) as isize, set_default: true, @@ -37,7 +37,7 @@ macro_rules! define_property { ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr$(,)*) =3D>= { $crate::bindings::Property { // use associated function syntax for type checking - name: ::core::ffi::CStr::as_ptr($name), + name: ::std::ffi::CStr::as_ptr($name), info: $prop, offset: ::core::mem::offset_of!($state, $field) as isize, set_default: false, @@ -75,7 +75,7 @@ macro_rules! vm_state_description { pub static $name: $crate::bindings::VMStateDescription =3D $crate:= :bindings::VMStateDescription { $(name: { #[used] - static VMSTATE_NAME: &::core::ffi::CStr =3D $vname; + static VMSTATE_NAME: &::std::ffi::CStr =3D $vname; $vname.as_ptr() },)* unmigratable: true, diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index e94a15bb823..321c33d2c7b 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -31,7 +31,10 @@ unsafe impl Sync for bindings::VMStateDescription {} pub mod device_class; pub mod zeroable; =20 -use std::alloc::{GlobalAlloc, Layout}; +use std::{ + alloc::{GlobalAlloc, Layout}, + os::raw::c_void, +}; =20 #[cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)] extern "C" { @@ -45,8 +48,8 @@ fn g_aligned_alloc0( =20 #[cfg(not(HAVE_GLIB_WITH_ALIGNED_ALLOC))] extern "C" { - fn qemu_memalign(alignment: usize, size: usize) -> *mut ::core::ffi::c= _void; - fn qemu_vfree(ptr: *mut ::core::ffi::c_void); + fn qemu_memalign(alignment: usize, size: usize) -> *mut c_void; + fn qemu_vfree(ptr: *mut c_void); } =20 extern "C" { @@ -111,7 +114,7 @@ fn default() -> Self { } =20 // Sanity check. -const _: [(); 8] =3D [(); ::core::mem::size_of::<*mut ::core::ffi::c_void>= ()]; +const _: [(); 8] =3D [(); ::core::mem::size_of::<*mut c_void>()]; =20 unsafe impl GlobalAlloc for QemuAllocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index aa1e0568c69..3396c33fe1e 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -2,7 +2,7 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use core::ffi::CStr; +use std::{ffi::CStr, os::raw::c_void}; =20 use qemu_api::{ bindings::*, @@ -63,11 +63,10 @@ impl ObjectImpl for DummyState { } =20 impl Class for DummyClass { - const CLASS_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core:= :ffi::c_void), - > =3D Some(dummy_class_init); + const CLASS_INIT: Option =3D + Some(dummy_class_init); const CLASS_BASE_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core:= :ffi::c_void), + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut c_voi= d), > =3D None; } =20 --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591861; cv=none; d=zohomail.com; s=zohoarc; b=N973z0HnOdet+M+FgeMhq53yYmkrsqRbtq7Gb5KH2Q/P4lWAzkTZ8IuR/GtnWJfVEOCm8SBG/OByoCA7venbCSxJTuS98Xol1jg2gvD4CR0vxl2I7aXxgQjlKg61a5ZhrUUXq4pTyE0iQTjV2WJxH9dCZDoVVkaTqbwKttytclc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591861; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zoIDQehBCXOq+hK5SCx2x9E41Nu5lYrh5jQDtEdUC3E=; b=gP9NbS4ZPV3IYkkhhO2B5CM1ddJj4dOXmELcRxeWhS+xJe4OD9Mvbn6STc3Efh6KAPU21fDXH+VyveCKMtLOxsrSBZC63Th9ENW12mb5X4Jiv/Q+v5lmuNXplBq3yM//0OTpD2H3wcH0sTju4nVZay5HrTUwRke1MCrwQQ/dpNs= 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 1729591861292928.2694515646335; Tue, 22 Oct 2024 03:11:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3BqJ-0004rx-Ma; Tue, 22 Oct 2024 06:10:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqH-0004rf-Dp for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqF-0004NZ-Lq for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:21 -0400 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-180-VdRURoNlNmGiDy8JdBteMw-1; Tue, 22 Oct 2024 06:10:17 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d47fdbbd6so3187099f8f.3 for ; Tue, 22 Oct 2024 03:10:17 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f570dd5sm83879455e9.3.2024.10.22.03.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zoIDQehBCXOq+hK5SCx2x9E41Nu5lYrh5jQDtEdUC3E=; b=ZLx3XUaufF5hGfTBT6VX/Ob4ZMiuXLnI8FHhExlkp+NbH6Q/thYlVDo+t7rlYZRztcT4+M V5oOFIj35DStUjdMn10vB9QQfW2TACxRkeIleQHyVx/txqGSJi+wOISLTihJ3K2gmVaX3m Kfzrzb1JBJ4Neu0yGmZmeplAeldReYA= X-MC-Unique: VdRURoNlNmGiDy8JdBteMw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591816; x=1730196616; 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=zoIDQehBCXOq+hK5SCx2x9E41Nu5lYrh5jQDtEdUC3E=; b=uqYYVe+fkXZRSa5sdNwcTLZErJNEBW9HXgAXFw4CCNr/4fPblBHxmoF7LGanRefQjU y4t6TxN/yii3EPcmfRQ6SFs9DNjFo90l0g8a3tExX8Zba8zHX4uGOF6qPGIuM969wWpv Si14PkQ3v2tltJMPyDeUduWLi6zXx5ynSK2OIjdYuRJw6Jag8y0fOsd9QPUFD0dtoXGS ZLHlnCd7cXte6Kp1NPxbyECUMvFcjF3DwEuAfMg2Y7bIlJcOzbHKSCQnDXj2bMWd/24O /rRKm+d2BNfPlzuobvPfvEdR6efXUIPRvi0i4viS3XcD6rJpLZGdoYeJvCYf/Maetx6B FYbQ== X-Gm-Message-State: AOJu0Yw8JlUfQyggKHPbyPgkYxopGK2yL6g7QeRYkbUr2IKaHuV41iRL qAsuCsGmB43CIesZFPJWOozYpL6QEIlBKitUO2GFOZrvYYNfDbbgLkR3CisRK0wi2Lv9v+ETK91 VEpgFBvXp37i5pvC9Q7LtBJe+0qUip8fIw2EJm5Tbo5wloLxsN5JUI/L41doAdI3qaFdy8uREpm zVs7QTKFQm6Tz7TQcxwU7XjkTXn6bTWOeLQXawTp8= X-Received: by 2002:adf:f491:0:b0:37d:47f9:be8a with SMTP id ffacd0b85a97d-37ef2040d72mr1443619f8f.0.1729591815616; Tue, 22 Oct 2024 03:10:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHV/5Fa5LQjFFaW5cFo+BfLBeWWn3KlkerhQymuadx9IzZ/+riWB9rstO66wqBfjZMuNIiW8A== X-Received: by 2002:adf:f491:0:b0:37d:47f9:be8a with SMTP id ffacd0b85a97d-37ef2040d72mr1443546f8f.0.1729591813778; Tue, 22 Oct 2024 03:10:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 04/14] rust: introduce a c_str macro Date: Tue, 22 Oct 2024 12:09:45 +0200 Message-ID: <20241022100956.196657-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591863662116600 Content-Type: text/plain; charset="utf-8" This allows CStr constants to be defined easily on Rust 1.63.0, while checking that there are no embedded NULs. c"" literals were only stabilized in Rust 1.77.0. Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 5 ++- rust/hw/char/pl011/src/device_class.rs | 5 ++- rust/hw/char/pl011/src/lib.rs | 4 +- rust/qemu-api/meson.build | 4 ++ rust/qemu-api/src/c_str.rs | 53 ++++++++++++++++++++++++++ rust/qemu-api/src/lib.rs | 1 + rust/qemu-api/tests/tests.rs | 8 ++-- 7 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 rust/qemu-api/src/c_str.rs diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 7be21769ae4..5ffe1911376 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -11,6 +11,7 @@ =20 use qemu_api::{ bindings::{self, *}, + c_str, definitions::ObjectImpl, }; =20 @@ -99,7 +100,7 @@ impl qemu_api::definitions::Class for PL011Class { } =20 #[used] -pub static CLK_NAME: &CStr =3D c"clk"; +pub static CLK_NAME: &CStr =3D c_str!("clk"); =20 impl PL011State { /// Initializes a pre-allocated, unitialized instance of `PL011State`. @@ -575,7 +576,7 @@ pub fn update(&self) { let dev: *mut DeviceState =3D qdev_new(PL011State::TYPE_INFO.name); let sysbus: *mut SysBusDevice =3D dev.cast::(); =20 - qdev_prop_set_chr(dev, c"chardev".as_ptr(), chr); + 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_mmio_map(sysbus, 0, addr); sysbus_connect_irq(sysbus, 0, irq); diff --git a/rust/hw/char/pl011/src/device_class.rs b/rust/hw/char/pl011/sr= c/device_class.rs index 78fa1cdd5b6..3b9b0267b4c 100644 --- a/rust/hw/char/pl011/src/device_class.rs +++ b/rust/hw/char/pl011/src/device_class.rs @@ -6,6 +6,7 @@ =20 use qemu_api::{ bindings::*, + c_str, definitions::ObjectImpl, zeroable::Zeroable, }; @@ -22,14 +23,14 @@ qemu_api::declare_properties! { PL011_PROPERTIES, qemu_api::define_property!( - c"chardev", + c_str!("chardev"), PL011State, char_backend, unsafe { &qdev_prop_chr }, CharBackend ), qemu_api::define_property!( - c"migrate-clk", + c_str!("migrate-clk"), PL011State, migrate_clock, unsafe { &qdev_prop_bool }, diff --git a/rust/hw/char/pl011/src/lib.rs b/rust/hw/char/pl011/src/lib.rs index 2b157868b0f..0a598e5629d 100644 --- a/rust/hw/char/pl011/src/lib.rs +++ b/rust/hw/char/pl011/src/lib.rs @@ -41,11 +41,13 @@ extern crate bilge_impl; extern crate qemu_api; =20 +use qemu_api::c_str; + pub mod device; pub mod device_class; pub mod memory_ops; =20 -pub const TYPE_PL011: &::std::ffi::CStr =3D c"pl011"; +pub const TYPE_PL011: &::std::ffi::CStr =3D c_str!("pl011"); =20 /// Offset of each register from the base memory address of the device. /// diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 1b0fd406378..2b3dea59fb6 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -3,6 +3,7 @@ _qemu_api_rs =3D static_library( structured_sources( [ 'src/lib.rs', + 'src/c_str.rs', 'src/definitions.rs', 'src/device_class.rs', 'src/zeroable.rs', @@ -17,6 +18,9 @@ _qemu_api_rs =3D static_library( ], ) =20 +rust.test('rust-qemu-api-tests', _qemu_api_rs, + suite: ['unit', 'rust']) + qemu_api =3D declare_dependency( link_with: _qemu_api_rs, dependencies: qemu_api_macros, diff --git a/rust/qemu-api/src/c_str.rs b/rust/qemu-api/src/c_str.rs new file mode 100644 index 00000000000..5ef46d12bef --- /dev/null +++ b/rust/qemu-api/src/c_str.rs @@ -0,0 +1,53 @@ +// Copyright 2024 Red Hat, Inc. +// Author(s): Paolo Bonzini +// SPDX-License-Identifier: GPL-2.0-or-later + +#[macro_export] +/// Given a string constant _without_ embedded or trailing NULs, return +/// a CStr. +/// +/// Needed for compatibility with Rust <1.77. +macro_rules! c_str { + ($str:expr) =3D> {{ + const STRING: &str =3D concat!($str, "\0"); + const BYTES: &[u8] =3D STRING.as_bytes(); + + // "for" is not allowed in const context... oh well, + // everybody loves some lisp. This could be turned into + // a procedural macro if this is a problem; alternatively + // Rust 1.72 makes CStr::from_bytes_with_nul a const function. + const fn f(b: &[u8], i: usize) { + if i =3D=3D BYTES.len() - 1 { + } else if BYTES[i] =3D=3D 0 { + panic!("c_str argument contains NUL") + } else { + f(b, i + 1) + } + } + f(BYTES, 0); + + // SAFETY: absence of NULs apart from the final byte was checked a= bove + unsafe { std::ffi::CStr::from_bytes_with_nul_unchecked(BYTES) } + }}; +} + +#[cfg(test)] +mod tests { + use std::ffi::CStr; + + use crate::c_str; + + #[test] + fn test_cstr_macro() { + let good =3D c_str!("=F0=9F=A6=80"); + let good_bytes =3D b"\xf0\x9f\xa6\x80\0"; + assert_eq!(good.to_bytes_with_nul(), good_bytes); + } + + #[test] + fn test_cstr_macro_const() { + const GOOD: &CStr =3D c_str!("=F0=9F=A6=80"); + const GOOD_BYTES: &[u8] =3D b"\xf0\x9f\xa6\x80\0"; + assert_eq!(GOOD.to_bytes_with_nul(), GOOD_BYTES); + } +} diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index 321c33d2c7b..9c3be4f6489 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -27,6 +27,7 @@ unsafe impl Sync for bindings::Property {} unsafe impl Sync for bindings::TypeInfo {} unsafe impl Sync for bindings::VMStateDescription {} =20 +pub mod c_str; pub mod definitions; pub mod device_class; pub mod zeroable; diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 3396c33fe1e..605bc99ed4c 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -6,7 +6,7 @@ =20 use qemu_api::{ bindings::*, - declare_properties, define_property, + c_str, declare_properties, define_property, definitions::{Class, ObjectImpl}, device_class_init, vm_state_description, }; @@ -16,7 +16,7 @@ fn test_device_decl_macros() { // Test that macros can compile. vm_state_description! { VMSTATE, - name: c"name", + name: c_str!("name"), unmigratable: true, } =20 @@ -35,7 +35,7 @@ pub struct DummyClass { declare_properties! { DUMMY_PROPERTIES, define_property!( - c"migrate-clk", + c_str!("migrate-clk"), DummyState, migrate_clock, unsafe { &qdev_prop_bool }, @@ -54,7 +54,7 @@ pub struct DummyClass { impl ObjectImpl for DummyState { type Class =3D DummyClass; const TYPE_INFO: qemu_api::bindings::TypeInfo =3D qemu_api::type_i= nfo! { Self }; - const TYPE_NAME: &'static CStr =3D c"dummy"; + const TYPE_NAME: &'static CStr =3D c_str!("dummy"); const PARENT_TYPE_NAME: Option<&'static CStr> =3D Some(TYPE_DEVICE= ); const ABSTRACT: bool =3D false; const INSTANCE_INIT: Option =3D None; --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591903; cv=none; d=zohomail.com; s=zohoarc; b=G3oeFkoFZ13/FkrdifQkkiMcNL4Ghst4c96aViKCX4h/JCrkIXxyTWcArUlqW3xKm/3wqBVb9bjvgOR9q832suQBTAqR6MkmNkzozZxLGr/dA9tJIV9CMk1V4Qo2v1E4p4gVAeUwBdwjC9/xgKZ/MKwBaaarNnN5HTTpi9K72KM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591903; 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=FhAct4q18ImXFIsWNk2smwgX1VzeDjNJvhYscWcGBhY=; b=hUIPxduQnMThdF/eXXZwu5ppk46SSP2vZxwIQlUghAeLUyO3JakvG40p+BI1q09K2OzkifqBXYOUk8NiCB95BXXgjk9gX6qVqz6Ah1ZLvPOfOPpqu7t5h7t6vqilrU2M5VllUTRP7OGlc27Tt99lgjw/POobaR6L8GRTjNJS/jE= 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 1729591903792733.8827060542477; Tue, 22 Oct 2024 03:11:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3BqU-0004sX-2N; Tue, 22 Oct 2024 06:10:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqM-0004sD-F4 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:27 -0400 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 1t3BqJ-0004O1-GK for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:25 -0400 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-209-HSM7FzGbMFWdl4WtJo0cuw-1; Tue, 22 Oct 2024 06:10:21 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315d98a873so36909055e9.1 for ; Tue, 22 Oct 2024 03:10:21 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a48882sm6257283f8f.30.2024.10.22.03.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591822; 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=FhAct4q18ImXFIsWNk2smwgX1VzeDjNJvhYscWcGBhY=; b=ehLKCrcbpel7YcafEFxnSPUOA+mezi2WVvU2zO3YTGbdQSEGbe+2VxZ3Ryw8aFo+9lmgyE Ae/NlA2Nl6fBS1JIwQqriYdmYDkIQNismsBEUv9mrMlvzi7M3KjwQslVlYncvhFJnhFt9f qQ8HR010vDP/KkJNRKAsbFqQ/GBZRPE= X-MC-Unique: HSM7FzGbMFWdl4WtJo0cuw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591819; x=1730196619; 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=FhAct4q18ImXFIsWNk2smwgX1VzeDjNJvhYscWcGBhY=; b=geNrDPU8nL25EgmZM/nS4JdfBg7Ea5Qho9oHU3n4Ld7h7TBLR8ouoE0HJ0zQqk8gO2 /XxBq1jrxNGaB/pACLyqKs8SW35+1HyzW26jrl/cjPpK169EnJ4MKs5QcfV+moP61DcE 00zGaKGGlrjZMnIy8m0TWqNhYJGXYTm0/QD1ypttuOPc7PknDeD9Xb7aDz8t/+vst/zM 2gYhGA1trDbGqbi1O2vs8JfuFhL5lRc+NwGFWJVgCj0pjX9hM5s0cEjgi4fgSTuqPNBp o3wCTe8Ri6x1OvSmsVAz11rxf2lKIrV5Sv5br8GwZLH7AjDljb75eijrENh8BsArBYSD lhNQ== X-Gm-Message-State: AOJu0Yyf3/unVNI/uH80Zi724cT9kVDJ2usBSVuPJx0frXOVChOzpch8 u4oENVxeMHVwJWJvBbp+dwCSQDOfGw1ndJllMcWcuo2INwsfP+sPGzn1+x7K+/y+OeppFE9V716 OWKPK1hfyh/AXVgvyRz0H/ofsbJxn9zFlUgU+HgQD/i5+lbez+i76N/01iE9Ns8obFShICMLwUY yfuBvYnu6mq+CHqXh28zIMpKBLGdnIy6GvbL5KSUE= X-Received: by 2002:adf:cb09:0:b0:37c:d179:2f73 with SMTP id ffacd0b85a97d-37ef0b7c8a5mr1907599f8f.13.1729591819405; Tue, 22 Oct 2024 03:10:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQHeGfJVT36YqLn+DMDNjjXcUGuP1hlqTqi7nBib4PHBCTALP7lJMDW5934aNhKUagchCtcg== X-Received: by 2002:adf:cb09:0:b0:37c:d179:2f73 with SMTP id ffacd0b85a97d-37ef0b7c8a5mr1907579f8f.13.1729591818925; Tue, 22 Oct 2024 03:10:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 05/14] rust: silence unknown warnings for the sake of old compilers Date: Tue, 22 Oct 2024 12:09:46 +0200 Message-ID: <20241022100956.196657-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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=-1.699, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591905713116600 Content-Type: text/plain; charset="utf-8" Occasionally, we may need to silence warnings and clippy lints that were only introduced in newer Rust compiler versions. However, this would fail when compiling with an older rustc: error: unknown lint: `non_local_definitions` --> rust/qemu-api/rust-qemu-api-tests.p/structured/offset_of.rs:79:17 So by default we need to block the unknown_lints warning. To avoid misspelled lints or other similar issues, re-enable it in the CI job that uses nightly rust. Signed-off-by: Paolo Bonzini --- meson.build | 8 ++++++++ .gitlab-ci.d/buildtest.yml | 2 +- meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 94f30033f68..fe72f9951ca 100644 --- a/meson.build +++ b/meson.build @@ -3327,6 +3327,14 @@ if have_rust and have_system # Prohibit code that is forbidden in Rust 2024 rustc_args +=3D ['-D', 'unsafe_op_in_unsafe_fn'] =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_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/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index 7705000e3cc..4c87f8788d5 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -128,7 +128,7 @@ build-system-fedora-rust-nightly: job: amd64-fedora-rust-nightly-container variables: IMAGE: fedora-rust-nightly - CONFIGURE_ARGS: --disable-docs --enable-rust + CONFIGURE_ARGS: --disable-docs --enable-rust --enable-strict-rust-lints TARGETS: aarch64-softmmu MAKE_CHECK_ARGS: check-build allow_failure: true diff --git a/meson_options.txt b/meson_options.txt index 0ee4d7bb86b..e46199a3232 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -376,3 +376,5 @@ option('x86_version', type : 'combo', choices : ['0', '= 1', '2', '3', '4'], value =20 option('rust', type: 'feature', value: 'disabled', description: 'Rust support') +option('strict_rust_lints', type: 'boolean', value: false, + description: 'Enable stricter set of Rust warnings') diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 6d08605b771..e898b20307d 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -47,6 +47,8 @@ meson_options_help() { printf "%s\n" ' getrandom()' printf "%s\n" ' --enable-safe-stack SafeStack Stack Smash Protecti= on (requires' printf "%s\n" ' clang/llvm and coroutine backe= nd ucontext)' + printf "%s\n" ' --enable-strict-rust-lints' + printf "%s\n" ' Enable stricter set of Rust wa= rnings' printf "%s\n" ' --enable-strip Strip targets on install' printf "%s\n" ' --enable-tcg-interpreter TCG with bytecode interpreter = (slow)' printf "%s\n" ' --enable-trace-backends=3DCHOICES' @@ -490,6 +492,8 @@ _meson_option_parse() { --disable-spice-protocol) printf "%s" -Dspice_protocol=3Ddisabled ;; --enable-stack-protector) printf "%s" -Dstack_protector=3Denabled ;; --disable-stack-protector) printf "%s" -Dstack_protector=3Ddisabled ;; + --enable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=3Dtrue ;; + --disable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=3Dfalse ;; --enable-strip) printf "%s" -Dstrip=3Dtrue ;; --disable-strip) printf "%s" -Dstrip=3Dfalse ;; --sysconfdir=3D*) quote_sh "-Dsysconfdir=3D$2" ;; --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591877; cv=none; d=zohomail.com; s=zohoarc; b=mp3AMMwc/zzyD/u+QmhwSmZ+S8bsJgYDMkNCya313WHWpBgGtK6/OJyJ+tvSPuA73i6lweaLmeNgFU7ONSZyJ7LVP+26Rvno0J6As0M/OJZelkt9FTDLzqjgrQyBdp1BgICzy6AFq71rrliLA3KZv4fn50wRC3bi2RG1a6YxUl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591877; 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=p2uLljYjUly9gfbALpWloSBtc6UsfQdEzE6UaHjO4cY=; b=Bj2Ak+5XfRQ9U5/n++O3gpKwU4jFEiBOl9jc3n1CbKT4SFLuIhkXzRVL7QE4nginfrS1kBJLIzETSJj4RFknY/NWcT1A3oWjVtnygFkhNk0BF+wJCEQc4NZGjfUtIOSfv5ixupx62I2RypZ8hkyR8Is6dPowdFDl1u3cuWV1L2s= 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 1729591877071676.8679812758526; Tue, 22 Oct 2024 03:11:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3Bqb-0004vA-Cl; Tue, 22 Oct 2024 06:10:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqZ-0004uS-0T for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqT-0004Oj-Ti for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:38 -0400 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-256-g0cZToZgMdytz_4yEQpcYw-1; Tue, 22 Oct 2024 06:10:25 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315eaa3189so43705075e9.1 for ; Tue, 22 Oct 2024 03:10:25 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5711b3sm83295015e9.9.2024.10.22.03.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591832; 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=p2uLljYjUly9gfbALpWloSBtc6UsfQdEzE6UaHjO4cY=; b=PuMblHEsDrB9zrnXHutJYtRygWmrjGMh9hgVyIpsjT5U/9CSThapiQOplaSjB9bLEFI/Sg DntNyHtpUdFvRgMzCnxlOOs1B8lvNm0I4zbRnuyjy9PGF8bJNkHMvbWF9yi2Ym66wpDJey eGAI+9Rf7WQ+ZaUEwyxLLmWrJxYKPpY= X-MC-Unique: g0cZToZgMdytz_4yEQpcYw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591822; x=1730196622; 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=p2uLljYjUly9gfbALpWloSBtc6UsfQdEzE6UaHjO4cY=; b=aSHHihYZfYjAxeA8Af46SeCzB99phFxoVnaJVNyjQPnjYiQxqLXm5QuKkpFYf3JFYc 1f7K6dEoGMLSdINPJkvvgCC7DSWz+rok9KofHabt/k7a1TFAUjfTss03woy4oUAX9usO C+tAfUqfoRYQhXHP1EhN1lq2owgADcXAuRrdia3/UA3Lv+0FhGo0S64Q+MntUga/QLR5 Tk7PSsBjlc7cMOoQz4eIL72b0a1frhWg+6RWavsvN1sIPTjnyeSZZmDR2NpMbcC29c2c mlZzbgStSraeMn6XqH1snX1oCjmIBgoK/R/QJhWYFMdzjE7L2+TgyYG1tz2EdF9Wd1lc x8CA== X-Gm-Message-State: AOJu0YxTd56YCaU1yzxURFsMeRgFD3hgij/08hxRUBL0qkw9XBfbtaWW BfKHWxHKLq4bkt8U1gQUJuyCaB2dlbAckv6gQ8GCxS6F/kFAbrXbL999O2049DvMNwnlUfRyQgh qhAyKcmYLgaFRCSsb8eilB4HbufRT3KvtfKgHpnuf3LmuE0tnP+eCbEHEiKKN+LtNYM0elgpC49 pK1q5dsxyOFdtbcdmAtSseN94SfsYU/0qIiKFG2fE= X-Received: by 2002:a05:600c:5118:b0:431:604d:b22 with SMTP id 5b1f17b1804b1-4316163bcbdmr176850915e9.16.1729591822178; Tue, 22 Oct 2024 03:10:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHoS9DC1RJMddRt0hU6ZtpdoDQDkvBCdOP19Ectrf7z2F8rSu2CbtI7oaked69XcOYrgiygw== X-Received: by 2002:a05:600c:5118:b0:431:604d:b22 with SMTP id 5b1f17b1804b1-4316163bcbdmr176850465e9.16.1729591821609; Tue, 22 Oct 2024 03:10:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 06/14] rust: synchronize dependencies between subprojects and Cargo.lock Date: Tue, 22 Oct 2024 12:09:47 +0200 Message-ID: <20241022100956.196657-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1729591877581116600 Content-Type: text/plain; charset="utf-8" The next commit will introduce a new build dependency for rust/qemu-api, version_check. Before adding it, ensure that all dependencies are synchronized between the Meson- and cargo-based build systems. Note that it's not clear whether in the long term we'll use Cargo for anything; it seems that the three main uses (clippy, rustfmt, rustdoc) can all be invoked manually---either via glue code in QEMU, or by extending Meson to gain the relevant functionality. However, for the time being we're stuck with Cargo so it should at least look at the same code as the rest of the build system. Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/Cargo.lock | 5 +++- rust/qemu-api-macros/Cargo.lock | 11 ++++---- rust/qemu-api/Cargo.lock | 49 ++++++++++++++++++++++++++++++++- rust/qemu-api/Cargo.toml | 1 + 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/rust/hw/char/pl011/Cargo.lock b/rust/hw/char/pl011/Cargo.lock index b58cebb186e..82028ddf793 100644 --- a/rust/hw/char/pl011/Cargo.lock +++ b/rust/hw/char/pl011/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version =3D 3 +version =3D 4 =20 [[package]] name =3D "arbitrary-int" @@ -91,6 +91,9 @@ dependencies =3D [ [[package]] name =3D "qemu_api" version =3D "0.1.0" +dependencies =3D [ + "qemu_api_macros", +] =20 [[package]] name =3D "qemu_api_macros" diff --git a/rust/qemu-api-macros/Cargo.lock b/rust/qemu-api-macros/Cargo.l= ock index fdc0fce116c..779b0ac6a25 100644 --- a/rust/qemu-api-macros/Cargo.lock +++ b/rust/qemu-api-macros/Cargo.lock @@ -1,12 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version =3D 3 +version =3D 4 =20 [[package]] name =3D "proc-macro2" -version =3D "1.0.86" +version =3D "1.0.84" source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae10= 3b77" +checksum =3D "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a= 49d6" dependencies =3D [ "unicode-ident", ] @@ -18,6 +18,7 @@ dependencies =3D [ "proc-macro2", "quote", "syn", + "unicode-ident", ] =20 [[package]] @@ -31,9 +32,9 @@ dependencies =3D [ =20 [[package]] name =3D "syn" -version =3D "2.0.72" +version =3D "2.0.66" source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7= a8af" +checksum =3D "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cd= cff5" dependencies =3D [ "proc-macro2", "quote", diff --git a/rust/qemu-api/Cargo.lock b/rust/qemu-api/Cargo.lock index e9c51a243a8..468293feedd 100644 --- a/rust/qemu-api/Cargo.lock +++ b/rust/qemu-api/Cargo.lock @@ -1,7 +1,54 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version =3D 3 +version =3D 4 + +[[package]] +name =3D "proc-macro2" +version =3D "1.0.84" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a= 49d6" +dependencies =3D [ + "unicode-ident", +] =20 [[package]] name =3D "qemu_api" version =3D "0.1.0" +dependencies =3D [ + "qemu_api_macros", +] + +[[package]] +name =3D "qemu_api_macros" +version =3D "0.1.0" +dependencies =3D [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name =3D "quote" +version =3D "1.0.36" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208ac= aca7" +dependencies =3D [ + "proc-macro2", +] + +[[package]] +name =3D "syn" +version =3D "2.0.66" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cd= cff5" +dependencies =3D [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name =3D "unicode-ident" +version =3D "1.0.12" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0f= ee4b" diff --git a/rust/qemu-api/Cargo.toml b/rust/qemu-api/Cargo.toml index 3677def3fe2..db594c64083 100644 --- a/rust/qemu-api/Cargo.toml +++ b/rust/qemu-api/Cargo.toml @@ -14,6 +14,7 @@ keywords =3D [] categories =3D [] =20 [dependencies] +qemu_api_macros =3D { path =3D "../qemu-api-macros" } =20 [features] default =3D [] --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591933; cv=none; d=zohomail.com; s=zohoarc; b=eMt/zWJttvs+b8QrgL7TuTS4xs7+4/fv+u9GIUiZVUEzrye/9c0m5ASXVwvzQ+U1SNATxlZ5oq0DSYQPR4dvZVhL31fPn8JgmHbOwR8tYcCVtPXRITSa96KPbhq2uvzF4Yl6JmVE8GoiA/OmYKIUIP1TVyGYwcpjMSMeKsCzUYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591933; 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=yBchrBlim6aYT5+mpyUWgR4s/JYFs7BD36LJ5gWznMw=; b=MXX3fdZPnmYJxCR8mkXfcApmpFd2zt1Oit392UYTB3dBh9iEzXJ4qeYjDwgHbez2RWXpJvrr9Ej4yA4B0H/Z6jTSp6CiZX1CG31RMvVKnoyZ+piBkNpHgxJKgJe7y6KiP4HeMxvCWhU1A4eJKxqTeKOUDwJH2TlSHUQvQr6bzdc= 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 172959193376294.18400256750795; Tue, 22 Oct 2024 03:12:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3BqY-0004u6-As; Tue, 22 Oct 2024 06:10:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqV-0004tQ-ES for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqR-0004Od-D9 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:34 -0400 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-658-g-A0iFiVMOue-11gTz6pIA-1; Tue, 22 Oct 2024 06:10:29 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4315eaa3189so43705645e9.1 for ; Tue, 22 Oct 2024 03:10:29 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431805a8583sm6287055e9.48.2024.10.22.03.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591830; 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=yBchrBlim6aYT5+mpyUWgR4s/JYFs7BD36LJ5gWznMw=; b=dSCVQvNlrzupPWK5p16QOpQhgSo3200hs90D/TbHmY8fd5n/iX2Pigkn1+thNFP3rU+vEn jBUF0bYFkPEr14diQhZxd0shU66StwGq0gq8vPQebiYvf0iGu7vhuaujbj1zvSCZCtYDb7 4HsK5nDpbXuuXs4FBAwlZnwcYfe3x0s= X-MC-Unique: g-A0iFiVMOue-11gTz6pIA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591827; x=1730196627; 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=yBchrBlim6aYT5+mpyUWgR4s/JYFs7BD36LJ5gWznMw=; b=xAKf4TO8C2tZAkq8NTvS1HOqaFGXsOMiHX9ifv2lxtJGpAT9WhMwyot00sGRcea/xc /UwHuMUm+Z0DwMrIbOsrMHpXOZt5Kv4fsQyZCB4/i6mlnVUg+kpvL/OQW5HoCtcpTIFo ZTv1o83DZ/p6ekrW4zAZDz4VYSQ5aDuxjtW+HSZgCgfLdvuSmkzJY2zNvdPdxxMlalrs /iDiRSO6YZlL3ITt/O5QQxfLJdajYDGDJHuUK0lvaFw6VzK9wtcu8uc3xKo4Mr6U9/6H 7deVGrbjg2ipJ2qulIXvOrw8pZPgbR+fbl/g4hhCv+jLhpNavcF0rnufa/vxeaV5GyPe Z1Pg== X-Gm-Message-State: AOJu0YxvULBZuSHgPb1RAzlAGxlc86RTAXaV6l/aS/sg6W7ORV/m6Toy M45BTGSg+Sl0K8gQZj2Ia2Um2VADrqGJ31KsK7NHKaL5eXVM8MbcYdyJ9nHO+A1w+ir5FdVzEwT 3T1X0YZQFxfaRqbvVgPjR8zlPSY7BqFMAL1jYQRpH+nTRy3M3xhnVN8qOPoBdu+kh20YBl9ENp2 nKcLQ/e52xBM5LyS68C+SytutFYabXfHRkNZgJegQ= X-Received: by 2002:a05:600c:5489:b0:431:24c3:dbaa with SMTP id 5b1f17b1804b1-4316161eeaamr144556885e9.2.1729591827193; Tue, 22 Oct 2024 03:10:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1SfvfTluFev9BgEl9+dkTmUGHtWKuxlCnQ21W7oWMzQzPNPw8Gl95aBTc/lNhhoSNQAoAOw== X-Received: by 2002:a05:600c:5489:b0:431:24c3:dbaa with SMTP id 5b1f17b1804b1-4316161eeaamr144556545e9.2.1729591826527; Tue, 22 Oct 2024 03:10:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 07/14] rust: introduce alternative implementation of offset_of! Date: Tue, 22 Oct 2024 12:09:48 +0200 Message-ID: <20241022100956.196657-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591936188116600 Content-Type: text/plain; charset="utf-8" From: Junjie Mao offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation that was found on the Rust forums, and whose author agreed to license as MIT for use in QEMU. The alternative allows only one level of field access, but apart from this can be used just by replacing core::mem::offset_of! with qemu_api::offset_of!. The actual implementation of offset_of! is done in a declarative macro, but for simplicity and to avoid introducing an extra level of indentation, the trigger is a procedural macro #[derive(offsets)]. Signed-off-by: Junjie Mao Co-developed-by: Paolo Bonzini Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/Cargo.lock | 1 + rust/hw/char/pl011/src/device.rs | 2 +- rust/qemu-api-macros/Cargo.toml | 5 +- rust/qemu-api-macros/src/lib.rs | 29 +++- rust/qemu-api/Cargo.lock | 7 + rust/qemu-api/Cargo.toml | 6 +- rust/qemu-api/build.rs | 8 + rust/qemu-api/meson.build | 12 +- rust/qemu-api/src/device_class.rs | 8 +- rust/qemu-api/src/lib.rs | 4 + rust/qemu-api/src/offset_of.rs | 161 ++++++++++++++++++ rust/qemu-api/tests/tests.rs | 1 + subprojects/packagefiles/syn-2-rs/meson.build | 1 + 13 files changed, 232 insertions(+), 13 deletions(-) create mode 100644 rust/qemu-api/src/offset_of.rs diff --git a/rust/hw/char/pl011/Cargo.lock b/rust/hw/char/pl011/Cargo.lock index 82028ddf793..087658ca72b 100644 --- a/rust/hw/char/pl011/Cargo.lock +++ b/rust/hw/char/pl011/Cargo.lock @@ -93,6 +93,7 @@ name =3D "qemu_api" version =3D "0.1.0" dependencies =3D [ "qemu_api_macros", + "version_check", ] =20 [[package]] diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 5ffe1911376..c26d21e079d 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -29,7 +29,7 @@ pub const PL011_FIFO_DEPTH: usize =3D 16_usize; =20 #[repr(C)] -#[derive(Debug, qemu_api_macros::Object)] +#[derive(Debug, qemu_api_macros::Object, qemu_api_macros::offsets)] /// PL011 Device Model in QEMU pub struct PL011State { pub parent_obj: SysBusDevice, diff --git a/rust/qemu-api-macros/Cargo.toml b/rust/qemu-api-macros/Cargo.t= oml index 144cc3650fa..47fec2e4637 100644 --- a/rust/qemu-api-macros/Cargo.toml +++ b/rust/qemu-api-macros/Cargo.toml @@ -19,7 +19,10 @@ proc-macro =3D true [dependencies] proc-macro2 =3D "1" quote =3D "1" -syn =3D "2" + +[dependencies.syn] +version =3D "2" +features=3D ["extra-traits"] =20 # Do not include in any global workspace [workspace] diff --git a/rust/qemu-api-macros/src/lib.rs b/rust/qemu-api-macros/src/lib= .rs index a4bc5d01ee8..472264159d6 100644 --- a/rust/qemu-api-macros/src/lib.rs +++ b/rust/qemu-api-macros/src/lib.rs @@ -3,8 +3,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 use proc_macro::TokenStream; -use quote::quote; -use syn::{parse_macro_input, DeriveInput}; +use quote::{quote, quote_spanned}; +use syn::{parse_macro_input, parse_quote, spanned::Spanned, Attribute, Der= iveInput}; =20 #[proc_macro_derive(Object)] pub fn derive_object(input: TokenStream) -> TokenStream { @@ -21,3 +21,28 @@ pub fn derive_object(input: TokenStream) -> TokenStream { =20 TokenStream::from(expanded) } + +#[proc_macro_derive(offsets)] +pub fn derive_offsets(input: TokenStream) -> TokenStream { + let input =3D parse_macro_input!(input as DeriveInput); + let repr_c: Attribute =3D parse_quote! { #[repr(C)] }; + + // All the work for expanding this macro is done in "with_offsets!", + // a macro in the qemu_api crate which re-parses the struct declaratio= n; + // this derive macro is just a convenience. + // + // The with_offsets! macro expands to nothing if the compiler is new e= nough + // to have a stable offset_of. + let expanded =3D if !input.attrs.iter().any(|x| *x =3D=3D repr_c) { + quote_spanned! { + input.span() =3D> + compile_error!("expected #[repr(C)] together with #[derive(off= sets)]"); + } + } else { + quote! { + ::qemu_api::with_offsets! { #input } + } + }; + + TokenStream::from(expanded) +} diff --git a/rust/qemu-api/Cargo.lock b/rust/qemu-api/Cargo.lock index 468293feedd..371c6167918 100644 --- a/rust/qemu-api/Cargo.lock +++ b/rust/qemu-api/Cargo.lock @@ -16,6 +16,7 @@ name =3D "qemu_api" version =3D "0.1.0" dependencies =3D [ "qemu_api_macros", + "version_check", ] =20 [[package]] @@ -52,3 +53,9 @@ name =3D "unicode-ident" version =3D "1.0.12" source =3D "registry+https://github.com/rust-lang/crates.io-index" checksum =3D "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0f= ee4b" + +[[package]] +name =3D "version_check" +version =3D "0.9.4" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e= 483f" diff --git a/rust/qemu-api/Cargo.toml b/rust/qemu-api/Cargo.toml index db594c64083..9c3a99522a9 100644 --- a/rust/qemu-api/Cargo.toml +++ b/rust/qemu-api/Cargo.toml @@ -16,6 +16,9 @@ categories =3D [] [dependencies] qemu_api_macros =3D { path =3D "../qemu-api-macros" } =20 +[build-dependencies] +version_check =3D "~0.9" + [features] default =3D [] allocator =3D [] @@ -24,4 +27,5 @@ allocator =3D [] [workspace] =20 [lints.rust] -unexpected_cfgs =3D { level =3D "warn", check-cfg =3D ['cfg(MESON)', 'cfg(= HAVE_GLIB_WITH_ALIGNED_ALLOC)'] } +unexpected_cfgs =3D { level =3D "warn", check-cfg =3D ['cfg(MESON)', 'cfg(= HAVE_GLIB_WITH_ALIGNED_ALLOC)', + 'cfg(has_offset_of)'] } diff --git a/rust/qemu-api/build.rs b/rust/qemu-api/build.rs index 419b154c2d2..0a68c3712f1 100644 --- a/rust/qemu-api/build.rs +++ b/rust/qemu-api/build.rs @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 use std::path::Path; +use version_check as rustc; =20 fn main() { if !Path::new("src/bindings.rs").exists() { @@ -11,4 +12,11 @@ fn main() { (`ninja bindings.rs`) and copy them to src/bindings.rs, or bu= ild through meson." ); } + + // Check for available rustc features + if rustc::is_min_version("1.77.0").unwrap_or(false) { + println!("cargo:rustc-cfg=3Dhas_offset_of"); + } + + println!("cargo:rerun-if-changed=3Dbuild.rs"); } diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 2b3dea59fb6..4ac33acced3 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -1,3 +1,9 @@ +_qemu_api_cfg =3D ['--cfg', 'MESON'] +# _qemu_api_cfg +=3D ['--cfg', 'feature=3D"allocator"'] +if rustc.version().version_compare('>=3D1.77.0') + _qemu_api_cfg +=3D ['--cfg', 'has_offset_of'] +endif + _qemu_api_rs =3D static_library( 'qemu_api', structured_sources( @@ -6,16 +12,14 @@ _qemu_api_rs =3D static_library( 'src/c_str.rs', 'src/definitions.rs', 'src/device_class.rs', + 'src/offset_of.rs', 'src/zeroable.rs', ], {'.' : bindings_rs}, ), override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', - rust_args: [ - '--cfg', 'MESON', - # '--cfg', 'feature=3D"allocator"', - ], + rust_args: _qemu_api_cfg, ) =20 rust.test('rust-qemu-api-tests', _qemu_api_rs, diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index 5c305d945d3..ce3d5f50507 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -23,23 +23,23 @@ macro_rules! device_class_init { =20 #[macro_export] macro_rules! define_property { - ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr, default = =3D $defval:expr$(,)*) =3D> { + ($name:expr, $state:ty, $field:ident, $prop:expr, $type:expr, default = =3D $defval:expr$(,)*) =3D> { $crate::bindings::Property { // use associated function syntax for type checking name: ::std::ffi::CStr::as_ptr($name), info: $prop, - offset: ::core::mem::offset_of!($state, $field) as isize, + offset: $crate::offset_of!($state, $field) as isize, set_default: true, defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval.= into() }, ..$crate::zeroable::Zeroable::ZERO } }; - ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr$(,)*) =3D>= { + ($name:expr, $state:ty, $field:ident, $prop:expr, $type:expr$(,)*) =3D= > { $crate::bindings::Property { // use associated function syntax for type checking name: ::std::ffi::CStr::as_ptr($name), info: $prop, - offset: ::core::mem::offset_of!($state, $field) as isize, + offset: $crate::offset_of!($state, $field) as isize, set_default: false, ..$crate::zeroable::Zeroable::ZERO } diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index 9c3be4f6489..92f1785d891 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -30,6 +30,7 @@ unsafe impl Sync for bindings::VMStateDescription {} pub mod c_str; pub mod definitions; pub mod device_class; +pub mod offset_of; pub mod zeroable; =20 use std::{ @@ -166,3 +167,6 @@ unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { } } } + +#[cfg(has_offset_of)] +pub use std::mem::offset_of; diff --git a/rust/qemu-api/src/offset_of.rs b/rust/qemu-api/src/offset_of.rs new file mode 100644 index 00000000000..87db8607592 --- /dev/null +++ b/rust/qemu-api/src/offset_of.rs @@ -0,0 +1,161 @@ +// SPDX-License-Identifier: MIT + +/// This macro provides the same functionality as `core::mem::offset_of`, +/// except that only one level of field access is supported. The declarat= ion +/// of the struct must be wrapped with `with_offsets! { }`. +/// +/// It is needed because `offset_of!` was only stabilized in Rust 1.77. +#[cfg(not(has_offset_of))] +#[macro_export] +macro_rules! offset_of { + ($Container:ty, $field:ident) =3D> { + <$Container>::OFFSET_TO__.$field + }; +} + +/// A wrapper for struct declarations, that allows using `offset_of!` in +/// versions of Rust prior to 1.77 +#[macro_export] +macro_rules! with_offsets { + // This method to generate field offset constants comes from: + // + // https://play.rust-lang.org/?version=3Dstable&mode=3Ddebug&editi= on=3D2018&gist=3D10a22a9b8393abd7b541d8fc844bc0df + // + // used under MIT license with permission of Yandros aka Daniel Henry-= Mantilla + ( + $(#[$struct_meta:meta])* + $struct_vis:vis + struct $StructName:ident { + $( + $(#[$field_meta:meta])* + $field_vis:vis + $field_name:ident : $field_ty:ty + ),* + $(,)? + } + ) =3D> ( + #[cfg(not(has_offset_of))] + const _: () =3D { + struct StructOffsetsHelper(std::marker::PhantomData); + const END_OF_PREV_FIELD: usize =3D 0; + + // populate StructOffsetsHelper with associated consts, + // one for each field + $crate::with_offsets! { + @struct $StructName + @names [ $($field_name)* ] + @tys [ $($field_ty ,)*] + } + + // now turn StructOffsetsHelper's consts into a single stru= ct, + // applying field visibility. This provides better error mess= ages + // than if offset_of! used StructOffsetsHelper:: directly. + pub + struct StructOffsets { + $( + $field_vis + $field_name: usize, + )* + } + impl $StructName { + pub + const OFFSET_TO__: StructOffsets =3D StructOffsets { + $( + $field_name: StructOffsetsHelper::<$StructName>::$= field_name, + )* + }; + } + }; + ); + + ( + @struct $StructName:ident + @names [] + @tys [] + ) =3D> (); + + ( + @struct $StructName:ident + @names [$field_name:ident $($other_names:tt)*] + @tys [$field_ty:ty , $($other_tys:tt)*] + ) =3D> ( + #[allow(non_local_definitions)] + #[allow(clippy::modulo_one)] + impl StructOffsetsHelper<$StructName> { + #[allow(nonstandard_style)] + const $field_name: usize =3D { + const ALIGN: usize =3D std::mem::align_of::<$field_ty>(); + const TRAIL: usize =3D END_OF_PREV_FIELD % ALIGN; + END_OF_PREV_FIELD + (if TRAIL =3D=3D 0 { 0usize } else { A= LIGN - TRAIL }) + }; + } + const _: () =3D { + const END_OF_PREV_FIELD: usize =3D + StructOffsetsHelper::<$StructName>::$field_name + + std::mem::size_of::<$field_ty>() + ; + $crate::with_offsets! { + @struct $StructName + @names [$($other_names)*] + @tys [$($other_tys)*] + } + }; + ); +} + +#[cfg(test)] +mod tests { + use crate::offset_of; + + #[repr(C)] + struct Foo { + a: u16, + b: u32, + c: u64, + d: u16, + } + + #[repr(C)] + struct Bar { + pub a: u16, + pub b: u64, + c: Foo, + d: u64, + } + + crate::with_offsets! { + #[repr(C)] + struct Bar { + pub a: u16, + pub b: u64, + c: Foo, + d: u64, + } + } + + #[repr(C)] + pub struct Baz { + b: u32, + a: u8, + } + crate::with_offsets! { + #[repr(C)] + pub struct Baz { + b: u32, + a: u8, + } + } + + #[test] + fn test_offset_of() { + const OFFSET_TO_C: usize =3D offset_of!(Bar, c); + + assert_eq!(offset_of!(Bar, a), 0); + assert_eq!(offset_of!(Bar, b), 8); + assert_eq!(OFFSET_TO_C, 16); + assert_eq!(offset_of!(Bar, d), 40); + + assert_eq!(offset_of!(Baz, b), 0); + assert_eq!(offset_of!(Baz, a), 4); + } +} diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 605bc99ed4c..96e413b75ee 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -20,6 +20,7 @@ fn test_device_decl_macros() { unmigratable: true, } =20 + #[derive(qemu_api_macros::offsets)] #[repr(C)] #[derive(qemu_api_macros::Object)] pub struct DummyState { diff --git a/subprojects/packagefiles/syn-2-rs/meson.build b/subprojects/pa= ckagefiles/syn-2-rs/meson.build index a53335f3092..9f56ce1c24d 100644 --- a/subprojects/packagefiles/syn-2-rs/meson.build +++ b/subprojects/packagefiles/syn-2-rs/meson.build @@ -24,6 +24,7 @@ _syn_rs =3D static_library( '--cfg', 'feature=3D"printing"', '--cfg', 'feature=3D"clone-impls"', '--cfg', 'feature=3D"proc-macro"', + '--cfg', 'feature=3D"extra-traits"', ], dependencies: [ quote_dep, --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591935; cv=none; d=zohomail.com; s=zohoarc; b=ReLowp6ssaOJk9bP/CsrXTW+QaQU0aiYo2Pc9I4kfnLihw+TeUEDIyq9YP7+9nuT+cHiGUhX9NxyqYqOrNxDIGHJpcAcpf94hEVMUoOWDZPWbSE92EfVfVRdaw90Sht1gXe4K2Ej2Knem5rGfUXAji2DPEBhSLysFWqU04IJtRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591935; 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=03JiRCmWWZh2jJskiShZoJxz/aHC3ZzZOgP/wBs0hjc=; b=PXLnip72sK3XB5Zmqa/0+87nN4ztZ7cOUriUFUyQB2IjT31oLII+/5E4hIDyV/Cb/gwN6Y/Fos6iH1Tn3Ce7iFZpZCInJy95YO4piDmX2uFy+BTEERjPDSzAxG/LLZncdF+JzLP7l2CyWeQGIovBGXdrXAn44akHQn/jYpAsZgM= 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 1729591935552412.2406714500456; Tue, 22 Oct 2024 03:12:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3Bqa-0004uo-8d; Tue, 22 Oct 2024 06:10:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqW-0004tX-II for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:36 -0400 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 1t3BqU-0004Oo-1t for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:36 -0400 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-375-7AElOKDfPgqeNM6EwSfBVg-1; Tue, 22 Oct 2024 06:10:32 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315dd8fe7fso45269605e9.3 for ; Tue, 22 Oct 2024 03:10:31 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5cc183sm83173315e9.40.2024.10.22.03.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591833; 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=03JiRCmWWZh2jJskiShZoJxz/aHC3ZzZOgP/wBs0hjc=; b=Nlrbu5pC3o1CQQDM1AxBB3wvtQq+3+z2DHy79F95PusgjSb0v1oVIm4toEp+eVile8yNGh REEBjwnLk4JMucsBt9NwSaYIoYlX3+B+EXaN/9RHKPsjYSTPNACljnB9a4LE/n5W8Ap26W IdAhpkUF5tpuuim3OUNqhND/3Bi+/oM= X-MC-Unique: 7AElOKDfPgqeNM6EwSfBVg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591830; x=1730196630; 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=03JiRCmWWZh2jJskiShZoJxz/aHC3ZzZOgP/wBs0hjc=; b=OMq8sbhg8tIYclb4jYBZqdTJq0wBxPnRFq4e5JY8eIzO/tQeP3EQ7Wi4SC2otjiufx pmjwxcLRvstPRqdZY7OwSc8dijolNp/FzTfEoDYyVEnX1i9Niz40VkUC9H9K/CwXmAA3 Al26X6fVe3ozdooF+CgzsvT1CqT+3qvVEpz2jGrdtJY6u+vnCHrdtqLwt2RnA7RStjux HrVRg2zmuHkHvtco2qflsdZMisZVtdVAWHrs7DLE/5ZBmxShteMrW2sYCHfPgoWihpUf ZGekIgxHZEnzAbteQhFHeXlp6KFIIgabdevXINqG4dgyItZIhOVFBupiKJDZK1Spna/R MuoQ== X-Gm-Message-State: AOJu0Yydu1E2ZUD749mqxd/NdLHiF8Z2y8ZST+nZk7kNAakRtYkXjH6z hpC0R/L2V2sPMQXpsVJ89zCrQjnpdkrYwRHK6KwVKld66e2m27EIdigPXC9LlQcBPJC/pPyB5Y9 ou/J3D40sjUaD2FfM1AwDJrg7sHG/jWYomAzmCCodseSkergPxa8TDM4dc8SZMBQXmZWyFGP0Rx z12Veg8D0xy2yCJlejeHNtnXsx85X2U8eIc3kU2hM= X-Received: by 2002:a05:600c:6747:b0:431:5ba1:a520 with SMTP id 5b1f17b1804b1-4316161ef0bmr156590505e9.3.1729591830088; Tue, 22 Oct 2024 03:10:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeXIzdAkgD/irfpaEYUIV1U1m1yqe+mtDkoib8cYmNAUb4ZS087N2QLxFwDJ4XbqUxXSPPVg== X-Received: by 2002:a05:600c:6747:b0:431:5ba1:a520 with SMTP id 5b1f17b1804b1-4316161ef0bmr156590225e9.3.1729591829637; Tue, 22 Oct 2024 03:10:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 08/14] rust: do not use MaybeUninit::zeroed() Date: Tue, 22 Oct 2024 12:09:49 +0200 Message-ID: <20241022100956.196657-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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=-1.699, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591936026116600 Content-Type: text/plain; charset="utf-8" MaybeUninit::zeroed() is handy is not available as a "const" function until Rust 1.75.0. Remove the default implemntation of Zeroable::ZERO, and write by hand the definitions for those types that need it. It may be possible to add automatic implementation of the trait, via a procedural macro and/or a trick similar to offset_of!, but do it the easy way for now. Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/zeroable.rs | 91 +++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/rust/qemu-api/src/zeroable.rs b/rust/qemu-api/src/zeroable.rs index 45ec95c9f70..13cdb2ccba5 100644 --- a/rust/qemu-api/src/zeroable.rs +++ b/rust/qemu-api/src/zeroable.rs @@ -1,23 +1,86 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 +use std::ptr; + /// Encapsulates the requirement that -/// `MaybeUninit::::zeroed().assume_init()` does not cause -/// undefined behavior. +/// `MaybeUninit::::zeroed().assume_init()` does not cause undefined +/// behavior. This trait in principle could be implemented as just: +/// +/// ``` +/// const ZERO: Self =3D unsafe { +/// ::core::mem::MaybeUninit::<$crate::bindings::Property>::zeroed= ().assume_init() +/// }, +/// ``` +/// +/// The need for a manual implementation is only because `zeroed()` cannot +/// be used as a `const fn` prior to Rust 1.75.0. Once we can assume a new +/// enough version of the compiler, we could provide a `#[derive(Zeroable)= ]` +/// macro to check at compile-time that all struct fields are Zeroable, and +/// use the above blanket implementation of the `ZERO` constant. /// /// # Safety /// -/// Do not add this trait to a type unless all-zeroes is -/// a valid value for the type. In particular, remember that raw -/// pointers can be zero, but references and `NonNull` cannot -/// unless wrapped with `Option<>`. +/// Because the implementation of `ZERO` is manual, it does not make +/// any assumption on the safety of `zeroed()`. However, other users of t= he +/// trait could use it that way. Do not add this trait to a type unless +/// all-zeroes is a valid value for the type. In particular, remember that +/// raw pointers can be zero, but references and `NonNull` cannot pub unsafe trait Zeroable: Default { - /// SAFETY: If the trait was added to a type, then by definition - /// this is safe. - const ZERO: Self =3D unsafe { ::core::mem::MaybeUninit::::zeroed= ().assume_init() }; + const ZERO: Self; } =20 -unsafe impl Zeroable for crate::bindings::Property__bindgen_ty_1 {} -unsafe impl Zeroable for crate::bindings::Property {} -unsafe impl Zeroable for crate::bindings::VMStateDescription {} -unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_1 {} -unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_2 {} +unsafe impl Zeroable for crate::bindings::Property__bindgen_ty_1 { + const ZERO: Self =3D Self { i: 0 }; +} + +unsafe impl Zeroable for crate::bindings::Property { + const ZERO: Self =3D Self { + name: ptr::null(), + info: ptr::null(), + offset: 0, + bitnr: 0, + bitmask: 0, + set_default: false, + defval: Zeroable::ZERO, + arrayoffset: 0, + arrayinfo: ptr::null(), + arrayfieldsize: 0, + link_type: ptr::null(), + }; +} + +unsafe impl Zeroable for crate::bindings::VMStateDescription { + const ZERO: Self =3D Self { + name: ptr::null(), + unmigratable: false, + early_setup: false, + version_id: 0, + minimum_version_id: 0, + priority: crate::bindings::MigrationPriority::MIG_PRI_DEFAULT, + pre_load: None, + post_load: None, + pre_save: None, + post_save: None, + needed: None, + dev_unplug_pending: None, + fields: ptr::null(), + subsections: ptr::null(), + }; +} + +unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_1 { + const ZERO: Self =3D Self { + min_access_size: 0, + max_access_size: 0, + unaligned: false, + accepts: None, + }; +} + +unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_2 { + const ZERO: Self =3D Self { + min_access_size: 0, + max_access_size: 0, + unaligned: false, + }; +} --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591900; cv=none; d=zohomail.com; s=zohoarc; b=AJP6x/hwCqbqncYl77xI2ussTo+iivqIPffL6Ch6UmBCF9PlTc3moCx3EkHHDQ8cOc9Kf1x5cuEEizknPUaGCS07eRFIwDP3RNkiRjZFJxY4t6tvmljUGEeO7xNY/sg3ABOuqb+P+j1wy6laxTp8L/QJTOeuXP9GPJrORQXyMRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591900; 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=8J+8xZYPHbr72c/IJr5xzYf68Dz55JZJUDo+rchRnfs=; b=nZdMhx2RCkEYO8ctOgWFyQcH5bFOctanOiN7YQdJvMEwl5Yx4evAVPVN35g1qFaAN7UTmfBtilKEGC5XH3zVQ97fEx9CtB9XcZr9vHOckQgFv59tbe0mZIo3cx8hlR0WnZewsf7VwRD0jY2FhinDciXn5QQqEPzpHszOjCewB5o= 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 1729591900517366.8575870783943; Tue, 22 Oct 2024 03:11:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3Bqb-0004uv-3h; Tue, 22 Oct 2024 06:10:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3BqZ-0004uT-0W for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:39 -0400 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 1t3BqX-0004P4-8p for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:38 -0400 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-575-fSTsnomuNvqtEb2DW1GSZA-1; Tue, 22 Oct 2024 06:10:35 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d49887a2cso3024973f8f.0 for ; Tue, 22 Oct 2024 03:10:35 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a4ac2esm6272449f8f.44.2024.10.22.03.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591836; 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=8J+8xZYPHbr72c/IJr5xzYf68Dz55JZJUDo+rchRnfs=; b=BWafTN9ooCu3Q8HwEY3llSWVzmktRORBy9JuRoQG5KsX6vNVasabn+GSplXi4nazB/vOWz Ryp1KgecSWRdF2IX1CeWu268eFmyJ7DQNapqD+hbeF/lqdMZfdSgyLAVYeQTCgUkdQ+tUZ RzNXNc4I2QMmPHNL08d8Rc7/WKY3IVo= X-MC-Unique: fSTsnomuNvqtEb2DW1GSZA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591833; x=1730196633; 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=8J+8xZYPHbr72c/IJr5xzYf68Dz55JZJUDo+rchRnfs=; b=Xqo7lzCHwB8R8I4Qwnp60oeIaUbOfaWjTv9iJOXNyywushUHvKpZBMrNLi3V0X5ne/ 6eqctI+qYOWQzCqv7sTTWOAC6hTd/rqOIKP+6m5q/GW6b58tWaOk7g9rGmq783PDfCRA uYwRhoD0p+VpXHGMVHkwTBNnpVudfS14EWzf4vguZwm7A/TfMxBe3Lkr9ianbTLAKB0D 9aEooh8YcAg/Xz8vjf4LZL/+1FoGPAx/QiWaQWQBiihzbJ8zT2V+jFMyH4q8F9JcMGMD DKjgA6z/NEKNLzYN+nj1Ta6c9blzuEXK5Nek5PpQ/tUP1i7e8Vxa+wvvi7XUG9c4kx1v mrcw== X-Gm-Message-State: AOJu0YzYpFEugLIFLLz73OQCoHyxSHa+YhYVUQCYyC/KDlrd9EQz7mka AzRhxCraQqLlkOW9ss5AZjsACJKoDAjnvKOM42IZXluTsPK8W9bh34JJXNKF3+KCm5PkblsQhgA e2IPJLsIKi524j+nYrSD9BgStI7AwvW8/yLEkF+M+OZlCxyF6xt/NWA8OjbEJKjceyvlGqmrICs DejmFVV4LyOFSothBYIC4GDt9laD1RkygUqnpyprc= X-Received: by 2002:a05:6000:4388:b0:378:8b56:4665 with SMTP id ffacd0b85a97d-37ef12c8531mr1556434f8f.24.1729591833455; Tue, 22 Oct 2024 03:10:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCu/q/XeHdz46UNT7zYQqEGMXcEYMCfCQgwfVFqVhd8DBg290J5LEF3gXAVmH5PiePmhyung== X-Received: by 2002:a05:6000:4388:b0:378:8b56:4665 with SMTP id ffacd0b85a97d-37ef12c8531mr1556406f8f.24.1729591832855; Tue, 22 Oct 2024 03:10:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 09/14] rust: clean up detection of the language Date: Tue, 22 Oct 2024 12:09:50 +0200 Message-ID: <20241022100956.196657-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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=-1.699, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591901592116600 Content-Type: text/plain; charset="utf-8" Disable the detection code altogether if have_system =3D=3D false. Signed-off-by: Paolo Bonzini --- meson.build | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/meson.build b/meson.build index fe72f9951ca..e411a8ae567 100644 --- a/meson.build +++ b/meson.build @@ -53,6 +53,17 @@ cpu =3D host_machine.cpu_family() =20 target_dirs =3D config_host['TARGET_DIRS'].split() =20 +# type of binaries to build +have_linux_user =3D false +have_bsd_user =3D false +have_system =3D false +foreach target : target_dirs + have_linux_user =3D have_linux_user or target.endswith('linux-user') + have_bsd_user =3D have_bsd_user or target.endswith('bsd-user') + have_system =3D have_system or target.endswith('-softmmu') +endforeach +have_user =3D have_linux_user or have_bsd_user + ############ # Programs # ############ @@ -71,11 +82,13 @@ if host_os =3D=3D 'darwin' and \ all_languages +=3D ['objc'] objc =3D meson.get_compiler('objc') endif -have_rust =3D false -if not get_option('rust').disabled() and add_languages('rust', required: g= et_option('rust'), native: false) \ - and add_languages('rust', required: get_option('rust'), native: true) + +have_rust =3D add_languages('rust', native: false, + required: get_option('rust').disable_auto_if(not have_system)) +have_rust =3D have_rust and add_languages('rust', native: true, + required: get_option('rust').disable_auto_if(not have_system)) +if have_rust rustc =3D meson.get_compiler('rust') - have_rust =3D true if rustc.version().version_compare('<1.80.0') if get_option('rust').enabled() error('rustc version ' + rustc.version() + ' is unsupported: Please = upgrade to at least 1.80.0') @@ -186,17 +199,6 @@ have_vhost_net_vdpa =3D have_vhost_vdpa and get_option= ('vhost_net').allowed() have_vhost_net_kernel =3D have_vhost_kernel and get_option('vhost_net').al= lowed() have_vhost_net =3D have_vhost_net_kernel or have_vhost_net_user or have_vh= ost_net_vdpa =20 -# type of binaries to build -have_linux_user =3D false -have_bsd_user =3D false -have_system =3D false -foreach target : target_dirs - have_linux_user =3D have_linux_user or target.endswith('linux-user') - have_bsd_user =3D have_bsd_user or target.endswith('bsd-user') - have_system =3D have_system or target.endswith('-softmmu') -endforeach -have_user =3D have_linux_user or have_bsd_user - have_tools =3D get_option('tools') \ .disable_auto_if(not have_system) \ .allowed() @@ -3317,7 +3319,7 @@ endif =20 genh +=3D configure_file(output: 'config-host.h', configuration: config_ho= st_data) =20 -if have_rust and have_system +if have_rust rustc_args =3D run_command( find_program('scripts/rust/rustc_args.py'), '--config-headers', meson.project_build_root() / 'config-host.h', @@ -3937,7 +3939,7 @@ common_all =3D static_library('common', implicit_include_directories: false, dependencies: common_ss.all_dependencies()) =20 -if have_rust and have_system +if have_rust bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', @@ -4091,7 +4093,7 @@ foreach target : target_dirs arch_srcs +=3D target_specific.sources() arch_deps +=3D target_specific.dependencies() =20 - if have_rust and have_system + if have_rust and target_type =3D=3D 'system' target_rust =3D rust_devices_ss.apply(config_target, strict: false) crates =3D [] foreach dep : target_rust.dependencies() @@ -4453,9 +4455,9 @@ else endif summary_info +=3D {'Rust support': have_rust} if have_rust - summary_info +=3D {'rustc version': rustc.version()} - summary_info +=3D {'rustc': ' '.join(rustc.cmd_array())} summary_info +=3D {'Rust target': config_host['RUST_TARGET_TRIPLE']} + summary_info +=3D {'rustc': ' '.join(rustc.cmd_array())} + summary_info +=3D {'rustc version': rustc.version()} endif option_cflags =3D (get_option('debug') ? ['-g'] : []) if get_option('optimization') !=3D 'plain' --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591885; cv=none; d=zohomail.com; s=zohoarc; b=NL3Fn2qdmHMKrHTyK/9ODaQYIL7WNfuoLWBx0kmLTET3J5h91gAn8RXBGdxu0PXB41lanCaT1kkQa8HuDEi3jDhAf4XceLy/pu16LHWokS0CuMSAalUad7H0OL1oqt/LGPj0VbSdJ5XMRMS5bWAUp3EmFcLWLXYo74hJrgP9nbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591885; 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=PBRhOELsRn9xQQiWxQ4MS4Iao+woVuEtGdzYywQ/DGE=; b=HAmNHw9WWjLjOtq6Blzx6NJw1+cJyCeXR5R/MqgjrVcy5uK6BqTDHv9htenQ1xrsU+wYfl+tSQ8Mo8p3rgDwPJxGL2ThygYg2h62guc+N1tD0XX/yBraZ66SIOzVPhU3/b4Yy5kbqWwad61AbPIg2MIzlt0FYrFkdbM0nNyFzKo= 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 1729591885075788.4864319974502; Tue, 22 Oct 2024 03:11:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3Bqf-000520-Nl; Tue, 22 Oct 2024 06:10:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bqc-0004vG-K2 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:43 -0400 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 1t3Bqa-0004PU-SM for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:42 -0400 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-651-oYG8AMCJMEi8EQj7rbhQ_Q-1; Tue, 22 Oct 2024 06:10:38 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d49887a2cso3024991f8f.0 for ; Tue, 22 Oct 2024 03:10:38 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a487bdsm6312221f8f.32.2024.10.22.03.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591840; 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=PBRhOELsRn9xQQiWxQ4MS4Iao+woVuEtGdzYywQ/DGE=; b=dx3RbDRXRWrW6XfS7FdVBurOht5OK9uDrLYVcuJe83ZQEcmDl6rS0O/l7ScYvYuRopx1/l DJGvKALZrEwDMvNF8vkPfslKvX1VlbnrBwsRjYAeHlvA2/WKMOewpDEBx8zlkAzkzlLZbp lQsQ+iJC2tMqgTR9xjZ1KBXalgiXPf8= X-MC-Unique: oYG8AMCJMEi8EQj7rbhQ_Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591837; x=1730196637; 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=PBRhOELsRn9xQQiWxQ4MS4Iao+woVuEtGdzYywQ/DGE=; b=mTGBcSk6/qNaFqVWLG7YF+Wzro343smYVnKErSi8B5Zo5VKN2qjcQDadcRKjvnIzOp m0bIdvQs5wylvyftA5ES4OGeb84Igqv+sz4me0G3Xpel7tV/5oF2QlfPFLwCU4mtCEug snTSoc/pnoanBqOMztU0+tI1gMKOCopyQGXqXZyCNZlCBjcuO/1C3P6BW8kasWhzdqjq FuwGQFQSIIGtyAuszWN5dokM8w12/1qzdiM2LtN4onkF7ZQCvP9FmlCVazDXbNyh8Hgx DuE1zZ8zP+crmHt5omitaPOy2PzqBTTjFGOVk0zt/tsE7jIR1xq+RF5p97TLZsc/1ev7 R+0g== X-Gm-Message-State: AOJu0YyrdrUmmzhKuco3MsrMbn6xDLyBDvkEnX/rLckWZyQcLyEUf/+6 gp0l6V+LFEmCu/dY/5eJ5Lo31NAS2frFlxM5qRVp5McGZohXaRvZqO6UkHUNxh7xyf/jHnjr8QQ z3BHQlg1tUV3shcOlKQuBPv/hv6d9H/UYcLzQY/+ZHTLU7w24y05lhMmc7Gn8AmiskexMNO1QfG xJhyDWhhNNLzbT1M+FD47g+/PQTnOlCjtXwgx/L/g= X-Received: by 2002:adf:e54c:0:b0:371:6fc7:d45d with SMTP id ffacd0b85a97d-37ef1263b35mr1699932f8f.2.1729591837111; Tue, 22 Oct 2024 03:10:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMglMYBxnOmMQKOThNtR81vbuaOXQHUSglgnAY0h0XMLxiJLA1jMKp4WiYGoFYzWmn9H79nw== X-Received: by 2002:adf:e54c:0:b0:371:6fc7:d45d with SMTP id ffacd0b85a97d-37ef1263b35mr1699916f8f.2.1729591836675; Tue, 22 Oct 2024 03:10:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 10/14] rust: allow version 1.63.0 of rustc Date: Tue, 22 Oct 2024 12:09:51 +0200 Message-ID: <20241022100956.196657-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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=-1.699, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591885506116600 Content-Type: text/plain; charset="utf-8" All constructs introduced by newer versions of Rust have been removed. Apart from Debian 12, all other supported Linux distributions have rustc 1.75.0 or newer. This means that they only lack c"" literals and stable offset_of!. Signed-off-by: Paolo Bonzini --- meson.build | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index e411a8ae567..9c57d7e5c6d 100644 --- a/meson.build +++ b/meson.build @@ -89,11 +89,12 @@ have_rust =3D have_rust and add_languages('rust', nativ= e: true, required: get_option('rust').disable_auto_if(not have_system)) if have_rust rustc =3D meson.get_compiler('rust') - if rustc.version().version_compare('<1.80.0') + if rustc.version().version_compare('<1.63.0') if get_option('rust').enabled() - error('rustc version ' + rustc.version() + ' is unsupported: Please = upgrade to at least 1.80.0') + error('rustc version ' + rustc.version() + ' is unsupported. Please = upgrade to at least 1.63.0') else - warning('rustc version ' + rustc.version() + ' is unsupported: Disab= ling Rust compilation. Please upgrade to at least 1.80.0 to use Rust.') + warning('rustc version ' + rustc.version() + ' is unsupported, disab= ling Rust compilation.') + message('Please upgrade to at least 1.63.0 to use Rust.') have_rust =3D false endif endif --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591899; cv=none; d=zohomail.com; s=zohoarc; b=cf6sgj5AxmUHo+pduAnlE8ilvANtuTA9owKj3sSXiQCiVSISA+Eso6oosf1VnIWWBFMUHPCElaFvclv2xE0XodL8hCuv6yjCc67uRO2ad/27rsYP/3XJPeEWLLeVn42yd9mnrO1kTZWRE/wuqnkTnliYUIDjur07OALSjhxgNkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591899; 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=biLPxyuTmYjTQwz6O/sjJWtUJX+CBzOfsRAa2TZ+E2U=; b=i1Tudjb8bcKVtYx634FZlWrNsdsKBnmnG+U71PF95YJEx15DDrJSRx3fYr0pctQo4/jauhyTTBpZrDZmtj3sk0HOOZHyeDt5xEU94Vn6CNXEm1gkM1HJtzC2Z3CIn3JxyPTcqtlPh0AhVxydSvTz1nwlas3rCv4XbZPK1A7Ti8o= 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 1729591899852980.304454130499; Tue, 22 Oct 2024 03:11:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3Bqk-00055e-8H; Tue, 22 Oct 2024 06:10:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bqh-00053E-28 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bqf-0004Pl-0Y for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:46 -0400 Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-356-zgRU7B9SNaC5VoTaDkKawA-1; Tue, 22 Oct 2024 06:10:42 -0400 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-539ed93e08aso4018331e87.3 for ; Tue, 22 Oct 2024 03:10:42 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5cc563sm83567805e9.44.2024.10.22.03.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591844; 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=biLPxyuTmYjTQwz6O/sjJWtUJX+CBzOfsRAa2TZ+E2U=; b=Rbk4qHFsRDolWbEeF5kirzGT5VZIe484WSWZYTO/9stZbF8B0taCGT+syesrWrdVT5I0k9 9a1VwC1CF19L9GB9MuPa8Di0bRbnchpJi7L+hixXIMHnqm35eAT/Lui4jvOfXr1LW4Q/jW lKgp9qlqmMJnGC7rlhHCHEgpf8cexzU= X-MC-Unique: zgRU7B9SNaC5VoTaDkKawA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591840; x=1730196640; 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=biLPxyuTmYjTQwz6O/sjJWtUJX+CBzOfsRAa2TZ+E2U=; b=ke5+UTcSW3H66cfdLX7H3ja1yW3HCBbtoF6RfoHVw9MJYM1DAGkqhEUgtea2h6ZGWX tcT4xIO3WEuPElMDaE3j0LYGryu/sVWZcpK7Ol8KTuYryCDwK0La0bXDFMD4mM4P0Tjn ifYDICXesbJ3O6DpSqjUvQKvhmSITEPqnoJSWSIpRyCOybucGiXjBb1NCaFiOQsuq9TU kT0Al5NFM0q8AN0c3W+d9lfmjwTKncNzdFUmsqEgklJvtL0/UVQOOL+Kclw0UGyvmolS gsbxxTWsFzwyIXv87G1BZzkQWEo7ITNYMo4OCIKlO03eJfHLmGV+Oz3+T28hw1fktRas uROg== X-Gm-Message-State: AOJu0YxKdAPtz7Xj6o0dDfandLTl5U4pzkwY0m/e63HVKoCjFspmZ4xY Y8ZfPIvIu9u8NiZEMdNsCACDUUlDfJvigZIzZnfS5T2LAcvsPSRmkQwb1THgmRpqnXux88Tt/BW EijOhDDMT5HRWUO/Zsz+rZG9+j3sYckdlycLdRo9d04Ob04CbggwQ1IZee0TZZWcAvig3MMUhXy AWyt4end9EyJX/NuBcTfQD08W75/77tWh8PDL11jg= X-Received: by 2002:a05:6512:2207:b0:539:f699:4954 with SMTP id 2adb3069b0e04-53b12c42f7emr1743110e87.58.1729591840250; Tue, 22 Oct 2024 03:10:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrpdzMEtP8GCRmiUdFQ5jGMhUMEzMd9aQF/jUXNzE+TGciLXFKA5p3pvKX+bCR0aSoJfrHPQ== X-Received: by 2002:a05:6512:2207:b0:539:f699:4954 with SMTP id 2adb3069b0e04-53b12c42f7emr1743077e87.58.1729591839635; Tue, 22 Oct 2024 03:10:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 11/14] rust: do not use --generate-cstr Date: Tue, 22 Oct 2024 12:09:52 +0200 Message-ID: <20241022100956.196657-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591901630116600 Content-Type: text/plain; charset="utf-8" --generate-cstr is a good idea and generally the right thing to do, but it is not available in Debian 12 and Ubuntu 22.04. Work around the absence. Signed-off-by: Paolo Bonzini --- meson.build | 4 +++- rust/hw/char/pl011/src/device.rs | 1 + rust/qemu-api/src/device_class.rs | 10 ++++++++++ rust/qemu-api/tests/tests.rs | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 9c57d7e5c6d..a083e3434b3 100644 --- a/meson.build +++ b/meson.build @@ -3941,13 +3941,15 @@ common_all =3D static_library('common', dependencies: common_ss.all_dependencies()) =20 if have_rust + # We would like to use --generate-cstr, but it is only available + # starting with bindgen 0.66.0. The oldest supported versions + # are in Ubuntu 22.04 (0.59.1) and Debian 12 (0.60.1). bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', '--ctypes-prefix', 'std::os::raw', '--formatter', 'rustfmt', '--generate-block', - '--generate-cstr', '--impl-debug', '--merge-extern-blocks', '--no-doc-comments', diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index c26d21e079d..1bcb6a0fba8 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -13,6 +13,7 @@ bindings::{self, *}, c_str, definitions::ObjectImpl, + device_class::TYPE_SYS_BUS_DEVICE, }; =20 use crate::{ diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index ce3d5f50507..995267dd715 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -2,6 +2,10 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 +use std::ffi::CStr; + +use crate::bindings; + #[macro_export] macro_rules! device_class_init { ($func:ident, props =3D> $props:ident, realize_fn =3D> $realize_fn:exp= r, legacy_reset_fn =3D> $legacy_reset_fn:expr, vmsd =3D> $vmsd:ident$(,)*) = =3D> { @@ -83,3 +87,9 @@ macro_rules! vm_state_description { }; } } + +// workaround until we can use --generate-cstr in bindgen. +pub const TYPE_DEVICE: &CStr =3D + unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_DEVICE) }; +pub const TYPE_SYS_BUS_DEVICE: &CStr =3D + unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_SYS_BUS_DE= VICE) }; diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 96e413b75ee..f932acd5c10 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -8,7 +8,7 @@ bindings::*, c_str, declare_properties, define_property, definitions::{Class, ObjectImpl}, - device_class_init, vm_state_description, + device_class, device_class_init, vm_state_description, }; =20 #[test] @@ -56,7 +56,7 @@ impl ObjectImpl for DummyState { type Class =3D DummyClass; const TYPE_INFO: qemu_api::bindings::TypeInfo =3D qemu_api::type_i= nfo! { Self }; const TYPE_NAME: &'static CStr =3D c_str!("dummy"); - const PARENT_TYPE_NAME: Option<&'static CStr> =3D Some(TYPE_DEVICE= ); + const PARENT_TYPE_NAME: Option<&'static CStr> =3D Some(device_clas= s::TYPE_DEVICE); const ABSTRACT: bool =3D false; const INSTANCE_INIT: Option =3D None; const INSTANCE_POST_INIT: Option =3D None; --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591911; cv=none; d=zohomail.com; s=zohoarc; b=F9MEJsdCFkTQ3rHo6XcbLWNjTatVcdnbgdXTVrfQS9rUI3a7QcZFpYG0JvZdBY5ky99G4Gaf3EmEqXYKdvbi7YpTv6al4Wi6Z7ySn1kOUyeqeFmHd+4AAA/85NprRqmxYN09hl1bICMLebkGNhuJUPAIl+6Ruy81ZiyTIId+BoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591911; 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=sqZKZs4ctIO+XwCEz08VcQx7mTvLUzVoJpL0KkC+cT8=; b=QysO2lsKL41Ib1dZDsZcmTmOTGsIbiQ/tYo/8v922EHToNlPPOQtshAPQ9EUGVVTKaZ5iJu3Jxxp/fBgY3tw5b7H9HrK3Vo18w9C4scRUeLkeyzsGEWNv02zjEjoKDFjoMponA6f9vCIVS8Em//6LvDda4ZsEySIvPwuxL5VbDc= 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 1729591911336618.8851860404394; Tue, 22 Oct 2024 03:11:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3Bqn-00056h-7O; Tue, 22 Oct 2024 06:10:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bql-00056J-5I for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bqj-0004Q1-3B for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:50 -0400 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-504-sZ24dXJhPJqJpGn-HtrDRQ-1; Tue, 22 Oct 2024 06:10:46 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4314c6ca114so43647315e9.1 for ; Tue, 22 Oct 2024 03:10:46 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5c314bsm83516045e9.32.2024.10.22.03.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591848; 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=sqZKZs4ctIO+XwCEz08VcQx7mTvLUzVoJpL0KkC+cT8=; b=DnATGNaNzIHWQoPmOJDYoxzCj3ryKKaY1e5rwywUaDhkfpJ9Tf/StwGBpdnrCLFf51Orf8 oiyYEj0TR+KNX+Nrz2e8FK7XghfsS6CiT2MG9PrOGBp8OiuNcwUxAiseB1Ta6RLIBZwYDi +Xgsh5FubltZjjP/SNn2gY18ZHWAw1o= X-MC-Unique: sZ24dXJhPJqJpGn-HtrDRQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591844; x=1730196644; 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=sqZKZs4ctIO+XwCEz08VcQx7mTvLUzVoJpL0KkC+cT8=; b=Qwvb+Qay0Z2neZtEYrsF3U6PLQP2L/TSBFWMKGLXDZX9smYCrHXEwCi6SjX/ChQ+4o POFYHO+jfbwgsxhGybsPNxgYTNKLIyYsD4QS2gNSl/mrGrfbxaVbdsLpfHp1Ivc9v/J1 wPezmd91OK/SClqoxcw4HLpNRViU3KTM9ZgO4r36bsxBRgLHPRzGKdFRPLJ13/Mp0fji 0QOfHHZtimfE+cjTPlZHYxzxVMvjhnqVg5rEFPMmKAFvqfWbUEy6nOfMXRa2gPrcbbVp BY4mPwM7cGdUcdBGCEDtTXj1f1CRi9DYBr9vWrtUh2CcRkl2qDxAd/SQxtlvDCZ5SB5p l5Pg== X-Gm-Message-State: AOJu0YyqoF6BFydnOM7pgmI1XdcLGfB81j02Haz+txcz8S7Ak3VUeQHy MSXyEgNlWL/Re1fuceP3KVY4kdd0B5+r6N5QwRwb7oVK7mcqEJl61KXwpnMLiWJn/P3UZaZQN+E HBU4I9idvy1IiAc3e9l5YPHfMfcl6IfcsBZ8fQjYVthaT+8IFxdwQmzKl7pfWn0UqsZrLgEqJJK kS1whgfdLisz+QC0NZWrc5NgIM1Lk7aG4N/IhCoOs= X-Received: by 2002:a05:600c:4687:b0:42c:b220:4778 with SMTP id 5b1f17b1804b1-4317cb0acd5mr15758815e9.33.1729591843911; Tue, 22 Oct 2024 03:10:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHQXFBOMtcFlMJKbKgMFyEMN/5s07ayLP0urv3U5os3KfbvukbP9P0rEK2yQX+0m9oNq4BEg== X-Received: by 2002:a05:600c:4687:b0:42c:b220:4778 with SMTP id 5b1f17b1804b1-4317cb0acd5mr15758585e9.33.1729591843395; Tue, 22 Oct 2024 03:10:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 12/14] rust: allow older version of bindgen Date: Tue, 22 Oct 2024 12:09:53 +0200 Message-ID: <20241022100956.196657-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591911656116600 Content-Type: text/plain; charset="utf-8" Cope with the old version that is provided in Debian 12. --size_t-is-usize is needed on bindgen <0.61.0, and it was removed in bindgen 0.65.0, so check for it in meson.build. --merge-extern-blocks was added in 0.61.0. --formatter rustfmt was added in 0.65.0 and is the default, so remove it. Apart from Debian 12 and Ubuntu 22.04, all other supported distros have version 0.66.x of bindgen or newer (or do not have bindgen at all). Signed-off-by: Paolo Bonzini --- docs/about/build-platforms.rst | 8 ++++++++ meson.build | 29 +++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/docs/about/build-platforms.rst b/docs/about/build-platforms.rst index 8fd7da140a3..8173830c17a 100644 --- a/docs/about/build-platforms.rst +++ b/docs/about/build-platforms.rst @@ -107,6 +107,14 @@ Python build dependencies required, it may be necessary to fetch python modules from the Python Package Index (PyPI) via ``pip``, in order to build QEMU. =20 +Rust build dependencies + QEMU is generally conservative in adding new Rust dependencies, and all + of them are included in the distributed tarballs. One exception is the + bindgen tool, which is too big to package and distribute. The minimum + supported version of bindgen is 0.60.x. For distributions that do not + include bindgen or have an older version, it is recommended to install + a newer version using ``cargo install bindgen-cli``. + Optional build dependencies Build components whose absence does not affect the ability to build QEMU may not be available in distros, or may be too old for QEMU's diff --git a/meson.build b/meson.build index a083e3434b3..d78afb79d67 100644 --- a/meson.build +++ b/meson.build @@ -100,6 +100,21 @@ if have_rust endif endif =20 +bindgen =3D find_program('bindgen', required: get_option('rust').disable_a= uto_if(not have_rust)) +if not bindgen.found() or bindgen.version().version_compare('<0.60.0') + if get_option('rust').enabled() + error('bindgen version ' + bindgen.version() + ' is unsupported. You c= an install a new version with "cargo install bindgen-cli"') + else + if bindgen.found() + warning('bindgen version ' + bindgen.version() + ' is unsupported, d= isabling Rust compilation.') + else + warning('bindgen not found, disabling Rust compilation.') + endif + message('To use Rust you can install a new version with "cargo install= bindgen-cli"') + have_rust =3D false + endif +endif + dtrace =3D not_found stap =3D not_found if 'dtrace' in get_option('trace_backends') @@ -3943,15 +3958,13 @@ common_all =3D static_library('common', if have_rust # We would like to use --generate-cstr, but it is only available # starting with bindgen 0.66.0. The oldest supported versions - # are in Ubuntu 22.04 (0.59.1) and Debian 12 (0.60.1). + # is 0.60.x (Debian 12 has 0.60.1) which introduces --allowlist-file. bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', '--ctypes-prefix', 'std::os::raw', - '--formatter', 'rustfmt', '--generate-block', '--impl-debug', - '--merge-extern-blocks', '--no-doc-comments', '--with-derive-default', '--no-layout-tests', @@ -3960,6 +3973,12 @@ if have_rust '--allowlist-file', meson.project_source_root() + '/.*', '--allowlist-file', meson.project_build_root() + '/.*' ] + if bindgen.version().version_compare('<0.61.0') + # default in 0.61+ + bindgen_args +=3D ['--size_t-is-usize'] + else + bindgen_args +=3D ['--merge-extern-blocks'] + endif c_enums =3D [ 'DeviceCategory', 'GpioPolarity', @@ -3995,7 +4014,7 @@ if have_rust dependencies: common_ss.all_dependencies(), output: 'bindings.rs', include_directories: include_directories('.', 'include'), - bindgen_version: ['>=3D0.69.4'], + bindgen_version: ['>=3D0.60.0'], args: bindgen_args, ) subdir('rust') @@ -4461,6 +4480,8 @@ if have_rust summary_info +=3D {'Rust target': config_host['RUST_TARGET_TRIPLE']} summary_info +=3D {'rustc': ' '.join(rustc.cmd_array())} summary_info +=3D {'rustc version': rustc.version()} + summary_info +=3D {'bindgen': bindgen.full_path()} + summary_info +=3D {'bindgen version': bindgen.version()} endif option_cflags =3D (get_option('debug') ? ['-g'] : []) if get_option('optimization') !=3D 'plain' --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591912; cv=none; d=zohomail.com; s=zohoarc; b=QrvqwPu0Gthu5ga+z1S4HtBLHAwl/UNagU70F1s5coz6pGoQD6Vp9hX/ymi8lhfmRUUc/1Vhgm8drWZbuSA1IMwssdr7iVVSjxFSD6sV8KvSrwScbN4+6i1cuhj4NK4hgZCOhQ3tdp4GSaZuwL/k3EYkKZ0KM8Vhfik2FBXadqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591911; 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=K9B3S4pkz/ND8ZX3LymjnObrKUjAIX6qwMdxq9Q+Q3M=; b=O/ikPqsLphiQ8GihKXOM42gKDUBAi3QVemaWrN9F/CLtlzAPKHTMHLnK3zf5DVZYw910o7Dsj2xg98Pw/E7j+0zTYpZ7OVePudfOZ5nTYCzc3iE0ijhmp4LaTVFn2B5iImOj7uqvJ9P8+6Tl6V6hJD5DiP3SUtCbLWuSxbrGGb8= 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 1729591911983531.6778236826218; Tue, 22 Oct 2024 03:11:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3Bqo-000572-8L; Tue, 22 Oct 2024 06:10:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bqm-00056Z-Ib for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bql-0004Q7-5z for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:52 -0400 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-58-LzABJowoNgejoB91X1AFWQ-1; Tue, 22 Oct 2024 06:10:49 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4317391101aso14416645e9.2 for ; Tue, 22 Oct 2024 03:10:49 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5c3194sm84592765e9.31.2024.10.22.03.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591850; 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=K9B3S4pkz/ND8ZX3LymjnObrKUjAIX6qwMdxq9Q+Q3M=; b=SD6ifI+tF2B+wjjveBxHO9LVNqVvoes4bd6026sKkeOW7vMtcggmn1+trHrFDAjvs9jCEp phS+Yjo5RPPrkUxEwvJDIla851LziXyXk3nTuxOBxU50g+ORJddZNxfCsL8JhEN+Zc1InX SG/WAhUlEdo1Sx+oFkS7290Bs3FiEG4= X-MC-Unique: LzABJowoNgejoB91X1AFWQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591847; x=1730196647; 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=K9B3S4pkz/ND8ZX3LymjnObrKUjAIX6qwMdxq9Q+Q3M=; b=d3UzbLRbvCPGTxomKFsg48Mh88esiKyvBUgUQzLw6AaZAz4YlCkPAJD4ezFHskhZ6H GnV58MOMvVri9quRUHoA42QPPAcmpMmfYc2zaTwltPCv0VO0ceApBqFaG4XrUR/7C85f RoHgfE8oB2122D7CrjrKF1hwvtJ9RAtAwGEQPl2wq/SjuNSjebdRPqrX8RAqZgP6zFq5 FK77XEQfGNYe3m7EP0kS8OAIRlvRnGKU+drR61LWJ/2EyEW39S5t122ucqDQIiExeXFS 4UyOQRlqCPKcOChMbZulJ/7Bm4hnj+OHOmTDi+yBKvsoqascnHUX2m6mYIjmWT0C/B7q 6QYQ== X-Gm-Message-State: AOJu0YzguYD0QzQgksjQ7VnrAlo1iaqToJJNphMJJN7zAsWUTgkw6n/h 8dE13K9bT/mx7u5AbvzGEsvoTuPlN4UX0KrjItdB/6eOa84C73PFCo0ValPsTG6uc5WNm102Ol2 dtoqu8K7FIHIpv3dYhocghyl+W+I1jTHuT/1m6r+NjB0DF7shpRxJVLF8zB9AVpRrOJKqb3tkam mmsCPkXJc3mZlr7hwev7veB04uvHyPfHH8wq8EWE8= X-Received: by 2002:a05:600c:1c95:b0:431:6083:cd2a with SMTP id 5b1f17b1804b1-43161659c02mr124685855e9.15.1729591847429; Tue, 22 Oct 2024 03:10:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDQGfliN2mrPSUog1KDj6MU2y/6FNACnBkmObU8eVnHfr3chcQmaoS/LkbMYCw8wpOebwq8A== X-Received: by 2002:a05:600c:1c95:b0:431:6083:cd2a with SMTP id 5b1f17b1804b1-43161659c02mr124685555e9.15.1729591846992; Tue, 22 Oct 2024 03:10:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 13/14] rust: make rustfmt optional Date: Tue, 22 Oct 2024 12:09:54 +0200 Message-ID: <20241022100956.196657-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591913644116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- meson.build | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/meson.build b/meson.build index d78afb79d67..5e3501750a1 100644 --- a/meson.build +++ b/meson.build @@ -115,6 +115,10 @@ if not bindgen.found() or bindgen.version().version_co= mpare('<0.60.0') endif endif =20 +if have_rust + rustfmt =3D find_program('rustfmt', required: false) +endif + dtrace =3D not_found stap =3D not_found if 'dtrace' in get_option('trace_backends') @@ -3973,6 +3977,13 @@ if have_rust '--allowlist-file', meson.project_source_root() + '/.*', '--allowlist-file', meson.project_build_root() + '/.*' ] + if not rustfmt.found() + if bindgen.version().version_compare('<0.65.0') + bindgen_args +=3D ['--no-rustfmt-bindings'] + else + bindgen_args +=3D ['--formatter', 'none'] + endif + endif if bindgen.version().version_compare('<0.61.0') # default in 0.61+ bindgen_args +=3D ['--size_t-is-usize'] --=20 2.46.2 From nobody Tue Oct 22 23:34:19 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=1729591900; cv=none; d=zohomail.com; s=zohoarc; b=DiytMgTy+sA4JqqXaFpmnzD9cMH8lT9MHHOpYrYZoWjbdzjQeLI/D+uYM5VVcwCcgPYG3dliGJQh9cu1yrLQoVkXwZatVHcdZ00pTi/dgEXGmpHzFgzKH6JrWrvQSjsldDzsWbIkL2i8b2PueNrcTCfp4HeBMLvWbiYrUCnJbV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729591900; 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=wXYKPERsSFUrXojLdSDlVUPkke/4VTh6P6Z9bxQslRA=; b=YFdvW1iJlrOgXI1dtj1w9jIgbSbyoCSyIDmEZBW83OxwgCXfZ2tRrp3DbH7weBnfJc0Y7lALKhHlaiBje12rJtiht/rHFqXNRoh7SPhExtuyYW1fq+EsDz7h50kkbzui8r1pdaOs77vz6tSlVmhPvSJ/6BSBQkZLLhhzqG3vzVI= 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 1729591900139597.8759723509716; Tue, 22 Oct 2024 03:11:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3Br1-0005OD-5H; Tue, 22 Oct 2024 06:11:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bqs-0005Cs-AB for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3Bqp-0004Qm-Cv for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:10:58 -0400 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-612-2A9CNMs7MRCVXTfxV9fs1w-1; Tue, 22 Oct 2024 06:10:53 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-431518e6d8fso38190125e9.0 for ; Tue, 22 Oct 2024 03:10:53 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f57fc36sm83998985e9.18.2024.10.22.03.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729591854; 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=wXYKPERsSFUrXojLdSDlVUPkke/4VTh6P6Z9bxQslRA=; b=elAXQ18ZwuIfvB2TVzP0sig8naWomxGy75rXUnWxzNeuIPZiQP+loeZm2Rdg3s2xoLdrDU PM2v5ymFxhkxbGy668yBElFX2cVho0+4KlhBqAtL2OoClP7eXOEClygqT8XmXEYKKMhAqI +8riB22x/raC7XWtDb1skgsYxguTjQM= X-MC-Unique: 2A9CNMs7MRCVXTfxV9fs1w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591851; x=1730196651; 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=wXYKPERsSFUrXojLdSDlVUPkke/4VTh6P6Z9bxQslRA=; b=ISdxMFoP64otk+aSCW0grWyYdISTw57svAHJOR++pWBa1NigT0qnDeVwT2OsMR9J5y tTRw15nJMfquJyw19GB50BJSdniDEaJWEbD8EkhEcXZ/ruq0/8Dj1HZ120mq/SoJRZ3r 3NdxCzf5gUmRWAuNYEj0HO7hKTSWIowvYt/tTAbPzG+zUzo2/bX2hmWK3tIQVKRlniti svpVbrSHnmpd2gvEuLCU/bSxcOcWieZluNQ/pUUQwfnh+5mjQblzrC9CQb4gjYhpiMS+ bX7w/G931V01zlS5ojC2br64KA7/iJhhGKoVck5tul7Pk4ftVBTVXTcNJKX9dhxCY8I6 6fyQ== X-Gm-Message-State: AOJu0YwlmnK+k1q4mvVeOXURjWeqhZIsTJlAwtGXuzkaXIdUJtwxfB2x SwnbmoB2ZRmX9eY2LsBM8fnMKoD7Pca+x6IW2NBBUNwPAixbfMOlYPDQwo46Q5/WX6g9XXJr/2I 1jOR3ap0C5l4o3zAAUWTbcKViDUfQbGN5X43sVIFvWCjDlsi+E0gB5/2oO2KFv4ZqPU9MT+gxRE 4TApTX2XXMoebRhb9sg6z1Uc/jemaIHmW5FsDdk8c= X-Received: by 2002:a05:600c:4ed2:b0:426:64a2:5362 with SMTP id 5b1f17b1804b1-4316163b8bbmr111004625e9.8.1729591851217; Tue, 22 Oct 2024 03:10:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENasJYl91Hg+yP66jIknw/gTZ0EeU7r9BvhomsSRp60/DrKVFy7AG/42ZwzSIhw7PyIV6ePQ== X-Received: by 2002:a05:600c:4ed2:b0:426:64a2:5362 with SMTP id 5b1f17b1804b1-4316163b8bbmr111004345e9.8.1729591850739; Tue, 22 Oct 2024 03:10:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, kwolf@redhat.com, junjie.mao@hotmail.com, manos.pitsidianakis@linaro.org Subject: [PATCH v2 14/14] dockerfiles: install bindgen from cargo on Ubuntu 22.04 Date: Tue, 22 Oct 2024 12:09:55 +0200 Message-ID: <20241022100956.196657-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241022100956.196657-1-pbonzini@redhat.com> References: <20241022100956.196657-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729591901618116600 Content-Type: text/plain; charset="utf-8" Because Ubuntu 22.04 has a very old version of bindgen, that does not have the important option --allowlist-file, it will not be able to use --enable-rust out of the box. Instead, install the latest version of bindgen-cli via "cargo install" in the container, following the documentation. Signed-off-by: Paolo Bonzini --- tests/docker/dockerfiles/ubuntu2204.docker | 5 +++++ tests/lcitool/mappings.yml | 4 ++++ tests/lcitool/refresh | 11 ++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/docker/dockerfiles/ubuntu2204.docker b/tests/docker/dock= erfiles/ubuntu2204.docker index ce3aa39d4f3..245ac879622 100644 --- a/tests/docker/dockerfiles/ubuntu2204.docker +++ b/tests/docker/dockerfiles/ubuntu2204.docker @@ -149,6 +149,11 @@ ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make" ENV NINJA "/usr/bin/ninja" ENV PYTHON "/usr/bin/python3" +ENV CARGO_HOME=3D/usr/local/cargo +ENV PATH=3D$CARGO_HOME/bin:$PATH +RUN DEBIAN_FRONTEND=3Dnoninteractive eatmydata \ + apt install -y --no-install-recommends cargo +RUN cargo install bindgen-cli # As a final step configure the user (if env is defined) ARG USER ARG UID diff --git a/tests/lcitool/mappings.yml b/tests/lcitool/mappings.yml index 9c5ac87c1c2..c90b23a00f1 100644 --- a/tests/lcitool/mappings.yml +++ b/tests/lcitool/mappings.yml @@ -1,4 +1,8 @@ mappings: + # Too old on Ubuntu 22.04; we install it from cargo instead + bindgen: + Ubuntu2204: + flake8: OpenSUSELeap15: =20 diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh index 0f16f4d525c..a46cbbdca41 100755 --- a/tests/lcitool/refresh +++ b/tests/lcitool/refresh @@ -137,6 +137,14 @@ fedora_rustup_nightly_extras =3D [ 'RUN /usr/local/cargo/bin/rustup run nightly cargo install bindgen-cli= \n', ] =20 +ubuntu2204_bindgen_extras =3D [ + "ENV CARGO_HOME=3D/usr/local/cargo\n", + 'ENV PATH=3D$CARGO_HOME/bin:$PATH\n', + "RUN DEBIAN_FRONTEND=3Dnoninteractive eatmydata \\\n", + " apt install -y --no-install-recommends cargo\n", + 'RUN cargo install bindgen-cli\n', +] + def cross_build(prefix, targets): conf =3D "ENV QEMU_CONFIGURE_OPTS --cross-prefix=3D%s\n" % (prefix) targets =3D "ENV DEF_TARGET_LIST %s\n" % (targets) @@ -157,7 +165,8 @@ try: trailer=3D"".join(debian12_extras)) generate_dockerfile("fedora", "fedora-40") generate_dockerfile("opensuse-leap", "opensuse-leap-15") - generate_dockerfile("ubuntu2204", "ubuntu-2204") + generate_dockerfile("ubuntu2204", "ubuntu-2204", + trailer=3D"".join(ubuntu2204_bindgen_extras)) =20 # # Non-fatal Rust-enabled build --=20 2.46.2