From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: openembedded-core@lists.openembedded.org
Cc: Khem Raj <raj.khem@gmail.com>
Subject: [PATCH v6 09/13] llvm: add SPIRV-LLVM-Translator support
Date: Mon, 07 Apr 2025 12:48:14 +0300 [thread overview]
Message-ID: <20250407-mesa-25-v6-9-29bf4cae8d28@oss.qualcomm.com> (raw)
In-Reply-To: <20250407-mesa-25-v6-0-29bf4cae8d28@oss.qualcomm.com>
Mesa builds require SPIRV-LLVM-Translator in order to build CLC support.
While it is possible to build it separately (like meta-clang does), it
also requires a separate clang compiler (which OE-Core doesn't provide).
Use an alternative path and build SPIRV-LLVM-Translator as a part of the
LLVM build process, lifting the requirement for the separate clang. Once
Clang is properly integrated into the OE-Core layer, this can be split
to a separate package and dropped. In order to ease migration from
meta-clang and to ease future split, PROVIDE the spirv-llvm-translator
and make the llvm-spirv package RPROVIDE spirv-llvm-translator.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
.../llvm/llvm/spirv-internal-build.patch | 30 +++++++++++++++++++
meta/recipes-devtools/llvm/llvm_20.1.1.bb | 35 ++++++++++++++++++----
2 files changed, 60 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 0000000000000000000000000000000000000000..555d40f4fb07342cc204c7c578662688605b2cb1
--- /dev/null
+++ b/meta/recipes-devtools/llvm/llvm/spirv-internal-build.patch
@@ -0,0 +1,30 @@
+From e94e529aefb28b65165e978daa2bfd89867ee8d0 Mon Sep 17 00:00:00 2001
+From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
+Date: Fri, 21 Mar 2025 17:17:52 +0200
+Subject: [PATCH] SPIRV-LLVM-Translator: fix handling of built-in SPIRV targer
+
+If the SPIRV-LLVM-Translator is being built together with the LLVM, set
+the defines declaring whether SPIRV target is also included into the
+LLVM library or not. Otherwise llvm-spirv execution fails because
+spirv-ext option is registered twice.
+
+Upstream-Status: Pending [will be submitted upstream after internal clearance]
+Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
+
+Index: llvm-project-20.1.0.src/llvm/projects/SPIRV-LLVM-Translator/CMakeLists.txt
+===================================================================
+--- llvm-project-20.1.0.src.orig/llvm/projects/SPIRV-LLVM-Translator/CMakeLists.txt
++++ llvm-project-20.1.0.src/llvm/projects/SPIRV-LLVM-Translator/CMakeLists.txt
+@@ -116,6 +116,12 @@ if(LLVM_SPIRV_BUILD_EXTERNAL)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
+ endif()
++else()
++ is_llvm_target_library("SPIRV" spirv_present_result INCLUDED_TARGETS)
++ if(spirv_present_result)
++ set(SPIRV_BACKEND_FOUND TRUE)
++ add_compile_definitions(LLVM_SPIRV_BACKEND_TARGET_PRESENT)
++ endif()
+ endif()
+
+ set(LLVM_SPIRV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
diff --git a/meta/recipes-devtools/llvm/llvm_20.1.1.bb b/meta/recipes-devtools/llvm/llvm_20.1.1.bb
index d33284c90180de60d5087b466304a94bd8ae6039..027de04bdd6d340792d1a9ca303dcd508a6d87c4 100644
--- a/meta/recipes-devtools/llvm/llvm_20.1.1.bb
+++ b/meta/recipes-devtools/llvm/llvm_20.1.1.bb
@@ -23,9 +23,19 @@ MAJ_MIN_VERSION = "${@oe.utils.trim_version("${PV}", 2)}"
LLVM_RELEASE = "${PV}"
+SRCREV_spirv = "68edc9d3d10ff6ec6353803a1bc60a5c25e7b715"
+# pattern: llvm_branch_200, currently there are no minor releases, so, no llvm_branch_201
+SPIRV_BRANCH = "llvm_release_${@oe.utils.trim_version('${PV}', 1).replace('.', '')}0"
+
+SRC_URI_SPIRV = " \
+ git://github.com/KhronosGroup/SPIRV-LLVM-Translator;protocol=https;name=spirv;branch=${SPIRV_BRANCH};destsuffix=llvm-project-${PV}.src/llvm/projects/SPIRV-LLVM-Translator \
+ file://spirv-internal-build.patch \
+"
+
SRC_URI = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV}/llvm-project-${PV}.src.tar.xz \
file://0007-llvm-allow-env-override-of-exe-path.patch \
file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \
+ ${@bb.utils.contains('PACKAGECONFIG', 'spirv-llvm-translator', '${SRC_URI_SPIRV}', '', d)} \
file://llvm-config \
file://isoc23.h \
"
@@ -59,11 +69,12 @@ def get_llvm_arch(bb, d, arch_var):
def get_llvm_host_arch(bb, d):
return get_llvm_arch(bb, d, 'HOST_ARCH')
-PACKAGECONFIG ??= "libllvm libclc"
+PACKAGECONFIG ??= "libllvm libclc spirv-llvm-translator"
# if optviewer OFF, force the modules to be not found or the ones on the host would be found
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"
PACKAGECONFIG[libllvm] = ""
PACKAGECONFIG[libclc] = ""
+PACKAGECONFIG[spirv-llvm-translator] = "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${STAGING_INCDIR}/.. ,,spirv-tools-native spirv-headers"
#
# Default to build all OE-Core supported target arches (user overridable).
@@ -73,7 +84,9 @@ LLVM_TARGETS ?= "AMDGPU;NVPTX;SPIRV;${@get_llvm_host_arch(bb, d)}"
ARM_INSTRUCTION_SET:armv5 = "arm"
ARM_INSTRUCTION_SET:armv4t = "arm"
-LLVM_PROJECTS = "${@bb.utils.contains('PACKAGECONFIG', 'libclc', 'clang;libclc', '', d)}"
+LLVM_PROJECTS_CLANG = "${@bb.utils.contains_any('PACKAGECONFIG', 'libclc spirv-llvm-translator', 'clang', '', d)}"
+LLVM_PROJECTS_CLC = "${@bb.utils.contains('PACKAGECONFIG', 'libclc', ';libclc', '', d)}"
+LLVM_PROJECTS = "${LLVM_PROJECTS_CLANG}${LLVM_PROJECTS_CLC}"
BUILD_CPPFLAGS += "-include ${UNPACKDIR}/isoc23.h"
@@ -141,7 +154,7 @@ do_install() {
fi
# Remove clang bits from target packages, we are not providing it for the system
- if ${@bb.utils.contains('PACKAGECONFIG', 'libclc', 'true', 'false', d)} &&
+ if ${@bb.utils.contains_any('PACKAGECONFIG', 'libclc spirv-llvm-translator', 'true', 'false', d)} &&
[ "${CLASSOVERRIDE}" != "class-native" ] ; then
rm -f ${D}${bindir}/clang*
rm -fr ${D}${libdir}/clang
@@ -179,11 +192,12 @@ llvm_sysroot_preprocess() {
ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV}
}
-PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto ${PN}-clc"
-PROVIDES = "${@bb.utils.filter('PACKAGECONFIG', 'libclc', d)}"
+PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto ${PN}-clc ${PN}-spirv"
+PROVIDES = "${@bb.utils.filter('PACKAGECONFIG', 'libclc spirv-llvm-translator', d)}"
RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks"
RPROVIDES:${PN}-clc = "${@bb.utils.filter('PACKAGECONFIG', 'libclc', d)}"
+RPROVIDES:${PN}-spirv = "${@bb.utils.filter('PACKAGECONFIG', 'spirv-llvm-translator', d)}"
FILES:${PN}-bugpointpasses = "\
${libdir}/BugpointPasses.so \
@@ -218,6 +232,17 @@ FILES:${PN}-staticdev += "\
FILES:${PN}-clc += "${datadir}/clc"
+FILES:${PN}-spirv = " \
+ ${bindir}/llvm-spirv \
+ ${includedir}/LLVMSPIRVLib \
+ ${libdir}/pkgconfig/LLVMSPIRVLib.pc \
+ ${libdir}/libLLVMSPIRV* \
+"
+
INSANE_SKIP:${PN}-libllvm += "dev-so"
+# SPIRV-LLVM-Translator provides only static libraries, they are included into
+# the llvm-spirv package.
+INSANE_SKIP:${PN}-spirv += "staticdev"
+
BBCLASSEXTEND = "native nativesdk"
--
2.39.5
next prev parent reply other threads:[~2025-04-07 9:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 9:48 [PATCH v6 00/13] mesa: upgrade to 25.0.2 Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 01/13] runqemu: also set GBM_BACKENDS_PATH Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 02/13] llvm: move libLLVM.so.N.M to llvm-libllvm package Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 03/13] llvm: use OECMAKE_SOURCEPATH to specify cmake dir Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 04/13] llvm: handle libdir in llvm-config Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 05/13] llvm: also use llvm-config wrapper for nativesdk recipes Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 06/13] llvm: remove LLVM_LDFLAGS from llvm-config --ldflags output Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 07/13] llvm: forcibly disable __isoc23_strtol usage Dmitry Baryshkov
2025-04-07 11:22 ` [OE-core] " Alexander Kanavin
2025-04-07 11:58 ` Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 08/13] llvm: support building libclc Dmitry Baryshkov
2025-04-07 9:48 ` Dmitry Baryshkov [this message]
2025-04-07 9:48 ` [PATCH v6 10/13] llvm: enable more targets to build Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 11/13] mesa: upgrade 24.0.7 -> 25.0.2 Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 12/13] bindgen-cli: a tool to generate Rust bindings Dmitry Baryshkov
2025-04-07 9:48 ` [PATCH v6 13/13] mesa: add support for RustiCL under PACKAGECONFIG "opencl" Dmitry Baryshkov
2025-04-08 13:34 ` [OE-core] [PATCH v6 00/13] mesa: upgrade to 25.0.2 Mathieu Dubois-Briand
2025-04-08 19:08 ` Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250407-mesa-25-v6-9-29bf4cae8d28@oss.qualcomm.com \
--to=dmitry.baryshkov@oss.qualcomm.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=raj.khem@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox