summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2021-10-10 21:10:08 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-14 11:48:35 +0100
commit79bd6389585327820dfc1a1d29f60779ef08b2e0 (patch)
treef82e0082d9c170a64274a4475b73dc04bc4af17f
parent320f2c5aa535237fab4f4a1e6f75358f53221459 (diff)
downloadopenembedded-core-contrib-79bd6389585327820dfc1a1d29f60779ef08b2e0.tar.gz
rust: generate target definitions from (arch, abi), not just arch
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>
-rw-r--r--meta/recipes-devtools/rust/rust-common.inc57
-rw-r--r--meta/recipes-devtools/rust/rust-cross.inc4
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 797284316e..7f92602e16 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 bee7c9f12f..42163f7b81 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