From nobody Sun Oct 5 02:02:04 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759246758; cv=none; d=zohomail.com; s=zohoarc; b=WpjMLDPUhkN0NocUDnidhhpf5asaJd+s+zLitRQ/KBUqKZIGC7o4dqn+OKWWi1HJxlMqY5k4SK1n1JMzkxTTS+kcKQm0CQOFVW3qBFaW1ks+/SofjSowzLRKImgz/1kShM7/NQpNecmmmkCrN+PDNUvckO1cIH0zdITaM2zuhaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759246758; 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=S7SIBgllnz6KmtZoaB98vFEfu3NyG7UL6U+A2rY+G0U=; b=j0Ii2JAPGGMHOL+gHfa/VvrHyS2sRjS6FeTXKEShsdLxaGka2DYjJc4chHnM/9Gprj8sTcnA0E/mOSQJnhmQNUVigsHDH7vpG3HSC25KTbZiRCo/Q6kwH6ZHrVr4hH5F1YAeh1jhqm/jraEolsb2/fqItR1P+tKQ92sd6rahl2A= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759246758937225.51764203878963; Tue, 30 Sep 2025 08:39:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v3cRF-0008Ej-F2; Tue, 30 Sep 2025 11:38:49 -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 1v3cRD-0008Cw-Hx for qemu-devel@nongnu.org; Tue, 30 Sep 2025 11:38: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 1v3cR7-0004Hb-Tt for qemu-devel@nongnu.org; Tue, 30 Sep 2025 11:38:47 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-JKJTufL9MreRhr7YD0yTig-1; Tue, 30 Sep 2025 11:38:35 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1B5AA1977309; Tue, 30 Sep 2025 15:38:34 +0000 (UTC) Received: from localhost (unknown [10.45.242.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A91F01800452; Tue, 30 Sep 2025 15:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759246720; 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=S7SIBgllnz6KmtZoaB98vFEfu3NyG7UL6U+A2rY+G0U=; b=YrjWKbSmSmTrGGiT7aSb2ZOX9aAGUfn2ru7znpxt0kAljOugHY1UAxsFnHc2/2mZ+pQCgo deg4VldIycf15uU9pFfg2ePOS8MPh7mqBEN5OeYHRsyGRm+4KDrwNjzMgoyKFqoTtA6wcZ Ea8SLXjFS+vTjrdkgJvEapYItFeMoaU= X-MC-Unique: JKJTufL9MreRhr7YD0yTig-1 X-Mimecast-MFC-AGG-ID: JKJTufL9MreRhr7YD0yTig_1759246714 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: devel@lists.libvirt.org, Manos Pitsidianakis , Jiaxun Yang , Kohei Tokunaga , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-rust@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Warner Losh , Kyle Evans , Ed Maste , Thomas Huth Subject: [PULL 07/23] configure: set the bindgen cross target Date: Tue, 30 Sep 2025 19:37:28 +0400 Message-ID: <20250930153746.573875-8-marcandre.lureau@redhat.com> In-Reply-To: <20250930153746.573875-1-marcandre.lureau@redhat.com> References: <20250930153746.573875-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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: -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.445, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759246760971116600 From: Marc-Andr=C3=A9 Lureau Implement a bash version of rust-bindgen rust_to_clang_target() to convert from rust target to clang target. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Paolo Bonzini Message-ID: <20250924120426.2158655-8-marcandre.lureau@redhat.com> --- configure | 7 ++++ scripts/rust-to-clang-target-test.sh | 43 ++++++++++++++++++++ scripts/rust-to-clang-target.sh | 60 ++++++++++++++++++++++++++++ tests/lcitool/libvirt-ci | 2 +- 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100755 scripts/rust-to-clang-target-test.sh create mode 100644 scripts/rust-to-clang-target.sh diff --git a/configure b/configure index 66613f3f4c..bf964947b8 100755 --- a/configure +++ b/configure @@ -1878,6 +1878,13 @@ if test "$skip_meson" =3D no; then eval "c=3D\$devices_${a}" echo "${a}-softmmu =3D '$c'" >> $cross done + if test "$rust" !=3D disabled; then + if test "$cross_compile" =3D "yes"; then + . "$source_path/scripts/rust-to-clang-target.sh" + clang_target=3D$(rust_to_clang_target "$rust_target_triple") + echo "bindgen_clang_arguments =3D [$(meson_quote --target=3D"$cl= ang_target")]" >> $cross + fi + fi =20 echo "[built-in options]" >> $cross echo "c_args =3D [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross diff --git a/scripts/rust-to-clang-target-test.sh b/scripts/rust-to-clang-t= arget-test.sh new file mode 100755 index 0000000000..ff6f8fcdc5 --- /dev/null +++ b/scripts/rust-to-clang-target-test.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env sh +# +# Copyright (C) 2025 Red Hat, Inc. +# +# Based on rust_to_clang_target() tests from rust-bindgen. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +scripts_dir=3D$(CDPATH=3D cd -- "$(dirname -- "$0")" && pwd) +. "$scripts_dir/rust-to-clang-target.sh" + +test_case() { + input=3D"$1" + expected=3D"$2" + result=3D$(rust_to_clang_target "$input") + + if [ "$result" =3D "$expected" ]; then + echo " OK: '$input' -> '$result'" + else + echo " FAILED: '$input'" + echo " Expected: '$expected'" + echo " Got: '$result'" + exit 1 + fi +} + +echo "Running tests..." + +test_case "aarch64-apple-ios" "arm64-apple-ios" +test_case "riscv64gc-unknown-linux-gnu" "riscv64-unknown-linux-gnu" +test_case "riscv64imac-unknown-none-elf" "riscv64-unknown-none-elf" +test_case "riscv32imc-unknown-none-elf" "riscv32-unknown-none-elf" +test_case "riscv32imac-unknown-none-elf" "riscv32-unknown-none-elf" +test_case "riscv32imafc-unknown-none-elf" "riscv32-unknown-none-elf" +test_case "riscv32i-unknown-none-elf" "riscv32-unknown-none-elf" +test_case "riscv32imc-esp-espidf" "riscv32-esp-elf" +test_case "xtensa-esp32-espidf" "xtensa-esp32-elf" +test_case "aarch64-apple-ios-sim" "arm64-apple-ios-simulator" +test_case "aarch64-apple-tvos-sim" "arm64-apple-tvos-simulator" +test_case "aarch64-apple-watchos-sim" "arm64-apple-watchos-simulator" + +echo "" +echo "All tests passed!" diff --git a/scripts/rust-to-clang-target.sh b/scripts/rust-to-clang-target= .sh new file mode 100644 index 0000000000..72db7e1300 --- /dev/null +++ b/scripts/rust-to-clang-target.sh @@ -0,0 +1,60 @@ +# Copyright (C) 2025 Red Hat, Inc. +# +# Based on rust_to_clang_target() from rust-bindgen. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +rust_to_clang_target() { + rust_target=3D"$1" + + # Split the string by hyphens + triple_parts=3D"" + old_IFS=3D"$IFS" + IFS=3D'-' + for part in $rust_target; do + triple_parts=3D"$triple_parts $part" + done + IFS=3D"$old_IFS" + set -- $triple_parts + + # RISC-V + case "$1" in + riscv32*) + set -- "riscv32" "${2}" "${3}" "${4}" + ;; + riscv64*) + set -- "riscv64" "${2}" "${3}" "${4}" + ;; + esac + + # Apple + if [ "$2" =3D "apple" ]; then + if [ "$1" =3D "aarch64" ]; then + set -- "arm64" "${2}" "${3}" "${4}" + fi + if [ "$4" =3D "sim" ]; then + set -- "${1}" "${2}" "${3}" "simulator" + fi + fi + + # ESP-IDF + if [ "$3" =3D "espidf" ]; then + set -- "${1}" "${2}" "elf" "${4}" + fi + + # Reassemble the string + new_triple=3D"" + first=3D1 + for part in "$@"; do + if [ -n "$part" ]; then + if [ "$first" -eq 1 ]; then + new_triple=3D"$part" + first=3D0 + else + new_triple=3D"$new_triple-$part" + fi + fi + done + + echo "$new_triple" +} diff --git a/tests/lcitool/libvirt-ci b/tests/lcitool/libvirt-ci index 18c4bfe02c..9da20ff7c3 160000 --- a/tests/lcitool/libvirt-ci +++ b/tests/lcitool/libvirt-ci @@ -1 +1 @@ -Subproject commit 18c4bfe02c467e5639bf9a687139735ccd7a3fff +Subproject commit 9da20ff7c3bc9067804a7561c2ff87583b434853 --=20 2.51.0