]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
clang: move get_clang_arch() functions to the common inc file
authorRoss Burton <ross.burton@arm.com>
Thu, 24 Jul 2025 18:38:48 +0000 (19:38 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 28 Jul 2025 16:35:16 +0000 (17:35 +0100)
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.

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>
meta/recipes-devtools/clang/clang_git.bb
meta/recipes-devtools/clang/common-clang.inc

index 830c0282cd67d40119f33fb41a5ccbe32d4c49b0..35b40d0ed18999610f540fb64c55a2a79dbff7fb 100644 (file)
@@ -30,29 +30,6 @@ inherit cmake pkgconfig python3native python3targetconfig multilib_header
 
 OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH"
 
-def get_clang_arch(bb, d, arch_var):
-    import re
-    a = d.getVar(arch_var)
-    if   re.match('(i.86|athlon|x86.64)$', a):         return 'X86'
-    elif re.match('arm$', a):                          return 'ARM'
-    elif re.match('armeb$', a):                        return 'ARM'
-    elif re.match('aarch64$', a):                      return 'AArch64'
-    elif re.match('aarch64_be$', a):                   return 'AArch64'
-    elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
-    elif re.match('riscv32$', a):                      return 'RISCV'
-    elif re.match('riscv64$', a):                      return 'RISCV'
-    elif re.match('p(pc|owerpc)(|64)', a):             return 'PowerPC'
-    elif re.match('loongarch64$', a):                  return 'LoongArch'
-    else:
-        bb.note("'%s' is not a primary llvm architecture" % a)
-    return ""
-
-def get_clang_host_arch(bb, d):
-    return get_clang_arch(bb, d, 'HOST_ARCH')
-
-def get_clang_target_arch(bb, d):
-    return get_clang_arch(bb, d, 'TARGET_ARCH')
-
 PACKAGECONFIG_CLANG_COMMON = "build-id eh libedit rtti shared-libs libclang-python \
                               ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', 'lld', '', d)} \
                               ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcplusplus libomp unwindlib', '', d)} \
index b8f37daea244ab36388bd3a83f63826bf131aeb1..6ac53125f0937b8de0b5ef5ff4fc4addd796ee7f 100644 (file)
@@ -21,4 +21,27 @@ LLVM_LIBDIR_SUFFIX = "${@d.getVar('baselib').replace('lib', '')}"
 # set the default pigz thread
 export PIGZ = "-p ${@oe.utils.cpu_count(at_least=2)}"
 
+def get_clang_arch(bb, d, arch_var):
+    import re
+    a = d.getVar(arch_var)
+    if   re.match('(i.86|athlon|x86.64)$', a):         return 'X86'
+    elif re.match('arm$', a):                          return 'ARM'
+    elif re.match('armeb$', a):                        return 'ARM'
+    elif re.match('aarch64$', a):                      return 'AArch64'
+    elif re.match('aarch64_be$', a):                   return 'AArch64'
+    elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
+    elif re.match('riscv32$', a):                      return 'RISCV'
+    elif re.match('riscv64$', a):                      return 'RISCV'
+    elif re.match('p(pc|owerpc)(|64)', a):             return 'PowerPC'
+    elif re.match('loongarch64$', a):                  return 'LoongArch'
+    else:
+        bb.fatal("Unhandled architecture %s" % arch_val)
+        return ""
+
+def get_clang_host_arch(bb, d):
+    return get_clang_arch(bb, d, 'HOST_ARCH')
+
+def get_clang_target_arch(bb, d):
+    return get_clang_arch(bb, d, 'TARGET_ARCH')
+
 require common.inc