]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
clang: improve LLVM target selection logic
authorRoss Burton <ross.burton@arm.com>
Mon, 21 Jul 2025 13:24:24 +0000 (14:24 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 21 Jul 2025 21:59:39 +0000 (22:59 +0100)
The GPU targets are incredibly slow to build, so if the DISTRO_FEATURES
doesn't include opengl or vulkan assume that the user will not be using
a GPU and disable them.

Alternatively, a distribution could state that they'll only be using
one of the backends, and set LLVM_TARGETS_GPU explicitly.

On my build machine, disabling the GPU targets reduces the build time of
clang-native from 21m to 16m.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/clang/clang_git.bb

index a85626c45abc478b7097799576f5d3c6ffdd0496..484f065a554d439495d84c4f8ccfe7c7ce054230 100644 (file)
@@ -112,16 +112,18 @@ CLANG_DEFAULT_CXX_STDLIB;CLANG_DEFAULT_RTLIB;CLANG_DEFAULT_UNWINDLIB;\
 CLANG_DEFAULT_OPENMP_RUNTIME;LLVM_ENABLE_PER_TARGET_RUNTIME_DIR;\
 LLVM_BUILD_TOOLS;LLVM_USE_HOST_TOOLS;LLVM_CONFIG_PATH;LLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR;\
 "
+
+# By default we build all the supported CPU architectures, and the GPU targets
+# if the opengl or vulkan DISTRO_FEATURES are enabled.
+#
+# For target builds we default to building that specific architecture, BPF, and the GPU targets if required.
 #
-# Default to build all OE-Core supported target arches (user overridable).
-# Gennerally setting LLVM_TARGETS_TO_BUILD = "" in local.conf is ok in most simple situations
-# where only one target architecture is needed along with just one build arch (usually X86)
-# Core tier targets:
-# AArch64;AMDGPU;ARM;AVR;BPF;Hexagon;Lanai;LoongArch;Mips;MSP430;NVPTX;PowerPC;RISCV;Sparc;SPIRV;SystemZ;VE;WebAssembly;X86;XCore
-# Known experimental targets: ARC;CSKY;DirectX;M68k;Xtensa
-
-LLVM_TARGETS_TO_BUILD ?= "AMDGPU;AArch64;ARM;BPF;Mips;PowerPC;RISCV;X86;LoongArch;NVPTX;SPIRV"
-LLVM_TARGETS_TO_BUILD:class-target ?= "${@get_clang_host_arch(bb, d)};AMDGPU;BPF;NVPTX;SPIRV"
+# The available target list can be seen in the source code
+# in the LLVM_ALL_TARGETS assignment:
+# https://github.com/llvm/llvm-project/blob/main/llvm/CMakeLists.txt
+LLVM_TARGETS_GPU ?= "${@bb.utils.contains_any('DISTRO_FEATURES', 'opengl vulkan', 'AMDGPU;NVPTX;SPIRV', '', d)}"
+LLVM_TARGETS_TO_BUILD ?= "AArch64;ARM;BPF;Mips;PowerPC;RISCV;X86;LoongArch;${LLVM_TARGETS_GPU}"
+LLVM_TARGETS_TO_BUILD:class-target ?= "${@get_clang_host_arch(bb, d)};BPF;${LLVM_TARGETS_GPU}"
 
 LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ?= ""