From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD12DC3DA4A for ; Thu, 8 Aug 2024 08:10:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbyDj-000569-LF; Thu, 08 Aug 2024 04:10:03 -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 1sbyDh-00054t-27 for qemu-devel@nongnu.org; Thu, 08 Aug 2024 04:10:01 -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 1sbyDe-0001aQ-Oj for qemu-devel@nongnu.org; Thu, 08 Aug 2024 04:10:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723104597; 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:autocrypt:autocrypt; bh=aKxd0cXP1y+N4k27JWws9HQ06YzVciEcPutqHkmvU8g=; b=RaWSHIQSDPiICsHr1pcczevOEi/eVDojxzXtl1RFDW6e2hnhJnHt2u91wKATs9Igo0kC3N Wkf9RLUhFw9tuHaPJEKXrbQY69JDxnw33IPnzfkGlSK0B+ShIuKQGOpwS42tQl6C2wtNPh TMBGiKMm7B0tq+F2agd/B+vdPVAJG4E= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-7-nEi0qjiyMYmolSsUO0vgkQ-1; Thu, 08 Aug 2024 04:09:53 -0400 X-MC-Unique: nEi0qjiyMYmolSsUO0vgkQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a7a83f54fdeso63137366b.0 for ; Thu, 08 Aug 2024 01:09:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723104592; x=1723709392; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aKxd0cXP1y+N4k27JWws9HQ06YzVciEcPutqHkmvU8g=; b=NT5IEfRrNS46G3ICpY0LGTegIsBH9bZiJu1Z6vhTWZwJlzTJv8X2m6eg9AVIDX75ge lhUTRPO/enLqqVHq5qJ6uPinFIIUMOlSK7QTqJ0jFzRjd5Xon3Y81lwH8pQ8EzSLdMIZ 8o1GVmumgcqSjYo2vlAPBdncyF0PlcAam696QAFxyrgxMBilEhg7C5sGxqHrhVcLwryL O4eyU8Ox3jRhwdGfquwaogxtTGmHJtdw2Z4fvXFR+Ew/lOYKY3/dGHv/KVMEAjwgWn+w xBR98bDfqI1yVi4X1pjxdw0T0MQC1ZHr2y+iqCerf7k2zQNKbPzQF/guH4+tZgy5f8p4 Sw1Q== X-Forwarded-Encrypted: i=1; AJvYcCWVo6cG+5h+/vMjoxhRMUW93LCAw3iyf/6RBIMiLkyLpjQS/pTeB64AD+fci2ZPlU84R8Kjv1BWBHnH4yBFTZJ270LeSlc= X-Gm-Message-State: AOJu0Yx+jyNhZxIk2Gr9anAXf20o/doBPzVI4NGmDDcxAZ26sFJE6rGR GVCD4rW12jaLXl2tIeODTc7IVqojPGEbDyxarKnCV5z/N/bHILKisoANbaD6mavozwd+hmvFuF7 CgtsSHPvR7uCIFZb7SQu4wwh6JuoDxN90M0+5mi04aDCtW5N0KjIr X-Received: by 2002:a17:906:4783:b0:a7a:a212:be4e with SMTP id a640c23a62f3a-a8090c29b81mr85853166b.7.1723104592529; Thu, 08 Aug 2024 01:09:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUusoL149Zvb9EZUOCLZvO56qko1QjRrxz/Ccc7VybB5+PRrGL2zkQu51bQ9R0kKjqBFaqDA== X-Received: by 2002:a17:906:4783:b0:a7a:a212:be4e with SMTP id a640c23a62f3a-a8090c29b81mr85849666b.7.1723104591961; Thu, 08 Aug 2024 01:09:51 -0700 (PDT) Received: from [10.168.67.37] ([131.175.147.29]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-a7dc9e8674dsm729292966b.146.2024.08.08.01.09.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Aug 2024 01:09:51 -0700 (PDT) Message-ID: Date: Thu, 8 Aug 2024 10:09:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v6 1/5] build-sys: Add rust feature option To: Manos Pitsidianakis , qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Mads Ynddal , Peter Maydell , =?UTF-8?Q?Alex_Benn=C3=A9e?= , =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , =?UTF-8?Q?Marc-Andr=C3=A9_Lureau?= , Thomas Huth , Markus Armbruster , =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= , Zhao Liu , Gustavo Romero , Pierrick Bouvier , rowan.hart@intel.com, Richard Henderson References: From: Paolo Bonzini Content-Language: en-US Autocrypt: addr=pbonzini@redhat.com; keydata= xsEhBFRCcBIBDqDGsz4K0zZun3jh+U6Z9wNGLKQ0kSFyjN38gMqU1SfP+TUNQepFHb/Gc0E2 CxXPkIBTvYY+ZPkoTh5xF9oS1j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XYfA3bgtFN8WJH2xgFL28XnqY4M6dLhJwV3z08tPSRqYFm4NMP dRsn0/7oymhneL8RthIvjDDQ5ktUjMe8LtHr70OZE/TT88qvEdhiIVUogHdo4qBrk41+gGQh b906Dudw5YhTJFU3nC6bbF2nrLlB4C/XSiH76ZvqzV0Z/cAMBo5NF/w= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 8/4/24 23:04, Manos Pitsidianakis wrote: > diff --git a/configure b/configure > index 019fcbd0ef..aac7f29f25 100755 > --- a/configure > +++ b/configure > @@ -874,6 +874,8 @@ Advanced options (experts only): > start the emulator (only use if you are including > desired devices in configs/devices/) > --with-devices-ARCH=NAME override default configs/devices > + --enable-rust enable compilation of Rust code > + --disable-rust disable compilation of Rust code Not needed ("rust" is included in the features list emitted by meson-build-options.sh) > --enable-debug enable common debug build options > --cpu=CPU Build for host CPU [$cpu] > --disable-containers don't use containers for cross-building > diff --git a/meson.build b/meson.build > index 97f63aa86c..9593fce47f 100644 > --- a/meson.build > +++ b/meson.build > @@ -70,6 +70,22 @@ if host_os == 'darwin' and \ > all_languages += ['objc'] > objc = meson.get_compiler('objc') > endif > +if get_option('rust').enabled() and meson.version().version_compare('<1.0.0') > + error('Rust support requires Meson version >=1.0.0') > +endif Also not needed (1.1.0 is the minimum supported meson version). > +have_rust = false > +if not get_option('rust').disabled() and add_languages('rust', required: get_option('rust'), native: false) > + rustc = meson.get_compiler('rust') The main missing part here is setting rustc in the native and cross files. This is a small change to the patch I had for cargo: diff --git a/configure b/configure index aac7f29f25c..f2d5a9a8d40 100755 --- a/configure +++ b/configure @@ -207,6 +207,8 @@ for opt do ;; --objcc=*) objcc="$optarg" ;; + --rustc=*) RUSTC="$optarg" + ;; --cpu=*) cpu="$optarg" ;; --extra-cflags=*) @@ -252,6 +254,9 @@ python= download="enabled" skip_meson=no use_containers="yes" +# do not enable by default because cross compilation requires --rust-target-triple +rust="disabled" +rust_target_triple="" gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") gdb_arches="" @@ -317,6 +322,8 @@ windmc="${WINDMC-${cross_prefix}windmc}" pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}" sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" +rustc="${RUSTC-rustc}" + check_define() { cat > $TMPC < "${TMPDIR1}/${TMPB}.out"; then + rust_host_triple=$(sed -n 's/^host: //p' "${TMPDIR1}/${TMPB}.out") +else + if test "$rust" = enabled; then + error_exit "could not execute rustc binary \"$rustc\"" + fi + rust=disabled +fi +if test "$rust" != disabled && test -z "$rust_target_triple"; then + rust_target_triple=$rust_host_triple +fi + ########################################## # functions to probe cross compilers @@ -1606,6 +1636,9 @@ if test "$container" != no; then echo "RUNC=$runc" >> $config_host_mak fi echo "SUBDIRS=$subdirs" >> $config_host_mak +if test "$rust" != disabled; then + echo "RUST_TARGET_TRIPLE=$rust_target_triple" >> $config_host_mak +fi echo "PYTHON=$python" >> $config_host_mak echo "MKVENV_ENSUREGROUP=$mkvenv ensuregroup $mkvenv_online_flag" >> $config_host_mak echo "GENISOIMAGE=$genisoimage" >> $config_host_mak @@ -1737,6 +1770,13 @@ if test "$skip_meson" = no; then echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross + if test "$rust" != disabled; then + if test "$rust_host_triple" != "$rust_target_triple"; then + echo "rustc = [$(meson_quote $rustc --target "$rust_target_triple")]" >> $cross + else + echo "rustc = [$(meson_quote $rustc)]" >> $cross + fi + fi echo "ar = [$(meson_quote $ar)]" >> $cross echo "dlltool = [$(meson_quote $dlltool)]" >> $cross echo "nm = [$(meson_quote $nm)]" >> $cross @@ -1772,6 +1812,9 @@ if test "$skip_meson" = no; then echo "# Automatically generated by configure - do not modify" > $native echo "[binaries]" >> $native echo "c = [$(meson_quote $host_cc)]" >> $native + if test "$rust" != disabled; then + echo "rustc = [$(meson_quote $rustc)]" >> $cross + fi mv $native config-meson.native meson_option_add --native-file meson_option_add config-meson.native @@ -1790,6 +1833,7 @@ if test "$skip_meson" = no; then test "$pie" = no && meson_option_add -Db_pie=false # QEMU options + test "$rust" != "auto" && meson_option_add "-Drust=$rust" test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi" test "$docs" != auto && meson_option_add "-Ddocs=$docs" test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE" diff --git a/meson.build b/meson.build index b89ce025c1a..e656ef34aab 100644 --- a/meson.build +++ b/meson.build @@ -70,9 +70,6 @@ if host_os == 'darwin' and \ all_languages += ['objc'] objc = meson.get_compiler('objc') endif -if get_option('rust').enabled() and meson.version().version_compare('<1.0.0') - error('Rust support requires Meson version >=1.0.0') -endif have_rust = false if not get_option('rust').disabled() and add_languages('rust', required: get_option('rust'), native: false) rustc = meson.get_compiler('rust') @@ -4305,8 +4302,9 @@ else endif summary_info += {'Rust support': have_rust} if have_rust - summary_info += {'rustc version': rustc.version()} - summary_info += {'rustc': ' '.join(rustc.cmd_array())} + summary_info += {'rustc version': rustc.version()} + summary_info += {'rustc': ' '.join(rustc.cmd_array())} + summary_info += {'Rust target': config_host['RUST_TARGET_TRIPLE']} endif option_cflags = (get_option('debug') ? ['-g'] : []) if get_option('optimization') != 'plain'