All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Kanavin <alex.kanavin@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Alexander Kanavin <alex@linutronix.de>
Subject: [PATCH 13/13] rust: generate target definitions from (arch, abi), not just arch
Date: Sun, 10 Oct 2021 21:10:08 +0200	[thread overview]
Message-ID: <20211010191008.4122049-13-alex@linutronix.de> (raw)
In-Reply-To: <20211010191008.4122049-1-alex@linutronix.de>

This allows to add the missing x32 definition and others in the future.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/recipes-devtools/rust/rust-common.inc | 57 +++++++++++++---------
 meta/recipes-devtools/rust/rust-cross.inc  |  4 +-
 2 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/meta/recipes-devtools/rust/rust-common.inc b/meta/recipes-devtools/rust/rust-common.inc
index 797284316e2..7f92602e165 100644
--- a/meta/recipes-devtools/rust/rust-common.inc
+++ b/meta/recipes-devtools/rust/rust-common.inc
@@ -119,22 +119,22 @@ def llvm_features(d):
 
 
 ## arm-unknown-linux-gnueabihf
-DATA_LAYOUT[arm] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-LLVM_TARGET[arm] = "${RUST_TARGET_SYS}"
-TARGET_ENDIAN[arm] = "little"
-TARGET_POINTER_WIDTH[arm] = "32"
-TARGET_C_INT_WIDTH[arm] = "32"
-MAX_ATOMIC_WIDTH[arm] = "64"
-FEATURES[arm] = "+v6,+vfp2"
+DATA_LAYOUT[arm-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+LLVM_TARGET[arm-eabi] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[arm-eabi] = "little"
+TARGET_POINTER_WIDTH[arm-eabi] = "32"
+TARGET_C_INT_WIDTH[arm-eabi] = "32"
+MAX_ATOMIC_WIDTH[arm-eabi] = "64"
+FEATURES[arm-eabi] = "+v6,+vfp2"
 
 ## armv7-unknown-linux-gnueabihf
-DATA_LAYOUT[armv7] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-LLVM_TARGET[armv7] = "${RUST_TARGET_SYS}"
-TARGET_ENDIAN[armv7] = "little"
-TARGET_POINTER_WIDTH[armv7] = "32"
-TARGET_C_INT_WIDTH[armv7] = "32"
-MAX_ATOMIC_WIDTH[armv7] = "64"
-FEATURES[armv7] = "+v7,+vfp2,+thumb2"
+DATA_LAYOUT[armv7-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+LLVM_TARGET[armv7-eabi] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[armv7-eabi] = "little"
+TARGET_POINTER_WIDTH[armv7-eabi] = "32"
+TARGET_C_INT_WIDTH[armv7-eabi] = "32"
+MAX_ATOMIC_WIDTH[armv7-eabi] = "64"
+FEATURES[armv7-eabi] = "+v7,+vfp2,+thumb2"
 
 ## aarch64-unknown-linux-{gnu, musl}
 DATA_LAYOUT[aarch64] = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
@@ -152,6 +152,14 @@ TARGET_POINTER_WIDTH[x86_64] = "64"
 TARGET_C_INT_WIDTH[x86_64] = "32"
 MAX_ATOMIC_WIDTH[x86_64] = "64"
 
+## x86_64-unknown-linux-gnux32
+DATA_LAYOUT[x86_64-x32] = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+LLVM_TARGET[x86_64-x32] = "${RUST_TARGET_SYS}"
+TARGET_ENDIAN[x86_64-x32] = "little"
+TARGET_POINTER_WIDTH[x86_64-x32] = "32"
+TARGET_C_INT_WIDTH[x86_64-x32] = "32"
+MAX_ATOMIC_WIDTH[x86_64-x32] = "64"
+
 ## i686-unknown-linux-{gnu, musl}
 DATA_LAYOUT[i686] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
 LLVM_TARGET[i686] = "${RUST_TARGET_SYS}"
@@ -292,22 +300,27 @@ TARGET_LLVM_FEATURES = "${@llvm_features(d)}"
 # (original) target.
 TARGET_LLVM_FEATURES:class-native = "${@','.join(llvm_features_from_cc_arch(d))}"
 
-def rust_gen_target(d, thing, wd, features, cpu, arch):
+def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""):
     import json
     sys = sys_for(d, thing)
     prefix = prefix_for(d, thing)
 
-    features = features or d.getVarFlag('FEATURES', arch) or ""
+    if abi:
+        arch_abi = "{}-{}".format(arch, abi)
+    else:
+        arch_abi = arch
+
+    features = features or d.getVarFlag('FEATURES', arch_abi) or ""
     features = features.strip()
 
     # build tspec
     tspec = {}
-    tspec['llvm-target'] = d.getVarFlag('LLVM_TARGET', arch)
-    tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch)
-    tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch))
-    tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch)
-    tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch)
-    tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch)
+    tspec['llvm-target'] = d.getVarFlag('LLVM_TARGET', arch_abi)
+    tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi)
+    tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch_abi))
+    tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch_abi)
+    tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch_abi)
+    tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch_abi)
     tspec['arch'] = arch_to_rust_target_arch(arch)
     tspec['os'] = "linux"
     if "musl" in tspec['llvm-target']:
