summaryrefslogtreecommitdiffstats
path: root/meta
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:45 +0100
commitd6b563710e6cc0857843433d85023d47f9f2037d (patch)
treec80b1492f65f5d562fb4d76cb07678ac253f1e77 /meta
parent463bcb876eef2a7faf50916e921b0d8ea0daefa5 (diff)
downloadpoky-d6b563710e6cc0857843433d85023d47f9f2037d.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. (From OE-Core rev: 79bd6389585327820dfc1a1d29f60779ef08b2e0) 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>
Diffstat (limited to 'meta')
-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):
119 119
120 120
121## arm-unknown-linux-gnueabihf 121## arm-unknown-linux-gnueabihf
122DATA_LAYOUT[arm] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 122DATA_LAYOUT[arm-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
123LLVM_TARGET[arm] = "${RUST_TARGET_SYS}" 123LLVM_TARGET[arm-eabi] = "${RUST_TARGET_SYS}"
124TARGET_ENDIAN[arm] = "little" 124TARGET_ENDIAN[arm-eabi] = "little"
125TARGET_POINTER_WIDTH[arm] = "32" 125TARGET_POINTER_WIDTH[arm-eabi] = "32"
126TARGET_C_INT_WIDTH[arm] = "32" 126TARGET_C_INT_WIDTH[arm-eabi] = "32"
127MAX_ATOMIC_WIDTH[arm] = "64" 127MAX_ATOMIC_WIDTH[arm-eabi] = "64"
128FEATURES[arm] = "+v6,+vfp2" 128FEATURES[arm-eabi] = "+v6,+vfp2"
129 129
130## armv7-unknown-linux-gnueabihf 130## armv7-unknown-linux-gnueabihf
131DATA_LAYOUT[armv7] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 131DATA_LAYOUT[armv7-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
132LLVM_TARGET[armv7] = "${RUST_TARGET_SYS}" 132LLVM_TARGET[armv7-eabi] = "${RUST_TARGET_SYS}"
133TARGET_ENDIAN[armv7] = "little" 133TARGET_ENDIAN[armv7-eabi] = "little"
134TARGET_POINTER_WIDTH[armv7] = "32" 134TARGET_POINTER_WIDTH[armv7-eabi] = "32"
135TARGET_C_INT_WIDTH[armv7] = "32" 135TARGET_C_INT_WIDTH[armv7-eabi] = "32"
136MAX_ATOMIC_WIDTH[armv7] = "64" 136MAX_ATOMIC_WIDTH[armv7-eabi] = "64"
137FEATURES[armv7] = "+v7,+vfp2,+thumb2" 137FEATURES[armv7-eabi] = "+v7,+vfp2,+thumb2"
138 138
139## aarch64-unknown-linux-{gnu, musl} 139## aarch64-unknown-linux-{gnu, musl}
140DATA_LAYOUT[aarch64] = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 140DATA_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"
152TARGET_C_INT_WIDTH[x86_64] = "32" 152TARGET_C_INT_WIDTH[x86_64] = "32"
153MAX_ATOMIC_WIDTH[x86_64] = "64" 153MAX_ATOMIC_WIDTH[x86_64] = "64"
154 154
155## x86_64-unknown-linux-gnux32
156DATA_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"
157LLVM_TARGET[x86_64-x32] = "${RUST_TARGET_SYS}"
158TARGET_ENDIAN[x86_64-x32] = "little"
159TARGET_POINTER_WIDTH[x86_64-x32] = "32"
160TARGET_C_INT_WIDTH[x86_64-x32] = "32"
161MAX_ATOMIC_WIDTH[x86_64-x32] = "64"
162
155## i686-unknown-linux-{gnu, musl} 163## i686-unknown-linux-{gnu, musl}
156DATA_LAYOUT[i686] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" 164DATA_LAYOUT[i686] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
157LLVM_TARGET[i686] = "${RUST_TARGET_SYS}" 165LLVM_TARGET[i686] = "${RUST_TARGET_SYS}"
@@ -292,22 +300,27 @@ TARGET_LLVM_FEATURES = "${@llvm_features(d)}"
292# (original) target. 300# (original) target.
293TARGET_LLVM_FEATURES:class-native = "${@','.join(llvm_features_from_cc_arch(d))}" 301TARGET_LLVM_FEATURES:class-native = "${@','.join(llvm_features_from_cc_arch(d))}"
294 302
295def rust_gen_target(d, thing, wd, features, cpu, arch): 303def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""):
296 import json 304 import json
297 sys = sys_for(d, thing) 305 sys = sys_for(d, thing)
298 prefix = prefix_for(d, thing) 306 prefix = prefix_for(d, thing)
299 307
300 features = features or d.getVarFlag('FEATURES', arch) or "" 308 if abi:
309 arch_abi = "{}-{}".format(arch, abi)
310 else:
311 arch_abi = arch
312
313 features = features or d.getVarFlag('FEATURES', arch_abi) or ""
301 features = features.strip() 314 features = features.strip()
302 315
303 # build tspec 316 # build tspec
304 tspec = {} 317 tspec = {}
305 tspec['llvm-target'] = d.getVarFlag('LLVM_TARGET', arch) 318 tspec['llvm-target'] = d.getVarFlag('LLVM_TARGET', arch_abi)
306 tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch) 319 tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi)
307 tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch)) 320 tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch_abi))
308 tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch) 321 tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch_abi)
309 tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch) 322 tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch_abi)
310 tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch) 323 tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch_abi)
311 tspec['arch'] = arch_to_rust_target_arch(arch) 324 tspec['arch'] = arch_to_rust_target_arch(arch)
312 tspec['os'] = "linux" 325 tspec['os'] = "linux"
313 if "musl" in tspec['llvm-target']: 326 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 () {
11 features = "" 11 features = ""
12 cpu = "generic" 12 cpu = "generic"
13 arch = d.getVar('{}_ARCH'.format(thing)) 13 arch = d.getVar('{}_ARCH'.format(thing))
14 abi = ""
14 if thing is "TARGET": 15 if thing is "TARGET":
16 abi = d.getVar('ABIEXTENSION')
15 # arm and armv7 have different targets in llvm 17 # arm and armv7 have different targets in llvm
16 if arch == "arm" and target_is_armv7(d): 18 if arch == "arm" and target_is_armv7(d):
17 arch = 'armv7' 19 arch = 'armv7'
18 features = d.getVar('TARGET_LLVM_FEATURES') or "" 20 features = d.getVar('TARGET_LLVM_FEATURES') or ""
19 cpu = d.getVar('TARGET_LLVM_CPU') 21 cpu = d.getVar('TARGET_LLVM_CPU')
20 rust_gen_target(d, thing, wd, features, cpu, arch) 22 rust_gen_target(d, thing, wd, features, cpu, arch, abi)
21} 23}
22 24
23# Otherwise we'll depend on what we provide 25# Otherwise we'll depend on what we provide