diff options
| -rw-r--r-- | meta/recipes-devtools/llvm/llvm/spirv-internal-build.patch | 30 | ||||
| -rw-r--r-- | meta/recipes-devtools/llvm/llvm/spirv-shared-library.patch | 25 | ||||
| -rw-r--r-- | meta/recipes-devtools/llvm/llvm_20.1.2.bb | 39 |
3 files changed, 89 insertions, 5 deletions
diff --git a/meta/recipes-devtools/llvm/llvm/spirv-internal-build.patch b/meta/recipes-devtools/llvm/llvm/spirv-internal-build.patch new file mode 100644 index 0000000000..555d40f4fb --- /dev/null +++ b/meta/recipes-devtools/llvm/llvm/spirv-internal-build.patch | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | From e94e529aefb28b65165e978daa2bfd89867ee8d0 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> | ||
| 3 | Date: Fri, 21 Mar 2025 17:17:52 +0200 | ||
| 4 | Subject: [PATCH] SPIRV-LLVM-Translator: fix handling of built-in SPIRV targer | ||
| 5 | |||
| 6 | If the SPIRV-LLVM-Translator is being built together with the LLVM, set | ||
| 7 | the defines declaring whether SPIRV target is also included into the | ||
| 8 | LLVM library or not. Otherwise llvm-spirv execution fails because | ||
| 9 | spirv-ext option is registered twice. | ||
| 10 | |||
| 11 | Upstream-Status: Pending [will be submitted upstream after internal clearance] | ||
| 12 | Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> | ||
| 13 | |||
| 14 | Index: llvm-project-20.1.0.src/llvm/projects/SPIRV-LLVM-Translator/CMakeLists.txt | ||
| 15 | =================================================================== | ||
| 16 | --- llvm-project-20.1.0.src.orig/llvm/projects/SPIRV-LLVM-Translator/CMakeLists.txt | ||
| 17 | +++ llvm-project-20.1.0.src/llvm/projects/SPIRV-LLVM-Translator/CMakeLists.txt | ||
| 18 | @@ -116,6 +116,12 @@ if(LLVM_SPIRV_BUILD_EXTERNAL) | ||
| 19 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) | ||
| 20 | set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) | ||
| 21 | endif() | ||
| 22 | +else() | ||
| 23 | + is_llvm_target_library("SPIRV" spirv_present_result INCLUDED_TARGETS) | ||
| 24 | + if(spirv_present_result) | ||
| 25 | + set(SPIRV_BACKEND_FOUND TRUE) | ||
| 26 | + add_compile_definitions(LLVM_SPIRV_BACKEND_TARGET_PRESENT) | ||
| 27 | + endif() | ||
| 28 | endif() | ||
| 29 | |||
| 30 | set(LLVM_SPIRV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
diff --git a/meta/recipes-devtools/llvm/llvm/spirv-shared-library.patch b/meta/recipes-devtools/llvm/llvm/spirv-shared-library.patch new file mode 100644 index 0000000000..edc595d576 --- /dev/null +++ b/meta/recipes-devtools/llvm/llvm/spirv-shared-library.patch | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | From e94e529aefb28b65165e978daa2bfd89867ee8d0 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> | ||
| 3 | Date: Thu, 9 Apr 2025 15:20:32 +0200 | ||
| 4 | Subject: [PATCH] SPIRV-LLVM-Translator: build shared library | ||
| 5 | |||
| 6 | By default SPIRV-LLVM-Translator builds only a static version of the library. | ||
| 7 | Unfortunately this might result in linking erros when uninative is in play, if | ||
| 8 | libLLVMSPIRV uses symbols which are provided only by the uninative libc and are | ||
| 9 | not provided by the host libc. | ||
| 10 | |||
| 11 | Upstream-Status: Inappropriate [OE-Specific] | ||
| 12 | Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> | ||
| 13 | |||
| 14 | Index: llvm-project-20.1.1.src/llvm/projects/SPIRV-LLVM-Translator/lib/SPIRV/CMakeLists.txt | ||
| 15 | =================================================================== | ||
| 16 | --- llvm-project-20.1.1.src.orig/llvm/projects/SPIRV-LLVM-Translator/lib/SPIRV/CMakeLists.txt | ||
| 17 | +++ llvm-project-20.1.1.src/llvm/projects/SPIRV-LLVM-Translator/lib/SPIRV/CMakeLists.txt | ||
| 18 | @@ -42,6 +42,7 @@ set(SRC_LIST | ||
| 19 | ) | ||
| 20 | add_llvm_library(LLVMSPIRVLib | ||
| 21 | ${SRC_LIST} | ||
| 22 | + SHARED | ||
| 23 | LINK_COMPONENTS | ||
| 24 | Analysis | ||
| 25 | BitWriter | ||
diff --git a/meta/recipes-devtools/llvm/llvm_20.1.2.bb b/meta/recipes-devtools/llvm/llvm_20.1.2.bb index f60c7ef7f7..f968217fa2 100644 --- a/meta/recipes-devtools/llvm/llvm_20.1.2.bb +++ b/meta/recipes-devtools/llvm/llvm_20.1.2.bb | |||
| @@ -23,9 +23,23 @@ MAJ_MIN_VERSION = "${@oe.utils.trim_version("${PV}", 2)}" | |||
| 23 | 23 | ||
| 24 | LLVM_RELEASE = "${PV}" | 24 | LLVM_RELEASE = "${PV}" |
| 25 | 25 | ||
| 26 | SRCREV_spirv = "68edc9d3d10ff6ec6353803a1bc60a5c25e7b715" | ||
| 27 | # pattern: llvm_branch_200, currently there are no minor releases, so, no llvm_branch_201 | ||
| 28 | SPIRV_BRANCH = "llvm_release_${@oe.utils.trim_version('${PV}', 1).replace('.', '')}0" | ||
| 29 | |||
| 30 | SRC_URI_SPIRV = " \ | ||
| 31 | git://github.com/KhronosGroup/SPIRV-LLVM-Translator;protocol=https;name=spirv;branch=${SPIRV_BRANCH};destsuffix=llvm-project-${PV}.src/llvm/projects/SPIRV-LLVM-Translator \ | ||
| 32 | file://spirv-internal-build.patch \ | ||
| 33 | " | ||
| 34 | |||
| 35 | SRC_URI_SPIRV:append:class-native = " \ | ||
| 36 | file://spirv-shared-library.patch \ | ||
| 37 | " | ||
| 38 | |||
| 26 | SRC_URI = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV}/llvm-project-${PV}.src.tar.xz \ | 39 | SRC_URI = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV}/llvm-project-${PV}.src.tar.xz \ |
| 27 | file://0007-llvm-allow-env-override-of-exe-path.patch \ | 40 | file://0007-llvm-allow-env-override-of-exe-path.patch \ |
| 28 | file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \ | 41 | file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \ |
| 42 | ${@bb.utils.contains('PACKAGECONFIG', 'spirv-llvm-translator', '${SRC_URI_SPIRV}', '', d)} \ | ||
| 29 | file://llvm-config \ | 43 | file://llvm-config \ |
| 30 | " | 44 | " |
| 31 | SRC_URI[sha256sum] = "f0a4a240aabc9b056142d14d5478bb6d962aeac549cbd75b809f5499240a8b38" | 45 | SRC_URI[sha256sum] = "f0a4a240aabc9b056142d14d5478bb6d962aeac549cbd75b809f5499240a8b38" |
| @@ -58,11 +72,12 @@ def get_llvm_arch(bb, d, arch_var): | |||
| 58 | def get_llvm_host_arch(bb, d): | 72 | def get_llvm_host_arch(bb, d): |
| 59 | return get_llvm_arch(bb, d, 'HOST_ARCH') | 73 | return get_llvm_arch(bb, d, 'HOST_ARCH') |
| 60 | 74 | ||
| 61 | PACKAGECONFIG ??= "libllvm libclc" | 75 | PACKAGECONFIG ??= "libllvm libclc spirv-llvm-translator" |
| 62 | # if optviewer OFF, force the modules to be not found or the ones on the host would be found | 76 | # if optviewer OFF, force the modules to be not found or the ones on the host would be found |
| 63 | PACKAGECONFIG[optviewer] = ",-DPY_PYGMENTS_FOUND=OFF -DPY_PYGMENTS_LEXERS_C_CPP_FOUND=OFF -DPY_YAML_FOUND=OFF,python3-pygments python3-pyyaml,python3-pygments python3-pyyaml" | 77 | PACKAGECONFIG[optviewer] = ",-DPY_PYGMENTS_FOUND=OFF -DPY_PYGMENTS_LEXERS_C_CPP_FOUND=OFF -DPY_YAML_FOUND=OFF,python3-pygments python3-pyyaml,python3-pygments python3-pyyaml" |
| 64 | PACKAGECONFIG[libllvm] = "" | 78 | PACKAGECONFIG[libllvm] = "" |
| 65 | PACKAGECONFIG[libclc] = "" | 79 | PACKAGECONFIG[libclc] = "" |
| 80 | PACKAGECONFIG[spirv-llvm-translator] = "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${STAGING_INCDIR}/.. ,,spirv-tools-native spirv-headers" | ||
| 66 | 81 | ||
| 67 | # | 82 | # |
| 68 | # Default to build all OE-Core supported target arches (user overridable). | 83 | # Default to build all OE-Core supported target arches (user overridable). |
| @@ -72,7 +87,9 @@ LLVM_TARGETS ?= "AMDGPU;NVPTX;SPIRV;${@get_llvm_host_arch(bb, d)}" | |||
| 72 | ARM_INSTRUCTION_SET:armv5 = "arm" | 87 | ARM_INSTRUCTION_SET:armv5 = "arm" |
| 73 | ARM_INSTRUCTION_SET:armv4t = "arm" | 88 | ARM_INSTRUCTION_SET:armv4t = "arm" |
| 74 | 89 | ||
| 75 | LLVM_PROJECTS = "${@bb.utils.contains('PACKAGECONFIG', 'libclc', 'clang;libclc', '', d)}" | 90 | LLVM_PROJECTS_CLANG = "${@bb.utils.contains_any('PACKAGECONFIG', 'libclc spirv-llvm-translator', 'clang', '', d)}" |
| 91 | LLVM_PROJECTS_CLC = "${@bb.utils.contains('PACKAGECONFIG', 'libclc', ';libclc', '', d)}" | ||
| 92 | LLVM_PROJECTS = "${LLVM_PROJECTS_CLANG}${LLVM_PROJECTS_CLC}" | ||
| 76 | 93 | ||
| 77 | EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ | 94 | EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ |
| 78 | -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \ | 95 | -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \ |
| @@ -138,7 +155,7 @@ do_install() { | |||
| 138 | fi | 155 | fi |
| 139 | 156 | ||
| 140 | # Remove clang bits from target packages, we are not providing it for the system | 157 | # Remove clang bits from target packages, we are not providing it for the system |
| 141 | if ${@bb.utils.contains('PACKAGECONFIG', 'libclc', 'true', 'false', d)} && | 158 | if ${@bb.utils.contains_any('PACKAGECONFIG', 'libclc spirv-llvm-translator', 'true', 'false', d)} && |
| 142 | [ "${CLASSOVERRIDE}" != "class-native" ] ; then | 159 | [ "${CLASSOVERRIDE}" != "class-native" ] ; then |
| 143 | rm -f ${D}${bindir}/clang* | 160 | rm -f ${D}${bindir}/clang* |
| 144 | rm -fr ${D}${libdir}/clang | 161 | rm -fr ${D}${libdir}/clang |
| @@ -176,11 +193,12 @@ llvm_sysroot_preprocess() { | |||
| 176 | ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV} | 193 | ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV} |
| 177 | } | 194 | } |
| 178 | 195 | ||
| 179 | PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto ${PN}-clc" | 196 | PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto ${PN}-clc ${PN}-spirv" |
| 180 | PROVIDES = "${@bb.utils.filter('PACKAGECONFIG', 'libclc', d)}" | 197 | PROVIDES = "${@bb.utils.filter('PACKAGECONFIG', 'libclc spirv-llvm-translator', d)}" |
| 181 | 198 | ||
| 182 | RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks" | 199 | RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks" |
| 183 | RPROVIDES:${PN}-clc = "${@bb.utils.filter('PACKAGECONFIG', 'libclc', d)}" | 200 | RPROVIDES:${PN}-clc = "${@bb.utils.filter('PACKAGECONFIG', 'libclc', d)}" |
| 201 | RPROVIDES:${PN}-spirv = "${@bb.utils.filter('PACKAGECONFIG', 'spirv-llvm-translator', d)}" | ||
| 184 | 202 | ||
| 185 | FILES:${PN}-bugpointpasses = "\ | 203 | FILES:${PN}-bugpointpasses = "\ |
| 186 | ${libdir}/BugpointPasses.so \ | 204 | ${libdir}/BugpointPasses.so \ |
| @@ -215,6 +233,17 @@ FILES:${PN}-staticdev += "\ | |||
| 215 | 233 | ||
| 216 | FILES:${PN}-clc += "${datadir}/clc" | 234 | FILES:${PN}-clc += "${datadir}/clc" |
| 217 | 235 | ||
| 236 | FILES:${PN}-spirv = " \ | ||
| 237 | ${bindir}/llvm-spirv \ | ||
| 238 | ${includedir}/LLVMSPIRVLib \ | ||
| 239 | ${libdir}/pkgconfig/LLVMSPIRVLib.pc \ | ||
| 240 | ${libdir}/libLLVMSPIRV* \ | ||
| 241 | " | ||
| 242 | |||
| 218 | INSANE_SKIP:${PN}-libllvm += "dev-so" | 243 | INSANE_SKIP:${PN}-libllvm += "dev-so" |
| 219 | 244 | ||
| 245 | # SPIRV-LLVM-Translator provides only static libraries, they are included into | ||
| 246 | # the llvm-spirv package. | ||
| 247 | INSANE_SKIP:${PN}-spirv += "staticdev" | ||
| 248 | |||
| 220 | BBCLASSEXTEND = "native nativesdk" | 249 | BBCLASSEXTEND = "native nativesdk" |
