summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-07-23 13:25:32 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-07-28 11:07:11 +0100
commit0f83d959465e0d99f98ade6803281585931d1b02 (patch)
tree32d982975f809dfaacf1dd371051e70139ab75cd /meta
parent5cb62d0a33777cb9afb1eea5f736a2580ce50dc7 (diff)
downloadopenembedded-core-contrib-0f83d959465e0d99f98ade6803281585931d1b02.tar.gz
rust-common/rust-cross: Clean up target json generation code
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 although ABIEXTENSION has to be excluded from the function signature, the triplet would normally cover anything set there. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/cargo/cargo-cross-canadian.inc4
-rw-r--r--meta/recipes-devtools/rust/rust-common.inc33
-rw-r--r--meta/recipes-devtools/rust/rust-cross-canadian-common.inc6
-rw-r--r--meta/recipes-devtools/rust/rust-cross.inc6
4 files changed, 24 insertions, 25 deletions
diff --git a/meta/recipes-devtools/cargo/cargo-cross-canadian.inc b/meta/recipes-devtools/cargo/cargo-cross-canadian.inc
index 01ba151d0a..d12267db3d 100644
--- a/meta/recipes-devtools/cargo/cargo-cross-canadian.inc
+++ b/meta/recipes-devtools/cargo/cargo-cross-canadian.inc
@@ -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 () {
diff --git a/meta/recipes-devtools/rust/rust-common.inc b/meta/recipes-devtools/rust/rust-common.inc
index d00b380dbd..2edc71e0d3 100644
--- a/meta/recipes-devtools/rust/rust-common.inc
+++ b/meta/recipes-devtools/rust/rust-common.inc
@@ -117,6 +117,7 @@ def llvm_features(d):
llvm_features_from_cc_arch(d) +
llvm_features_from_target_fpu(d))
+llvm_features[vardepvalue] = "${@llvm_features(d)}"
## arm-unknown-linux-gnueabihf
DATA_LAYOUT[arm-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
@@ -232,12 +233,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 +280,24 @@ def llvm_cpu(d):
except:
return trans.get(target, "generic")
-TARGET_LLVM_CPU="${@llvm_cpu(d)}"
-TARGET_LLVM_FEATURES = "${@llvm_features(d)}"
+llvm_cpu[vardepvalue] = "${@llvm_cpu(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))
+
+ abi = None
+ cpu = "generic"
+ features = ""
if thing == "TARGET":
abi = d.getVar('ABIEXTENSION')
+ cpu = llvm_cpu(d)
+ if bb.data.inherits_class('native', d):
+ features = ','.join(llvm_features_from_cc_arch(d))
+ else:
+ features = llvm_features(d) or ""
# arm and armv7 have different targets in llvm
if arch == "arm" and target_is_armv7(d):
arch = 'armv7'
@@ -355,14 +354,14 @@ def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""):
json.dump(tspec, f, indent=4)
# These are accounted for in tmpdir path names so don't need to be in the task sig
-rust_gen_target[vardepsexclude] += "RUST_HOST_SYS RUST_TARGET_SYS"
+rust_gen_target[vardepsexclude] += "RUST_HOST_SYS RUST_TARGET_SYS ABIEXTENSION llvm_cpu"
do_rust_gen_targets[vardeps] += "DATA_LAYOUT TARGET_ENDIAN TARGET_POINTER_WIDTH TARGET_C_INT_WIDTH MAX_ATOMIC_WIDTH FEATURES"
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
diff --git a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc b/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
index df4901f1fa..5c0644e92d 100644
--- a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
+++ b/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
@@ -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"
diff --git a/meta/recipes-devtools/rust/rust-cross.inc b/meta/recipes-devtools/rust/rust-cross.inc
index 2e47a3aa5f..719857ebbb 100644
--- a/meta/recipes-devtools/rust/rust-cross.inc
+++ b/meta/recipes-devtools/rust/rust-cross.inc
@@ -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