summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2025-07-24 19:38:48 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-07-28 17:37:02 +0100
commit0747e2d25f220ec18ecc0e81dabc250a4ceb475c (patch)
treed131f793cccdc4a50ba922c05e0e2281e9d3ae1b
parent831a22fa5a60b09229d90361d2215b190fbc575c (diff)
downloadpoky-0747e2d25f220ec18ecc0e81dabc250a4ceb475c.tar.gz
clang: move get_clang_arch() functions to the common inc file
These functions are useful outside of just the clang recipe, so move them to a common .inc file so they can be used by other clang-related recipes. Also make the function fail if it doesn't recognise the architecture, instead of returning the empty string and causing mysterious fails later. (From OE-Core rev: 1d5298533e97dab7636f885ddd740352782395b0) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/clang/clang_git.bb23
-rw-r--r--meta/recipes-devtools/clang/common-clang.inc23
2 files changed, 23 insertions, 23 deletions
diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb
index 830c0282cd..35b40d0ed1 100644
--- a/meta/recipes-devtools/clang/clang_git.bb
+++ b/meta/recipes-devtools/clang/clang_git.bb
@@ -30,29 +30,6 @@ inherit cmake pkgconfig python3native python3targetconfig multilib_header
30 30
31OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH" 31OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH"
32 32
33def get_clang_arch(bb, d, arch_var):
34 import re
35 a = d.getVar(arch_var)
36 if re.match('(i.86|athlon|x86.64)$', a): return 'X86'
37 elif re.match('arm$', a): return 'ARM'
38 elif re.match('armeb$', a): return 'ARM'
39 elif re.match('aarch64$', a): return 'AArch64'
40 elif re.match('aarch64_be$', a): return 'AArch64'
41 elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
42 elif re.match('riscv32$', a): return 'RISCV'
43 elif re.match('riscv64$', a): return 'RISCV'
44 elif re.match('p(pc|owerpc)(|64)', a): return 'PowerPC'
45 elif re.match('loongarch64$', a): return 'LoongArch'
46 else:
47 bb.note("'%s' is not a primary llvm architecture" % a)
48 return ""
49
50def get_clang_host_arch(bb, d):
51 return get_clang_arch(bb, d, 'HOST_ARCH')
52
53def get_clang_target_arch(bb, d):
54 return get_clang_arch(bb, d, 'TARGET_ARCH')
55
56PACKAGECONFIG_CLANG_COMMON = "build-id eh libedit rtti shared-libs libclang-python \ 33PACKAGECONFIG_CLANG_COMMON = "build-id eh libedit rtti shared-libs libclang-python \
57 ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', 'lld', '', d)} \ 34 ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', 'lld', '', d)} \
58 ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcplusplus libomp unwindlib', '', d)} \ 35 ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcplusplus libomp unwindlib', '', d)} \
diff --git a/meta/recipes-devtools/clang/common-clang.inc b/meta/recipes-devtools/clang/common-clang.inc
index b8f37daea2..6ac53125f0 100644
--- a/meta/recipes-devtools/clang/common-clang.inc
+++ b/meta/recipes-devtools/clang/common-clang.inc
@@ -21,4 +21,27 @@ LLVM_LIBDIR_SUFFIX = "${@d.getVar('baselib').replace('lib', '')}"
21# set the default pigz thread 21# set the default pigz thread
22export PIGZ = "-p ${@oe.utils.cpu_count(at_least=2)}" 22export PIGZ = "-p ${@oe.utils.cpu_count(at_least=2)}"
23 23
24def get_clang_arch(bb, d, arch_var):
25 import re
26 a = d.getVar(arch_var)
27 if re.match('(i.86|athlon|x86.64)$', a): return 'X86'
28 elif re.match('arm$', a): return 'ARM'
29 elif re.match('armeb$', a): return 'ARM'
30 elif re.match('aarch64$', a): return 'AArch64'
31 elif re.match('aarch64_be$', a): return 'AArch64'
32 elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
33 elif re.match('riscv32$', a): return 'RISCV'
34 elif re.match('riscv64$', a): return 'RISCV'
35 elif re.match('p(pc|owerpc)(|64)', a): return 'PowerPC'
36 elif re.match('loongarch64$', a): return 'LoongArch'
37 else:
38 bb.fatal("Unhandled architecture %s" % arch_val)
39 return ""
40
41def get_clang_host_arch(bb, d):
42 return get_clang_arch(bb, d, 'HOST_ARCH')
43
44def get_clang_target_arch(bb, d):
45 return get_clang_arch(bb, d, 'TARGET_ARCH')
46
24require common.inc 47require common.inc