From nobody Wed Apr 16 12:23:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1733934670; cv=none; d=zohomail.com; s=zohoarc; b=NiUbmwyYynMIToxifsHnmObT+vxqHpdfxmHw83GGehORn7lrAAG7GMapZ0T+UAQVOKZRky2202Y53cYMBicKXXEjmWom89iw8NQEP/PQ2uwMXTGEF5ZD18Xm34IBQ9kZV0FKSsgQyzvcapCLZA5P0Pk6O4C7XdrgpFp3AVW8mo8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733934670; h=Content-Transfer-Encoding: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:Cc; bh=Kc+3yZr1fEE4Vxs7y1Ixn7frgKT0doT0bC1xM2Vun5Y=; b=CaOsfgE25bxPktvOLHBSuwj10SacvSgxnZjaF8wiHf26ExgtQECtpPkB5ayCeez/6tJyyxs/fVyy+uLAUD6WiKyFdvKUQ73EhhSCPfN0Tk9q4SEr3GMBB1MA7qXrofaxjE7K74zWDhQaoyo/6DwNvJuduf5xa0Nzy/OYCs//1pE= 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 1733934670569751.4123836133996; Wed, 11 Dec 2024 08:31:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLPYv-0000aY-UE; Wed, 11 Dec 2024 11:27:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLPYo-0008TQ-Kf for qemu-devel@nongnu.org; Wed, 11 Dec 2024 11:27:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLPYm-0000Dz-Kr for qemu-devel@nongnu.org; Wed, 11 Dec 2024 11:27:38 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-mO4S-atpOYa4CJgOsniUDQ-1; Wed, 11 Dec 2024 11:27:34 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3861cd03a89so3250138f8f.1 for ; Wed, 11 Dec 2024 08:27:34 -0800 (PST) Received: from [192.168.10.3] ([151.81.118.45]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436178bd62dsm48509675e9.36.2024.12.11.08.27.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 08:27:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733934456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kc+3yZr1fEE4Vxs7y1Ixn7frgKT0doT0bC1xM2Vun5Y=; b=aj7vBrSy2Y/12++YY9pDuNBoN7gOuNCCFyOAgHrm4GpzMCJXtUmXwJRsIq/Q4kYtge0NRy 6LWD4PvPi9zVATBlnAIDiH87xLYVLLDjznYRo9bD9voZfMSZbOEwcpCyLbgihE5XPbp4Gl iJpPXaqi5FwNH+vPMOinyXEHx9tZ//Q= X-MC-Unique: mO4S-atpOYa4CJgOsniUDQ-1 X-Mimecast-MFC-AGG-ID: mO4S-atpOYa4CJgOsniUDQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733934452; x=1734539252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kc+3yZr1fEE4Vxs7y1Ixn7frgKT0doT0bC1xM2Vun5Y=; b=Znpg+DK1CfiC/v+OfuG4D+tMf2OOZcPewq2neeJd6T4NGOnSAoELrF7QpqA7bQYdZY l+gPgZ9BpJqEtvTeCz6UNwwyypLmaLLqBCRjnHlTB988tx18LEyGMrbhSgQtX/PYyX3Y eXlE/s75Q8wBw/KD9bLiXE/sy2OuopYeA4MoRo5afW9xbYmuYibdt8pQXn2/J5piBaU+ BhY67SVMdsv5RPETv+GOIl1EyisTLflSF1pB1TEC6RW2LqjdcSf3ehxYuHWm2JcNsryZ zc/FOYBxtV0cNmWFhsUIv8GZYfAJmp1SoIMnP6eFiugJEssy4ELMLRfjE6XPRDnHxjCy tCkQ== X-Gm-Message-State: AOJu0Yzr5JcvXwV9DE3pl3vEq8YlAhhnVCSaXSkL7Z0XbhH1biNZSMZr uLTgJ23hzoXi6ofXl03DGjaA1OwSoofGdgDgBCaUBhOIYGnhqa3dutg62u1hR1R1V3xibzOoZqU s4WcTDq1oh+UD0hYIu3D/WPsjfBYR+5GtgNxIVVaWlRbpIVN1R0f6wRFlQP10WLKaYZmkNHDPMB 1mGHXvshC3iefO2LM459ghQrBAU4O2mKAAvA33 X-Gm-Gg: ASbGncuhylw7mEcumP6Ttom50Rlau/qWVgC7WrptRPUkrEDRWdq8ORVNAurzUsqolTG I1gzvM/Y8syy2IucI3bNu32JLw8z/S5vHK47sn6D8gIEBL7TnYhzUZuyrdpK9ZmErdjCEECNbtr eIUaS3lm0lTZNnqm7EEfzwDY9ZjQRN/sd/uHERLBA7po4FrIFNE++0SW2izFqILYi/iZtCj+/OK N2/+Ojhw6Q0qdd0RH4JuPUDMk3bMGdKu+VjVIzO/5WgAvyY3IU+ZBDx X-Received: by 2002:a05:6000:1fad:b0:385:f527:be6d with SMTP id ffacd0b85a97d-387876af7demr219735f8f.36.1733934452536; Wed, 11 Dec 2024 08:27:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWVPZ0dEUNvTFXm4EY7w2EG3OqTg1SYd3ymQqxQ8jtlB+dr9UMyOrLBDJ6eed81aoOuVak/Q== X-Received: by 2002:a05:6000:1fad:b0:385:f527:be6d with SMTP id ffacd0b85a97d-387876af7demr219710f8f.36.1733934452069; Wed, 11 Dec 2024 08:27:32 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/49] rust: build: move rustc_args.py invocation to qemu-api crate Date: Wed, 11 Dec 2024 17:26:34 +0100 Message-ID: <20241211162720.320070-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241211162720.320070-1-pbonzini@redhat.com> References: <20241211162720.320070-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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.472, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.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: 1733934672201116600 Content-Type: text/plain; charset="utf-8" Only qemu-api needs access to the symbols in config-host.h. Remove the temptation to use them elsewhere by limiting the --cfg arguments to the qemu-api crate. Per-crate invocation of the script will also be needed to add --check-cfg options for each crate's features (when more complex, build-time configurable devices are added in the future). Signed-off-by: Paolo Bonzini --- meson.build | 56 +++++++++++++++++---------------------- rust/qemu-api/meson.build | 5 +++- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/meson.build b/meson.build index ea211c2dbb4..2f1f2aece4d 100644 --- a/meson.build +++ b/meson.build @@ -120,7 +120,30 @@ if have_rust endif =20 if have_rust + rustc_args =3D find_program('scripts/rust/rustc_args.py') rustfmt =3D find_program('rustfmt', required: false) + + # Prohibit code that is forbidden in Rust 2024 + rustc_lint_args =3D ['-D', 'unsafe_op_in_unsafe_fn'] + + # Occasionally, we may need to silence warnings and clippy lints that + # were only introduced in newer Rust compiler versions. Do not croak + # in that case; a CI job with rust_strict_lints =3D=3D true ensures that + # we do not have misspelled allow() attributes. + if not get_option('strict_rust_lints') + rustc_lint_args +=3D ['-A', 'unknown_lints'] + endif + + # Apart from procedural macros, our Rust executables will often link + # with C code, so include all the libraries that C code needs. This + # is safe; https://github.com/rust-lang/rust/pull/54675 says that + # passing -nodefaultlibs to the linker "was more ideological to + # start with than anything". + add_project_arguments(rustc_lint_args + + ['--cfg', 'MESON', '-C', 'default-linker-libraries'], + native: false, language: 'rust') + add_project_arguments(rustc_lint_args + ['--cfg', 'MESON'], + native: true, language: 'rust') endif =20 dtrace =3D not_found @@ -3399,37 +3422,8 @@ endif # Generated sources # ##################### =20 -genh +=3D configure_file(output: 'config-host.h', configuration: config_ho= st_data) - -if have_rust - rustc_args =3D run_command( - find_program('scripts/rust/rustc_args.py'), - '--config-headers', meson.project_build_root() / 'config-host.h', - capture : true, - check: true).stdout().strip().split() - - # Prohibit code that is forbidden in Rust 2024 - rustc_args +=3D ['-D', 'unsafe_op_in_unsafe_fn'] - - # Occasionally, we may need to silence warnings and clippy lints that - # were only introduced in newer Rust compiler versions. Do not croak - # in that case; a CI job with rust_strict_lints =3D=3D true ensures that - # we do not have misspelled allow() attributes. - if not get_option('strict_rust_lints') - rustc_args +=3D ['-A', 'unknown_lints'] - endif - - # Apart from procedural macros, our Rust executables will often link - # with C code, so include all the libraries that C code needs. This - # is safe; https://github.com/rust-lang/rust/pull/54675 says that - # passing -nodefaultlibs to the linker "was more ideological to - # start with than anything". - add_project_arguments(rustc_args + - ['--cfg', 'MESON', '-C', 'default-linker-libraries'], - native: false, language: 'rust') - add_project_arguments(rustc_args + ['--cfg', 'MESON'], - native: true, language: 'rust') -endif +config_host_h =3D configure_file(output: 'config-host.h', configuration: c= onfig_host_data) +genh +=3D config_host_h =20 hxtool =3D find_program('scripts/hxtool') shaderinclude =3D find_program('scripts/shaderinclude.py') diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 3be7b7e5ced..5df6b35bf88 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -1,4 +1,7 @@ -_qemu_api_cfg =3D [] +_qemu_api_cfg =3D run_command(rustc_args, + '--config-headers', config_host_h, + capture: true, check: true).stdout().strip().split() + # _qemu_api_cfg +=3D ['--cfg', 'feature=3D"allocator"'] if rustc.version().version_compare('>=3D1.77.0') _qemu_api_cfg +=3D ['--cfg', 'has_offset_of'] --=20 2.47.1