summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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