summaryrefslogtreecommitdiffstats
path: root/meta
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-11-09 17:42:14 +0000
commit7b401c7540265fb1e6e791a0531475881d08822d (patch)
tree0a3d63800638a9ec56f424e845db7e165eefdcbe /meta
parent62c4b68a118cc2188ff18d7bede25670fa398ff3 (diff)
downloadpoky-7b401c7540265fb1e6e791a0531475881d08822d.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: 2daa8d76369cd06e5c357e393e3145e08f3d6760) 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> (cherry picked from commit 1cfb9c8a59d98ccc9b0510cd28fb933f72fb6b6c) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes-recipe/rust-target-config.bbclass40
-rw-r--r--meta/lib/oe/rust.py2
2 files changed, 28 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)
diff --git a/meta/lib/oe/rust.py b/meta/lib/oe/rust.py
index 1dc9cf150d..185553eeeb 100644
--- a/meta/lib/oe/rust.py
+++ b/meta/lib/oe/rust.py
@@ -8,4 +8,6 @@
8def arch_to_rust_arch(arch): 8def arch_to_rust_arch(arch):
9 if arch == "ppc64le": 9 if arch == "ppc64le":
10 return "powerpc64le" 10 return "powerpc64le"
11 if arch in ('riscv32', 'riscv64'):
12 return arch + 'gc'
11 return arch 13 return arch