summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/rust-target-config.bbclass
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2022-10-25 20:44:26 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-10-28 09:44:52 +0100
commit6608c076f64e37fd8c2cda41c1e700f86e4e60a8 (patch)
tree7c751f8b5dc8e9192f119d71a114946bd83e6b4c /meta/classes-recipe/rust-target-config.bbclass
parent8dc68c2a80c029b10b7c072b67542d188379bbfe (diff)
downloadpoky-6608c076f64e37fd8c2cda41c1e700f86e4e60a8.tar.gz
rust-target-config: match riscv target names with what rust expects
Official rust risc-v targets are prefixed with riscv32gc- and riscv64gc-: https://doc.rust-lang.org/nightly/rustc/platform-support.html Particularly crossbeam-utils make important build time decisions for atomics based on those names, and so we need to match ours with official targets. On the other hand, the actual definitions for those targets do not use the 'gc' suffix in 'arch' and 'llvm-target' fields, and so we need to follow that too, to avoid cryptic mismatch errors from rust-llvm: https://github.com/rust-lang/rust/blob/master/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_gnu.rs (From OE-Core rev: 1cfb9c8a59d98ccc9b0510cd28fb933f72fb6b6c) 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/classes-recipe/rust-target-config.bbclass')
-rw-r--r--meta/classes-recipe/rust-target-config.bbclass40
1 files changed, 26 insertions, 14 deletions
diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass
index 9e1d81bf5c..2710b4325d 100644
--- a/meta/classes-recipe/rust-target-config.bbclass
+++ b/meta/classes-recipe/rust-target-config.bbclass
@@ -231,19 +231,19 @@ TARGET_POINTER_WIDTH[powerpc64le] = "64"
231TARGET_C_INT_WIDTH[powerpc64le] = "64" 231TARGET_C_INT_WIDTH[powerpc64le] = "64"
232MAX_ATOMIC_WIDTH[powerpc64le] = "64" 232MAX_ATOMIC_WIDTH[powerpc64le] = "64"
233 233
234## riscv32-unknown-linux-{gnu, musl} 234## riscv32gc-unknown-linux-{gnu, musl}
235DATA_LAYOUT[riscv32] = "e-m:e-p:32:32-i64:64-n32-S128" 235DATA_LAYOUT[riscv32gc] = "e-m:e-p:32:32-i64:64-n32-S128"
236TARGET_ENDIAN[riscv32] = "little" 236TARGET_ENDIAN[riscv32gc] = "little"
237TARGET_POINTER_WIDTH[riscv32] = "32" 237TARGET_POINTER_WIDTH[riscv32gc] = "32"
238TARGET_C_INT_WIDTH[riscv32] = "32" 238TARGET_C_INT_WIDTH[riscv32gc] = "32"
239MAX_ATOMIC_WIDTH[riscv32] = "32" 239MAX_ATOMIC_WIDTH[riscv32gc] = "32"
240 240
241## riscv64-unknown-linux-{gnu, musl} 241## riscv64gc-unknown-linux-{gnu, musl}
242DATA_LAYOUT[riscv64] = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" 242DATA_LAYOUT[riscv64gc] = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
243TARGET_ENDIAN[riscv64] = "little" 243TARGET_ENDIAN[riscv64gc] = "little"
244TARGET_POINTER_WIDTH[riscv64] = "64" 244TARGET_POINTER_WIDTH[riscv64gc] = "64"
245TARGET_C_INT_WIDTH[riscv64] = "64" 245TARGET_C_INT_WIDTH[riscv64gc] = "64"
246MAX_ATOMIC_WIDTH[riscv64] = "64" 246MAX_ATOMIC_WIDTH[riscv64gc] = "64"
247 247
248# Convert a normal arch (HOST_ARCH, TARGET_ARCH, BUILD_ARCH, etc) to something 248# Convert a normal arch (HOST_ARCH, TARGET_ARCH, BUILD_ARCH, etc) to something
249# rust's internals won't choke on. 249# rust's internals won't choke on.
@@ -258,9 +258,21 @@ def arch_to_rust_target_arch(arch):
258 return "arm" 258 return "arm"
259 elif arch == "powerpc64le": 259 elif arch == "powerpc64le":
260 return "powerpc64" 260 return "powerpc64"
261 elif arch == "riscv32gc":
262 return "riscv32"
263 elif arch == "riscv64gc":
264 return "riscv64"
261 else: 265 else:
262 return arch 266 return arch
263 267
268# Convert a rust target string to a llvm-compatible triplet
269def rust_sys_to_llvm_target(sys):
270 if sys.startswith('riscv32gc-'):
271 return sys.replace('riscv32gc-', 'riscv32-', 1)
272 if sys.startswith('riscv64gc-'):
273 return sys.replace('riscv64gc-', 'riscv64-', 1)
274 return sys
275
264# generates our target CPU value 276# generates our target CPU value
265def llvm_cpu(d): 277def llvm_cpu(d):
266 cpu = d.getVar('PACKAGE_ARCH') 278 cpu = d.getVar('PACKAGE_ARCH')
@@ -334,7 +346,7 @@ def rust_gen_target(d, thing, wd, arch):
334 346
335 # build tspec 347 # build tspec
336 tspec = {} 348 tspec = {}
337 tspec['llvm-target'] = rustsys 349 tspec['llvm-target'] = rust_sys_to_llvm_target(rustsys)
338 tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi) 350 tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi)
339 if tspec['data-layout'] is None: 351 if tspec['data-layout'] is None:
340 bb.fatal("No rust target defined for %s" % arch_abi) 352 bb.fatal("No rust target defined for %s" % arch_abi)