diff --git a/meta/recipes-devtools/rust/rust-cross.inc b/meta/recipes-devtools/rust/rust-cross.inc
index bee7c9f12f3..42163f7b819 100644
--- a/meta/recipes-devtools/rust/rust-cross.inc
+++ b/meta/recipes-devtools/rust/rust-cross.inc
@@ -11,13 +11,15 @@ python do_rust_gen_targets () {
         features = ""
         cpu = "generic"
         arch = d.getVar('{}_ARCH'.format(thing))
+        abi = ""
         if thing is "TARGET":
+            abi = d.getVar('ABIEXTENSION')
             # arm and armv7 have different targets in llvm
             if arch == "arm" and target_is_armv7(d):
                 arch = 'armv7'
             features = d.getVar('TARGET_LLVM_FEATURES') or ""
             cpu = d.getVar('TARGET_LLVM_CPU')
-        rust_gen_target(d, thing, wd, features, cpu, arch)
+        rust_gen_target(d, thing, wd, features, cpu, arch, abi)
 }
 
 # Otherwise we'll depend on what we provide
-- 
2.20.1



  parent reply	other threads:[~2021-10-10 19:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-10 19:09 [PATCH 01/13] rust: drop PV from include file names Alexander Kanavin
2021-10-10 19:09 ` [PATCH 02/13] rust: update 1.54.0 -> 1.55.0 Alexander Kanavin
2021-10-10 19:09 ` [PATCH 03/13] librsvg: update 2.40.21 -> 2.52.0 (transition to rust!) Alexander Kanavin
2021-10-10 19:09 ` [PATCH 04/13] librsvg: do not enable nativesdk Alexander Kanavin
2021-10-10 19:10 ` [PATCH 05/13] librsvg: add backports to fix big endian targets (e.g. mips) Alexander Kanavin
2021-10-10 19:10 ` [PATCH 06/13] librsvg: use only the target architecture to determine availability of atomic primitives Alexander Kanavin
2021-10-10 19:10 ` [PATCH 07/13] librsvg: restore reproducibility Alexander Kanavin
2021-10-10 19:10 ` [PATCH 08/13] adwaita-icon-theme: update 3.34/38 -> 41.0 Alexander Kanavin
2021-10-10 19:10 ` [PATCH 09/13] gstreamer1.0-plugins-bad: disable rsvg on x32 Alexander Kanavin
2021-10-10 19:10 ` [PATCH 10/13] rust/cargo: exclude UNINATIVE_LOADER from task signature Alexander Kanavin
2021-10-10 19:10 ` [PATCH 11/13] rust-common.bbclass: rewrite toolchain wrappers in (native) python Alexander Kanavin
2021-10-10 19:10 ` [PATCH 12/13] rust: do not write ar into target json definitions Alexander Kanavin
2021-10-10 19:10 ` Alexander Kanavin [this message]
2021-10-11 17:02   ` [OE-core] [PATCH 13/13] rust: generate target definitions from (arch, abi), not just arch Khem Raj
2021-10-11 17:14     ` Alexander Kanavin
2021-10-11 17:22       ` Khem Raj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211010191008.4122049-13-alex@linutronix.de \
    --to=alex.kanavin@gmail.com \
    --cc=alex@linutronix.de \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.