]> code.ossystems Code Review - openembedded-core.git/commitdiff
rust: generate target definitions from (arch, abi), not just arch
authorAlexander Kanavin <alex.kanavin@gmail.com>
Sun, 10 Oct 2021 19:10:08 +0000 (21:10 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 14 Oct 2021 10:48:35 +0000 (11:48 +0100)
This allows to add the missing x32 definition and others in the future.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/rust/rust-common.inc
meta/recipes-devtools/rust/rust-cross.inc

index 797284316e2d5938eea8fad50d0e4a65de68e9c2..7f92602e165ed7ff26142236237ac654f307b22f 100644 (file)
@@ -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']:
index bee7c9f12f3c4b266103d849a844efc1c632d571..42163f7b819457d11ab06510ad1ebc1d1e8500d6 100644 (file)
@@ -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