]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
rust-common/rust-cross: Clean up target json generation code rpurdie/debugsymbols
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 23 Jul 2022 12:25:32 +0000 (13:25 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 23 Jul 2022 12:25:35 +0000 (13:25 +0100)
Some of the subtleties in the different codepaths for target rust json generation
were not easy to spot. Start to simplfy the code to make this clearer.

This patch should not have any functionality change.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/cargo/cargo-cross-canadian.inc
meta/recipes-devtools/rust/rust-common.inc
meta/recipes-devtools/rust/rust-cross-canadian-common.inc
meta/recipes-devtools/rust/rust-cross.inc

index 01ba151d0a922f1c1abf5da1dc1ce8f9f60235f8..d12267db3d54080205cd911cd35d1cca11bf828c 100644 (file)
@@ -31,8 +31,8 @@ PN = "cargo-cross-canadian-${TRANSLATED_TARGET_ARCH}"
 python do_rust_gen_targets () {
     wd = d.getVar('WORKDIR') + '/targets/'
 
-    rust_gen_target(d, 'BUILD', wd, "", "generic", d.getVar('BUILD_ARCH'))
-    rust_gen_target(d, 'HOST', wd, "", "generic", d.getVar('HOST_ARCH'))
+    rust_gen_target(d, 'BUILD', wd, d.getVar('BUILD_ARCH'))
+    rust_gen_target(d, 'HOST', wd, d.getVar('HOST_ARCH'))
 }
 
 do_compile:prepend () {
index d00b380dbde72d89bf533ace796c602dbb538e90..be9d1a301bdd5fe64f3c0c675a827fc9ea38d119 100644 (file)
@@ -232,12 +232,6 @@ TARGET_POINTER_WIDTH[riscv64] = "64"
 TARGET_C_INT_WIDTH[riscv64] = "64"
 MAX_ATOMIC_WIDTH[riscv64] = "64"
 
-def sys_for(d, thing):
-    return d.getVar('{}_SYS'.format(thing))
-
-def prefix_for(d, thing):
-    return d.getVar('{}_PREFIX'.format(thing))
-
 # Convert a normal arch (HOST_ARCH, TARGET_ARCH, BUILD_ARCH, etc) to something
 # rust's internals won't choke on.
 def arch_to_rust_target_arch(arch):
@@ -285,20 +279,21 @@ def llvm_cpu(d):
     except:
         return trans.get(target, "generic")
 
-TARGET_LLVM_CPU="${@llvm_cpu(d)}"
-TARGET_LLVM_FEATURES = "${@llvm_features(d)}"
-
-# class-native implies TARGET=HOST, and TUNE_FEATURES only describes the real
-# (original) target.
-TARGET_LLVM_FEATURES:class-native = "${@','.join(llvm_features_from_cc_arch(d))}"
-
-def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""):
+def rust_gen_target(d, thing, wd, arch):
     import json
-    sys = sys_for(d, thing)
-    prefix = prefix_for(d, thing)
+    sys = d.getVar('{}_SYS'.format(thing))
+    prefix = d.getVar('{}_PREFIX'.format(thing))
+
+    cpu = "generic"
+    features = ""
 
     if thing == "TARGET":
         abi = d.getVar('ABIEXTENSION')
+        cpu = d.getVar('TARGET_LLVM_CPU')
+        if bb.data.inherits_class('native', d):
+            features = ','.join(llvm_features_from_cc_arch(d))
+        else:
+            features = d.getVar('TARGET_LLVM_FEATURES') or ""
         # arm and armv7 have different targets in llvm
         if arch == "arm" and target_is_armv7(d):
             arch = 'armv7'
@@ -362,7 +357,7 @@ do_rust_gen_targets[vardeps] += "DATA_LAYOUT TARGET_ENDIAN TARGET_POINTER_WIDTH
 python do_rust_gen_targets () {
     wd = d.getVar('WORKDIR') + '/targets/'
     build_arch = d.getVar('BUILD_ARCH')
-    rust_gen_target(d, 'BUILD', wd, "", "generic", build_arch)
+    rust_gen_target(d, 'BUILD', wd, build_arch)
 }
 
 addtask rust_gen_targets after do_patch before do_compile
index df4901f1face76f906c4ff24643dfe44946d7995..5c0644e92d78b7d969409b6ac5a48a9f0ff1a2d7 100644 (file)
@@ -28,9 +28,9 @@ DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDP
 python do_rust_gen_targets () {
     wd = d.getVar('WORKDIR') + '/targets/'
     # Order of BUILD, HOST, TARGET is important in case the files overwrite, most specific last
-    rust_gen_target(d, 'BUILD', wd, "", "generic", d.getVar('BUILD_ARCH'))
-    rust_gen_target(d, 'HOST', wd, "", "generic", d.getVar('HOST_ARCH'))
-    rust_gen_target(d, 'TARGET', wd, d.getVar('TARGET_LLVM_FEATURES') or "", d.getVar('TARGET_LLVM_CPU'), d.getVar('TARGET_ARCH'))
+    rust_gen_target(d, 'BUILD', wd, d.getVar('BUILD_ARCH'))
+    rust_gen_target(d, 'HOST', wd, d.getVar('HOST_ARCH'))
+    rust_gen_target(d, 'TARGET', wd, d.getVar('TARGET_ARCH'))
 }
 
 INHIBIT_DEFAULT_RUST_DEPS = "1"
index 2e47a3aa5f34e1965b8b084f7dcf6ceb502ab6c2..719857ebbb3a9a4cc5b4db1b66374c55b09617ef 100644 (file)
@@ -1,9 +1,9 @@
 python do_rust_gen_targets () {
     wd = d.getVar('WORKDIR') + '/targets/'
     # Order of BUILD, HOST, TARGET is important in case the files overwrite, most specific last
-    rust_gen_target(d, 'BUILD', wd, "", "generic", d.getVar('BUILD_ARCH'))
-    rust_gen_target(d, 'HOST', wd, "", "generic", d.getVar('HOST_ARCH'))
-    rust_gen_target(d, 'TARGET', wd, d.getVar('TARGET_LLVM_FEATURES') or "", d.getVar('TARGET_LLVM_CPU'), d.getVar('TARGET_ARCH'))
+    rust_gen_target(d, 'BUILD', wd, d.getVar('BUILD_ARCH'))
+    rust_gen_target(d, 'HOST', wd, d.getVar('HOST_ARCH'))
+    rust_gen_target(d, 'TARGET', wd, d.getVar('TARGET_ARCH'))
 }
 
 # Otherwise we'll depend on what we provide