From 4ed32e53f21afc8b4a3a005c357357c090833778 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Thu, 7 Apr 2016 09:31:59 -0500 Subject: [PATCH] rust: generate an appropriate cpu for targets This generates an appropriate CPU value for the targets. For ARM it leaves the default of 'generic' since we build up all the different CPU differences in the 'features' field but for x86/x86_64 we need to pass an appropriate CPU value. Signed-off-by: Doug Goldstein --- recipes-devtools/rust/rust.inc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/recipes-devtools/rust/rust.inc b/recipes-devtools/rust/rust.inc index 3b25a70..c1a1f01 100644 --- a/recipes-devtools/rust/rust.inc +++ b/recipes-devtools/rust/rust.inc @@ -167,6 +167,23 @@ def arch_to_rust_target_arch(arch): else: return arch +# generates our target CPU value +def llvm_cpu(d): + cpu = d.getVar('TUNE_PKGARCH', True) + target = d.getVar('TRANSLATED_TARGET_ARCH', True) + + trans = {} + trans['corei7-64'] = "corei7" + trans['core2-32'] = "core2" + trans['x86-64'] = "x86-64" + trans['i686'] = "i686" + trans['i586'] = "i586" + + try: + return trans[cpu] + except: + return trans.get(target, "generic") + def post_link_args_for(d, thing, arch): post_link_args = (d.getVar('{}_POST_LINK_ARGS'.format(thing), True) or "").split() post_link_args.extend((d.getVarFlag('POST_LINK_ARGS', arch, True) or "").split()) @@ -182,11 +199,14 @@ def ldflags_for(d, thing, arch): a.extend(post_link_args_for(d, thing, arch)) return a +TARGET_LLVM_CPU="${@llvm_cpu(d)}" TARGET_LLVM_FEATURES = "${@llvm_features_from_tune(d)}" +TARGET_LLVM_CPU_class-cross="${@llvm_cpu(d)}" TARGET_LLVM_FEATURES_class-cross = "${@llvm_features_from_tune(d)}" # class-native implies TARGET=HOST, and TUNE_FEATURES only describes the real # (original) target. +TARGET_LLVM_CPU="${@llvm_cpu(d)}" TARGET_LLVM_FEATURES_class-native = "" def rust_gen_target(d, thing, wd): @@ -211,6 +231,7 @@ def rust_gen_target(d, thing, wd): tspec['env'] = "gnu" tspec['linker'] = "{}{}gcc".format(d.getVar('CCACHE', True), prefix) tspec['objcopy'] = "{}objcopy".format(prefix) + tspec['cpu'] = d.getVar('TARGET_LLVM_CPU', True) if features is not "": tspec['features'] = features tspec['dynamic-linking'] = True