From nobody Tue Sep 9 00:17:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631018430884755.189543741207; Tue, 7 Sep 2021 05:40:30 -0700 (PDT) Received: from localhost ([::1]:43074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNaOr-0000Qa-Th for importer@patchew.org; Tue, 07 Sep 2021 08:40:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNa75-0001Fz-6l for qemu-devel@nongnu.org; Tue, 07 Sep 2021 08:22:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNa73-00076B-3h for qemu-devel@nongnu.org; Tue, 07 Sep 2021 08:22:06 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-_uA3K8xYPTu3sqD9kuUmjQ-1; Tue, 07 Sep 2021 08:22:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E793835DE2 for ; Tue, 7 Sep 2021 12:22:00 +0000 (UTC) Received: from localhost (unknown [10.39.208.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33A456608B; Tue, 7 Sep 2021 12:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631017323; 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=boIguc3k702SLL3dtYGl6A5xhu1pXRPkXWlbNcoqd3Y=; b=Jt6WfeUhR8eFOSrMaV57KcO+PYjJyfvZfmLO5PUDD2lQzmKDVUQldzVvGtZ7O8ApMYilGp INrcqYvrGKoQfrC+znDcf+aUEx2sWKHENor9vap/PuhbhCyuuKpmCOduwZw6qszf/dxeqO Itpv6RWBc5JEpg1m5wdtaUg3pTy4fHc= X-MC-Unique: _uA3K8xYPTu3sqD9kuUmjQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [RFC v3 10/32] build-sys: add --with-rust{-target} & basic build infrastructure Date: Tue, 7 Sep 2021 16:19:21 +0400 Message-Id: <20210907121943.3498701-11-marcandre.lureau@redhat.com> In-Reply-To: <20210907121943.3498701-1-marcandre.lureau@redhat.com> References: <20210907121943.3498701-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.391, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631018432271100001 From: Marc-Andr=C3=A9 Lureau Add the build-sys infrastructure to optionally build Rust code. Introduce a top-level workspace, so various sub-projects (libraries, executables etc) can be developed together, sharing the dependencies and output directory. If not Tier 1 (aarch64 and x86), all of the host architecture QEMU supports should be Tier 2: https://doc.rust-lang.org/nightly/rustc/platform-support.html Rust is generally available on various distributions (thanks to Firefox, I suppose). If not, it can usually be installed with rustup. configure will enable Rust support automatically if cargo is present. Rust support can be disabled --without-rust. When detecting windows cross building, it will use the $cpu-pc-windows-gnu target by default (more default mappings could be added over time). This can be changed with --with-rust-target=3DRTT. Signed-off-by: Marc-Andr=C3=A9 Lureau --- configure | 11 +++++++++++ meson.build | 27 +++++++++++++++++++++++++++ .gitignore | 1 + Cargo.toml | 2 ++ meson_options.txt | 5 +++++ 5 files changed, 46 insertions(+) create mode 100644 Cargo.toml diff --git a/configure b/configure index 48ff2837d9..470b90543f 100755 --- a/configure +++ b/configure @@ -445,6 +445,8 @@ fuse=3D"auto" fuse_lseek=3D"auto" multiprocess=3D"auto" slirp_smbd=3D"$default_feature" +with_rust=3D"auto" +with_rust_target=3D"" =20 malloc_trim=3D"auto" gio=3D"$default_feature" @@ -1586,6 +1588,12 @@ for opt do ;; --disable-slirp-smbd) slirp_smbd=3Dno ;; + --with-rust) with_rust=3Denabled + ;; + --without-rust) with_rust=3Ddisabled + ;; + --with-rust-target=3D*) with_rust_target=3D"$optarg" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1773,6 +1781,8 @@ Advanced options (experts only): --extra-ldflags=3DLDFLAGS append extra linker flags LDFLAGS --cross-cc-ARCH=3DCC use compiler when building ARCH guest test ca= ses --cross-cc-flags-ARCH=3D use compiler flags when building ARCH guest t= ests + --with-rust enable Rust compilation + --with-rust-target=3DRTT use the given Rust target triple --make=3DMAKE use specified make [$make] --python=3DPYTHON use specified python [$python] --sphinx-build=3DSPHINX use specified sphinx-build [$sphinx_build] @@ -5199,6 +5209,7 @@ if test "$skip_meson" =3D no; then -Db_coverage=3D$(if test "$gcov" =3D yes; then echo true; else ech= o false; fi) \ -Db_lto=3D$lto -Dcfi=3D$cfi -Dcfi_debug=3D$cfi_debug \ -Dmalloc=3D$malloc -Dmalloc_trim=3D$malloc_trim -Dsparse=3D$sparse= \ + -Dwith_rust=3D$with_rust -Dwith_rust_target=3D$with_rust_target \ -Dkvm=3D$kvm -Dhax=3D$hax -Dwhpx=3D$whpx -Dhvf=3D$hvf -Dnvmm=3D$nv= mm \ -Dxen=3D$xen -Dxen_pci_passthrough=3D$xen_pci_passthrough -Dtcg=3D= $tcg \ -Dcocoa=3D$cocoa -Dgtk=3D$gtk -Dmpath=3D$mpath -Dsdl=3D$sdl -Dsdl_= image=3D$sdl_image \ diff --git a/meson.build b/meson.build index cbf3ce19ae..63b61a2bc8 100644 --- a/meson.build +++ b/meson.build @@ -108,6 +108,29 @@ endif =20 bzip2 =3D find_program('bzip2', required: install_edk2_blobs) =20 +cargo =3D find_program('cargo', required: get_option('with_rust')) +with_rust =3D cargo.found() + +if with_rust + rust_target_triple =3D get_option('with_rust_target') + if meson.is_cross_build() + # more default target mappings may be added over time + if rust_target_triple =3D=3D '' and targetos =3D=3D 'windows' + rust_target_triple =3D host_machine.cpu() + '-pc-windows-gnu' + endif + if rust_target_triple =3D=3D '' + error('cross-compiling, but no Rust target-triple defined.') + endif + endif +endif +config_host_data.set('CONFIG_WITH_RUST', with_rust) + +if get_option('optimization') in ['0', '1', 'g'] + rs_build_type =3D 'debug' +else + rs_build_type =3D 'release' +endif + ################## # Compiler flags # ################## @@ -2916,6 +2939,10 @@ if targetos =3D=3D 'windows' summary_info +=3D {'Windows SDK': config_host['WIN_SDK']} endif endif +summary_info +=3D {'Rust support': with_rust} +if with_rust and rust_target_triple !=3D '' + summary_info +=3D {'Rust target': rust_target_triple} +endif summary_info +=3D {'CFLAGS': ' '.join(get_option('c_args') + ['-O' + get_option('optim= ization')] + (get_option('debug') ? ['= -g'] : []))} diff --git a/.gitignore b/.gitignore index eb2553026c..78715bc7c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /GNUmakefile /build/ +/target/ *.pyc .sdk .stgit-* diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000000..c4b464ff15 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,2 @@ +[workspace] +members =3D [] diff --git a/meson_options.txt b/meson_options.txt index a9a9b8f4c6..fe9f90634b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -155,3 +155,8 @@ option('slirp', type: 'combo', value: 'auto', option('fdt', type: 'combo', value: 'auto', choices: ['disabled', 'enabled', 'auto', 'system', 'internal'], description: 'Whether and how to find the libfdt library') + +option('with_rust', type: 'feature', value: 'auto', + description: 'Enable Rust support') +option('with_rust_target', type : 'string', value: '', + description: 'Rust target triple') --=20 2.33.0.113.g6c40894d24