]> code.ossystems Code Review - openembedded-core.git/commitdiff
rust: Introduce arch_to_rust_arch()
authorAndrew Jeffery <andrew@aj.id.au>
Mon, 28 Feb 2022 14:39:46 +0000 (01:09 +1030)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 2 Mar 2022 18:44:08 +0000 (18:44 +0000)
On modern Power systems `uname -m` yields 'ppc64le' while the toolchain
knows the architecture as 'powerpc64le'. Provide a mapping from one to
the other to integrate with the existing architecture configuration
flags.

arch_to_rust_arch() only exists to map the OE *_ARCH variables before
any further processing, unlike arch_to_rust_target_arch() which is
specific to the internal triple handling of rust.

On Linux ppc64le systems the changes give the following config:

```
$ cat ./tmp/work/ppc64le-linux/rust-native/1.58.0-r0/targets/ppc64le-linux.json
{
    "llvm-target": "powerpc64le-unknown-linux-gnu",
    "data-layout": "e-m:e-i64:64-n32:64-v256:256:256-v512:512:512",
    "max-atomic-width": 64,
    "target-pointer-width": "64",
    "target-c-int-width": "64",
    "target-endian": "little",
    "arch": "powerpc64",
    "os": "linux",
    "env": "gnu",
    "vendor": "unknown",
    "target-family": "unix",
    "linker": "gcc",
    "cpu": "generic",
    "dynamic-linking": true,
    "executables": true,
    "linker-is-gnu": true,
    "linker-flavor": "gcc",
    "has-rpath": true,
    "has-elf-tls": true,
    "position-independent-executables": true,
    "panic-strategy": "unwind"
}
```

Change-Id: Ief0c01189185d7d4da31d307270bec4e1de674ca
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/base.bbclass
meta/classes/rust-common.bbclass
meta/lib/oe/rust.py [new file with mode: 0644]
meta/recipes-devtools/rust/rust-common.inc

index 966eadad67a5b3fbe395c60441dd7adf9a725a7f..b7869da3b38f8a5cbdb355930b71fac0613225b4 100644 (file)
@@ -12,7 +12,7 @@ inherit logging
 
 OE_EXTRA_IMPORTS ?= ""
 
-OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license oe.qa oe.reproducible ${OE_EXTRA_IMPORTS}"
+OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license oe.qa oe.reproducible oe.rust ${OE_EXTRA_IMPORTS}"
 OE_IMPORTS[type] = "list"
 
 PACKAGECONFIG_CONFARGS ??= ""
index 98d65970e8c077c7aa23543b99abbd191f1dd629..8cfe864ca3fd3d78b112ce522b3ddb456ee7b07d 100644 (file)
@@ -65,7 +65,7 @@ def rust_base_triple(d, thing):
     if thing == "TARGET" and target_is_armv7(d):
         arch = "armv7"
     else:
-        arch = d.getVar('{}_ARCH'.format(thing))
+        arch = oe.rust.arch_to_rust_arch(d.getVar('{}_ARCH'.format(thing)))
 
     # All the Yocto targets are Linux and are 'unknown'
     vendor = "-unknown"
diff --git a/meta/lib/oe/rust.py b/meta/lib/oe/rust.py
new file mode 100644 (file)
index 0000000..ec70b34
--- /dev/null
@@ -0,0 +1,5 @@
+# Handle mismatches between `uname -m`-style output and Rust's arch names
+def arch_to_rust_arch(arch):
+    if arch == "ppc64le":
+        return "powerpc64le"
+    return arch
index ceeee9786376b3356d22031c43b6f0e2cf4ae907..310aecef226e94f6146d7944347114e0d943b931 100644 (file)
@@ -313,10 +313,12 @@ def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""):
     sys = sys_for(d, thing)
     prefix = prefix_for(d, thing)
 
+    rust_arch = oe.rust.arch_to_rust_arch(arch)
+
     if abi:
-        arch_abi = "{}-{}".format(arch, abi)
+        arch_abi = "{}-{}".format(rust_arch, abi)
     else:
-        arch_abi = arch
+        arch_abi = rust_arch
 
     features = features or d.getVarFlag('FEATURES', arch_abi) or ""
     features = features.strip()
@@ -329,7 +331,7 @@ def rust_gen_target(d, thing, wd, features, cpu, 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['arch'] = arch_to_rust_target_arch(rust_arch)
     tspec['os'] = "linux"
     if "musl" in tspec['llvm-target']:
         tspec['env'] = "musl"