diff options
author | Ross Burton <ross.burton@arm.com> | 2025-07-21 14:24:23 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-07-21 23:00:18 +0100 |
commit | 56e1ae0ccf8b5e206e0721c4dc22bd1e701966a9 (patch) | |
tree | 8190fb71827fcae199dd4d2cbb4c7441f82c6389 | |
parent | 208693b05c1032c412f7e4041cadf87a48e04821 (diff) | |
download | poky-56e1ae0ccf8b5e206e0721c4dc22bd1e701966a9.tar.gz |
libclc: split out of clang
Split the libclc subproject out of the clang recipe and into a dedicated
libclc recipe.
This is useful because libclc is the OpenCL runtime library and as such
isn't target-specific and needs a native clang to build, not a target
libllvm.
Verified that nothing is dropped by adding clang and libclc to an image
and verifying that the file list is the same before and after this
change.
We need to patch the libclc CMakeLists to allow it to use an out-of-tree
prepare_builtins binary, discussion is ongoing with upstream to resolve
this properly.
(From OE-Core rev: 33a8742a1280b4c6779a7aa487c2dd4a713babe6)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
5 files changed, 108 insertions, 11 deletions
diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc index 6bfc2efb16..927aac16d6 100644 --- a/meta/conf/distro/include/maintainers.inc +++ b/meta/conf/distro/include/maintainers.inc | |||
@@ -328,6 +328,7 @@ RECIPE_MAINTAINER:pn-libcap-ng = "Yi Zhao <yi.zhao@windriver.com>" | |||
328 | RECIPE_MAINTAINER:pn-libcap-ng-python = "Yi Zhao <yi.zhao@windriver.com>" | 328 | RECIPE_MAINTAINER:pn-libcap-ng-python = "Yi Zhao <yi.zhao@windriver.com>" |
329 | RECIPE_MAINTAINER:pn-libcgroup = "Unassigned <unassigned@yoctoproject.org>" | 329 | RECIPE_MAINTAINER:pn-libcgroup = "Unassigned <unassigned@yoctoproject.org>" |
330 | RECIPE_MAINTAINER:pn-libcheck = "Yi Zhao <yi.zhao@windriver.com>" | 330 | RECIPE_MAINTAINER:pn-libcheck = "Yi Zhao <yi.zhao@windriver.com>" |
331 | RECIPE_MAINTAINER:pn-libclc = "Khem Raj <raj.khem@gmail.com>" | ||
331 | RECIPE_MAINTAINER:pn-libcomps = "Unassigned <unassigned@yoctoproject.org>" | 332 | RECIPE_MAINTAINER:pn-libcomps = "Unassigned <unassigned@yoctoproject.org>" |
332 | RECIPE_MAINTAINER:pn-libconvert-asn1-perl = "Tim Orling <tim.orling@konsulko.com>" | 333 | RECIPE_MAINTAINER:pn-libconvert-asn1-perl = "Tim Orling <tim.orling@konsulko.com>" |
333 | RECIPE_MAINTAINER:pn-libcxx = "Khem Raj <raj.khem@gmail.com>" | 334 | RECIPE_MAINTAINER:pn-libcxx = "Khem Raj <raj.khem@gmail.com>" |
diff --git a/meta/recipes-devtools/clang/clang/0001-libclc-allow-existing-prepare-builtins-in-standalone.patch b/meta/recipes-devtools/clang/clang/0001-libclc-allow-existing-prepare-builtins-in-standalone.patch new file mode 100644 index 0000000000..46929798ad --- /dev/null +++ b/meta/recipes-devtools/clang/clang/0001-libclc-allow-existing-prepare-builtins-in-standalone.patch | |||
@@ -0,0 +1,57 @@ | |||
1 | From 348f846b206780646430d6477c04b7793b669f34 Mon Sep 17 00:00:00 2001 | ||
2 | From: Ross Burton <ross.burton@arm.com> | ||
3 | Date: Wed, 16 Jul 2025 23:24:21 +0100 | ||
4 | Subject: [PATCH] allow external prepare_builtins | ||
5 | |||
6 | In standalone cross builds, libclc can't build a native prepare_builtins. | ||
7 | |||
8 | Hack the CMake to allow it to use an existing binary, which we build in the recipe. | ||
9 | |||
10 | Upstream-Status: Inappropriate [discussion for a proper fix in https://github.com/llvm/llvm-project/issues/149814] | ||
11 | Signed-off-by: Ross Burton <ross.burton@arm.com> | ||
12 | --- | ||
13 | libclc/CMakeLists.txt | 23 +++++++++++++++++------ | ||
14 | 1 file changed, 17 insertions(+), 6 deletions(-) | ||
15 | |||
16 | diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt | ||
17 | index 43e213b385f5..d4a6d096169e 100644 | ||
18 | --- a/libclc/CMakeLists.txt | ||
19 | +++ b/libclc/CMakeLists.txt | ||
20 | @@ -181,17 +181,28 @@ set(LLVM_LINK_COMPONENTS | ||
21 | IRReader | ||
22 | Support | ||
23 | ) | ||
24 | + | ||
25 | if( LIBCLC_STANDALONE_BUILD ) | ||
26 | - add_llvm_executable( prepare_builtins utils/prepare-builtins.cpp ) | ||
27 | - set( prepare_builtins_exe prepare_builtins ) | ||
28 | - set( prepare_builtins_target prepare_builtins ) | ||
29 | + message("cross ${CMAKE_CROSSCOMPILING}") | ||
30 | + if(CMAKE_CROSSCOMPILING) | ||
31 | + find_program(PREPARE_BUILTINS prepare_builtins REQUIRED) | ||
32 | + message("found ${PREPARE_BUILTINS}") | ||
33 | + set( prepare_builtins_exe ${PREPARE_BUILTINS} ) | ||
34 | + else() | ||
35 | + add_llvm_executable( prepare_builtins utils/prepare-builtins.cpp ) | ||
36 | + set( prepare_builtins_exe prepare_builtins ) | ||
37 | + set( prepare_builtins_target prepare_builtins ) | ||
38 | + target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} ) | ||
39 | + # These were not properly reported in early LLVM and we don't need them | ||
40 | + target_compile_options( prepare_builtins PRIVATE -fno-rtti -fno-exceptions ) | ||
41 | + endif() | ||
42 | else() | ||
43 | add_llvm_utility( prepare_builtins utils/prepare-builtins.cpp ) | ||
44 | setup_host_tool( prepare_builtins PREPARE_BUILTINS prepare_builtins_exe prepare_builtins_target ) | ||
45 | + target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} ) | ||
46 | + # These were not properly reported in early LLVM and we don't need them | ||
47 | + target_compile_options( prepare_builtins PRIVATE -fno-rtti -fno-exceptions ) | ||
48 | endif() | ||
49 | -target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} ) | ||
50 | -# These were not properly reported in early LLVM and we don't need them | ||
51 | -target_compile_options( prepare_builtins PRIVATE -fno-rtti -fno-exceptions ) | ||
52 | |||
53 | # Setup arch devices | ||
54 | set( r600--_devices cedar cypress barts cayman ) | ||
55 | -- | ||
56 | 2.43.0 | ||
57 | |||
diff --git a/meta/recipes-devtools/clang/clang_git.bb b/meta/recipes-devtools/clang/clang_git.bb index 1210ca92de..a85626c45a 100644 --- a/meta/recipes-devtools/clang/clang_git.bb +++ b/meta/recipes-devtools/clang/clang_git.bb | |||
@@ -131,7 +131,7 @@ HF[vardepvalue] = "${HF}" | |||
131 | 131 | ||
132 | # Ensure that LLVM_PROJECTS does not contain compiler runtime components e.g. libcxx etc | 132 | # Ensure that LLVM_PROJECTS does not contain compiler runtime components e.g. libcxx etc |
133 | # they are enabled via LLVM_ENABLE_RUNTIMES | 133 | # they are enabled via LLVM_ENABLE_RUNTIMES |
134 | LLVM_PROJECTS ?= "clang;clang-tools-extra;libclc;lld" | 134 | LLVM_PROJECTS ?= "clang;clang-tools-extra;lld" |
135 | 135 | ||
136 | # linux hosts (.so) on Windows .pyd | 136 | # linux hosts (.so) on Windows .pyd |
137 | SOLIBSDEV:mingw32 = ".pyd" | 137 | SOLIBSDEV:mingw32 = ".pyd" |
@@ -192,7 +192,7 @@ EXTRA_OECMAKE:append:class-target = "\ | |||
192 | 192 | ||
193 | DEPENDS = "binutils zlib zstd libffi libxml2 libxml2-native ninja-native swig-native spirv-tools-native llvm-tblgen-native" | 193 | DEPENDS = "binutils zlib zstd libffi libxml2 libxml2-native ninja-native swig-native spirv-tools-native llvm-tblgen-native" |
194 | DEPENDS:append:class-nativesdk = " clang-crosssdk-${SDK_SYS} virtual/nativesdk-cross-binutils nativesdk-python3" | 194 | DEPENDS:append:class-nativesdk = " clang-crosssdk-${SDK_SYS} virtual/nativesdk-cross-binutils nativesdk-python3" |
195 | DEPENDS:append:class-target = " clang-cross-${TARGET_ARCH} python3 ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcxx', '', d)} spirv-llvm-translator-native" | 195 | DEPENDS:append:class-target = " clang-cross-${TARGET_ARCH} python3 ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcxx', '', d)}" |
196 | 196 | ||
197 | RRECOMMENDS:${PN} = "binutils" | 197 | RRECOMMENDS:${PN} = "binutils" |
198 | RRECOMMENDS:${PN}:append:class-target = "${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', ' libcxx-dev', '', d)}" | 198 | RRECOMMENDS:${PN}:append:class-target = "${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', ' libcxx-dev', '', d)}" |
@@ -259,7 +259,6 @@ do_install:append:class-native () { | |||
259 | install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clangd-indexer ${D}${bindir}/clangd-indexer | 259 | install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clangd-indexer ${D}${bindir}/clangd-indexer |
260 | fi | 260 | fi |
261 | install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen | 261 | install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen |
262 | install -Dm 0755 ${B}${BINPATHPREFIX}/bin/prepare_builtins ${D}${bindir}/prepare_builtins | ||
263 | 262 | ||
264 | for f in `find ${D}${bindir} -executable -type f -not -type l`; do | 263 | for f in `find ${D}${bindir} -executable -type f -not -type l`; do |
265 | test -n "`file -b $f|grep -i ELF`" && ${STRIP} $f | 264 | test -n "`file -b $f|grep -i ELF`" && ${STRIP} $f |
@@ -295,11 +294,11 @@ do_install:append:class-nativesdk () { | |||
295 | fi | 294 | fi |
296 | } | 295 | } |
297 | 296 | ||
298 | PROVIDES:append:class-native = " llvm-native libclc-native" | 297 | PROVIDES:append:class-native = " llvm-native" |
299 | PROVIDES:append:class-target = " llvm libclc" | 298 | PROVIDES:append:class-target = " llvm" |
300 | PROVIDES:append:class-nativesdk = " nativesdk-llvm nativesdk-libclc" | 299 | PROVIDES:append:class-nativesdk = " nativesdk-llvm" |
301 | 300 | ||
302 | PACKAGES =+ "${PN}-libllvm ${PN}-libclang-python ${PN}-libclang-cpp ${PN}-tidy ${PN}-format ${PN}-tools ${PN}-clc \ | 301 | PACKAGES =+ "${PN}-libllvm ${PN}-libclang-python ${PN}-libclang-cpp ${PN}-tidy ${PN}-format ${PN}-tools \ |
303 | libclang llvm-linker-tools" | 302 | libclang llvm-linker-tools" |
304 | 303 | ||
305 | BBCLASSEXTEND = "native nativesdk" | 304 | BBCLASSEXTEND = "native nativesdk" |
@@ -316,8 +315,6 @@ RDEPENDS:${PN}-tools += "\ | |||
316 | perl-module-term-ansicolor \ | 315 | perl-module-term-ansicolor \ |
317 | " | 316 | " |
318 | 317 | ||
319 | RPROVIDES:${PN}-clc = "${MLPREFIX}libclc" | ||
320 | |||
321 | RRECOMMENDS:${PN}-tidy += "${PN}-tools" | 318 | RRECOMMENDS:${PN}-tidy += "${PN}-tools" |
322 | 319 | ||
323 | FILES:llvm-linker-tools = "${libdir}/LLVMgold* ${libdir}/libLTO.so.* ${libdir}/LLVMPolly*" | 320 | FILES:llvm-linker-tools = "${libdir}/LLVMgold* ${libdir}/libLTO.so.* ${libdir}/LLVMPolly*" |
@@ -384,8 +381,6 @@ FILES:${PN} += "\ | |||
384 | ${nonarch_libdir}/${BPN}/*/include/ \ | 381 | ${nonarch_libdir}/${BPN}/*/include/ \ |
385 | " | 382 | " |
386 | 383 | ||
387 | FILES:${PN}-clc += "${datadir}/clc" | ||
388 | |||
389 | FILES:${PN}-libllvm =+ "\ | 384 | FILES:${PN}-libllvm =+ "\ |
390 | ${libdir}/libLLVM.so.${MAJOR_VER}.${MINOR_VER} \ | 385 | ${libdir}/libLLVM.so.${MAJOR_VER}.${MINOR_VER} \ |
391 | ${libdir}/libLLVM-${MAJOR_VER}.so \ | 386 | ${libdir}/libLLVM-${MAJOR_VER}.so \ |
diff --git a/meta/recipes-devtools/clang/common.inc b/meta/recipes-devtools/clang/common.inc index d66f9059b2..d6280c2fbe 100644 --- a/meta/recipes-devtools/clang/common.inc +++ b/meta/recipes-devtools/clang/common.inc | |||
@@ -59,6 +59,7 @@ SRC_URI = "\ | |||
59 | file://0036-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch \ | 59 | file://0036-libunwind-Use-gcs-instead-of-gcs-target-attribute.patch \ |
60 | file://0037-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch \ | 60 | file://0037-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch \ |
61 | file://0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch \ | 61 | file://0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch \ |
62 | file://0001-libclc-allow-existing-prepare-builtins-in-standalone.patch \ | ||
62 | " | 63 | " |
63 | # Fallback to no-PIE if not set | 64 | # Fallback to no-PIE if not set |
64 | GCCPIE ??= "" | 65 | GCCPIE ??= "" |
diff --git a/meta/recipes-devtools/clang/libclc_git.bb b/meta/recipes-devtools/clang/libclc_git.bb new file mode 100644 index 0000000000..ed31de503a --- /dev/null +++ b/meta/recipes-devtools/clang/libclc_git.bb | |||
@@ -0,0 +1,43 @@ | |||
1 | SUMMARY = "Implementation of the library requirements of the OpenCL C programming language." | ||
2 | HOMEPAGE = "https://libclc.llvm.org" | ||
3 | SECTION = "devel" | ||
4 | |||
5 | require common-clang.inc | ||
6 | require common-source.inc | ||
7 | |||
8 | LIC_FILES_CHKSUM = "file://libclc/LICENSE.TXT;md5=7cc795f6cbb2d801d84336b83c8017db" | ||
9 | |||
10 | inherit cmake pkgconfig | ||
11 | |||
12 | # Depend explicitly on clang-native instead of using TOOLCHAIN as the build | ||
13 | # objects from this recipe are build explicitly using clang for GPU targets. | ||
14 | # We could INHIBIT_DEFAULT_DEPS to avoid any other toolchain but then we need | ||
15 | # to wrestle CMake to configure without a toolchain. | ||
16 | DEPENDS += "clang-native spirv-llvm-translator-native" | ||
17 | |||
18 | OECMAKE_SOURCEPATH = "${S}/libclc" | ||
19 | B_NATIVE = "${B}-native" | ||
20 | |||
21 | # Semicolon-separated list of targets to build | ||
22 | LIBCLC_TARGETS ?= "all" | ||
23 | |||
24 | EXTRA_OECMAKE = "-DLIBCLC_TARGETS_TO_BUILD=${LIBCLC_TARGETS} \ | ||
25 | -DPREPARE_BUILTINS=${B_NATIVE}/prepare_builtins" | ||
26 | |||
27 | # Need to build a native prepare_builtins binary in target builds. The easiest | ||
28 | # way to do this is with a second native cmake build tree. | ||
29 | do_build_prepare_builtins() { | ||
30 | cmake --fresh -G Ninja \ | ||
31 | -S ${OECMAKE_SOURCEPATH} -B ${B_NATIVE} \ | ||
32 | -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${WORKDIR}/toolchain-native.cmake \ | ||
33 | -DLIBCLC_TARGETS_TO_BUILD= | ||
34 | cmake --build ${B_NATIVE} --target prepare_builtins | ||
35 | } | ||
36 | do_build_prepare_builtins:class-native() { | ||
37 | : | ||
38 | } | ||
39 | do_configure[prefuncs] += "do_build_prepare_builtins" | ||
40 | |||
41 | FILES:${PN} += "${datadir}/clc" | ||
42 | |||
43 | BBCLASSEXTEND = "native nativesdk" | ||