diff options
| author | Richard Henderson <richard.henderson@linaro.org> | 2025-09-30 09:29:17 -0700 |
|---|---|---|
| committer | Richard Henderson <richard.henderson@linaro.org> | 2025-09-30 09:29:38 -0700 |
| commit | 29b77c1a2db2d796bc3847852a5c8dc2a1e6e83b (patch) | |
| tree | ade324bd385a718d8a9c0d3dd0d60e607b640f2b /scripts/rust-to-clang-target.sh | |
| parent | 74de8d6b8431b3b16dff8e1235cb4f47f7feb3d1 (diff) | |
| parent | 582a39beea414c092dbd8c178f3eff3a718eee77 (diff) | |
| download | focaccia-qemu-29b77c1a2db2d796bc3847852a5c8dc2a1e6e83b.tar.gz focaccia-qemu-29b77c1a2db2d796bc3847852a5c8dc2a1e6e83b.zip | |
Merge tag 'rust-ci-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging
CI/build-sys fixes for Rust Collect CI/build-sys patches related to Rust. # -----BEGIN PGP SIGNATURE----- # # iQJQBAABCgA6FiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmjb+PUcHG1hcmNhbmRy # ZS5sdXJlYXVAcmVkaGF0LmNvbQAKCRDa6OEJdZac5Y3iEAC2C8pc2lPCTGFI+0N/ # eqXwTCeSysbmprhqf3vWXQEke8WgYMGPeZNXqUUnzzRuR5oN7JTy6YNzLCM0jGUp # QHciTecyPVQjIlWOs+HURqKsrLO2CG1sbWuips1eZ6X8O5KdHLxfFqvyReflEn/z # G1LHhQEWQzKwR0kj3VVHjyUzeSIJVch8sVONkby4h2DMFO4lHtcrr7VAzKlwKGAt # kgFgijaLe7xCPktJs7g2x+NfBeRbnQ/3mb3/3pkunx98Dhhis0yTZSyfzlChyVfL # FwTf/xWgw/0oQ8+c9E/RJz6DVvgjJNASrLumuZWO7HVdDV60cvMwb3xHOcQmAz7t # +ySKM08jI9lWYIr/tKnwWo1NWFWPzDts0L+M/pRhQ1/pYw8OnYvtwnKd3ClEVRbp # dYcKRE97t3L8BbWyB5hTvTc0V0IVbOOhfDVZfG/IPqxIKWHeCGLL2PiyKGBgfU2M # V4okrMbGqWH72HZbLUpMYcaaK9lVv6ng/3AH817giJVnCuNO06m420/7Q8WcX68o # foIeTbL83h8KCqi8pGCJUW9Wz3/wIk3AYkUKwdISswCL6nSgt7pk7K1fnFwGI4bu # PqzQITelnRUK0TOvqzbDi6Y3j0p06/bc4TAHoI76Yzi3iUrQL0ynOAFFf6Wk13p9 # EnMAlnsrY9kyJrCMU66lroU/RQ== # =rMSk # -----END PGP SIGNATURE----- # gpg: Signature made Tue 30 Sep 2025 08:36:21 AM PDT # gpg: using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5 # gpg: issuer "marcandre.lureau@redhat.com" # gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [unknown] # gpg: aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [unknown] # gpg: WARNING: The key's User ID is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 87A9 BD93 3F87 C606 D276 F62D DAE8 E109 7596 9CE5 * tag 'rust-ci-pull-request' of https://gitlab.com/marcandre.lureau/qemu: (23 commits) build-sys: pass -fvisibility=default for wasm bindgen build-sys: deprecate mips host meson: rust-bindgen limit allowlist-file to srcdir/include tests/freebsd: enable Rust configure: set the meson executable suffix/ext tests/lcitool: enable rust & refresh tests/docker: add ENABLE_RUST environment tests/lcitool: update to debian13 tests/lcitool: add missing rust-std dep lcitool/alpine: workaround bindgen issue lcitool/qemu: include libclang-rt for TSAN lcitool: update, switch to f41 build-sys: cfi_debug and safe_stack are not compatible tests/docker/common: print meson log on configure failure tests/docker: use fully qualified image name for emsdk tests/docker/common: print errors to stderr configure: set the bindgen cross target configure: fix rust meson configuration scripts/archive-source: use a bash array scripts/archive-source: silence subprojects downloads ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'scripts/rust-to-clang-target.sh')
| -rw-r--r-- | scripts/rust-to-clang-target.sh | 60 |
1 files changed, 60 insertions, 0 deletions
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="$1" + + # Split the string by hyphens + triple_parts="" + old_IFS="$IFS" + IFS='-' + for part in $rust_target; do + triple_parts="$triple_parts $part" + done + IFS="$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" = "apple" ]; then + if [ "$1" = "aarch64" ]; then + set -- "arm64" "${2}" "${3}" "${4}" + fi + if [ "$4" = "sim" ]; then + set -- "${1}" "${2}" "${3}" "simulator" + fi + fi + + # ESP-IDF + if [ "$3" = "espidf" ]; then + set -- "${1}" "${2}" "elf" "${4}" + fi + + # Reassemble the string + new_triple="" + first=1 + for part in "$@"; do + if [ -n "$part" ]; then + if [ "$first" -eq 1 ]; then + new_triple="$part" + first=0 + else + new_triple="$new_triple-$part" + fi + fi + done + + echo "$new_triple" +} |