diff options
| author | Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> | 2025-04-10 05:54:46 +0300 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-04-11 11:44:22 +0100 |
| commit | c3a1f9b863147469fde2bec18fa7081e83958e39 (patch) | |
| tree | e7ac08b12d4769a0743fbd52256173918a517046 | |
| parent | d41b5391ab43609d47041e9b2f4e03a131383e19 (diff) | |
| download | poky-c3a1f9b863147469fde2bec18fa7081e83958e39.tar.gz | |
llvm: support building libclc
Current Mesa requires libclc in order to build Intel Gallium (iris) or
Vulkan drivers. In order to unblock Mesa updates, build libclc as a part
of the LLVM build process.
The libclc requires Clang for building, so enable Clang too via
LLVM_PROJECTS. Remove clang from the DESTDIR, so that it is only used
during the build process. Proper handling of Clang as a toolchain is a
separate and much more complicated topic. Clang is enabled for all kinds
of builds as it is a requirement for libclc to build.
Cleaning of ${datadir} has been moved to happen at the end of do_install
to be performed after do clang removal and made not to fail if
${datadir} is not empty, as libclc install files into that location.
NVPTX and SPIRV targets are enabled since they are required for the
libclc to link.
LLVM_NATIVE_TOOL_DIR is used to pass a path to the native tools built
via llvm-native instead of building them during the target and/or
nativesdk build.
The llvm-clc package is set to RPROVIDE libclc (and the recipe also
PROVIDEs libclc) in order to be compatible with the meta-clang packages
(and to be future-compatible with the split package after proper Clang
support is introduced to OE-Core).
(From OE-Core rev: 2773404dec7840e2252cfd5bf474be70d8e7888f)
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-devtools/llvm/llvm_20.1.2.bb | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/meta/recipes-devtools/llvm/llvm_20.1.2.bb b/meta/recipes-devtools/llvm/llvm_20.1.2.bb index d996a7c49c..f60c7ef7f7 100644 --- a/meta/recipes-devtools/llvm/llvm_20.1.2.bb +++ b/meta/recipes-devtools/llvm/llvm_20.1.2.bb | |||
| @@ -58,19 +58,22 @@ def get_llvm_arch(bb, d, arch_var): | |||
| 58 | def get_llvm_host_arch(bb, d): | 58 | def get_llvm_host_arch(bb, d): |
| 59 | return get_llvm_arch(bb, d, 'HOST_ARCH') | 59 | return get_llvm_arch(bb, d, 'HOST_ARCH') |
| 60 | 60 | ||
| 61 | PACKAGECONFIG ??= "libllvm" | 61 | PACKAGECONFIG ??= "libllvm libclc" |
| 62 | # if optviewer OFF, force the modules to be not found or the ones on the host would be found | 62 | # 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" | 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" |
| 64 | PACKAGECONFIG[libllvm] = "" | 64 | PACKAGECONFIG[libllvm] = "" |
| 65 | PACKAGECONFIG[libclc] = "" | ||
| 65 | 66 | ||
| 66 | # | 67 | # |
| 67 | # Default to build all OE-Core supported target arches (user overridable). | 68 | # Default to build all OE-Core supported target arches (user overridable). |
| 68 | # | 69 | # |
| 69 | LLVM_TARGETS ?= "AMDGPU;${@get_llvm_host_arch(bb, d)}" | 70 | LLVM_TARGETS ?= "AMDGPU;NVPTX;SPIRV;${@get_llvm_host_arch(bb, d)}" |
| 70 | 71 | ||
| 71 | ARM_INSTRUCTION_SET:armv5 = "arm" | 72 | ARM_INSTRUCTION_SET:armv5 = "arm" |
| 72 | ARM_INSTRUCTION_SET:armv4t = "arm" | 73 | ARM_INSTRUCTION_SET:armv4t = "arm" |
| 73 | 74 | ||
| 75 | LLVM_PROJECTS = "${@bb.utils.contains('PACKAGECONFIG', 'libclc', 'clang;libclc', '', d)}" | ||
| 76 | |||
| 74 | EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ | 77 | EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ |
| 75 | -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \ | 78 | -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \ |
| 76 | -DLLVM_ENABLE_PIC=ON \ | 79 | -DLLVM_ENABLE_PIC=ON \ |
| @@ -84,6 +87,7 @@ EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ | |||
| 84 | -DLLVM_VERSION_SUFFIX='${VER_SUFFIX}' \ | 87 | -DLLVM_VERSION_SUFFIX='${VER_SUFFIX}' \ |
| 85 | -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ | 88 | -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ |
| 86 | -DCMAKE_BUILD_TYPE=Release \ | 89 | -DCMAKE_BUILD_TYPE=Release \ |
| 90 | -DLLVM_ENABLE_PROJECTS='${LLVM_PROJECTS}' \ | ||
| 87 | " | 91 | " |
| 88 | 92 | ||
| 89 | EXTRA_OECMAKE:append:class-target = "\ | 93 | EXTRA_OECMAKE:append:class-target = "\ |
| @@ -91,6 +95,7 @@ EXTRA_OECMAKE:append:class-target = "\ | |||
| 91 | -DLLVM_HOST_TRIPLE=${TARGET_SYS} \ | 95 | -DLLVM_HOST_TRIPLE=${TARGET_SYS} \ |
| 92 | -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \ | 96 | -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \ |
| 93 | -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \ | 97 | -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \ |
| 98 | -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \ | ||
| 94 | " | 99 | " |
| 95 | 100 | ||
| 96 | EXTRA_OECMAKE:append:class-nativesdk = "\ | 101 | EXTRA_OECMAKE:append:class-nativesdk = "\ |
| @@ -98,6 +103,7 @@ EXTRA_OECMAKE:append:class-nativesdk = "\ | |||
| 98 | -DLLVM_HOST_TRIPLE=${SDK_SYS} \ | 103 | -DLLVM_HOST_TRIPLE=${SDK_SYS} \ |
| 99 | -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \ | 104 | -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \ |
| 100 | -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \ | 105 | -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \ |
| 106 | -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \ | ||
| 101 | " | 107 | " |
| 102 | 108 | ||
| 103 | # patch out build host paths for reproducibility | 109 | # patch out build host paths for reproducibility |
| @@ -126,17 +132,39 @@ do_install() { | |||
| 126 | 132 | ||
| 127 | # Remove opt-viewer: https://llvm.org/docs/Remarks.html | 133 | # Remove opt-viewer: https://llvm.org/docs/Remarks.html |
| 128 | rm -rf ${D}${datadir}/opt-viewer | 134 | rm -rf ${D}${datadir}/opt-viewer |
| 129 | rmdir ${D}${datadir} | ||
| 130 | 135 | ||
| 131 | # reproducibility | 136 | # reproducibility |
| 132 | sed -i -e 's,${WORKDIR},,g' ${D}/${libdir}/cmake/llvm/LLVMConfig.cmake | 137 | sed -i -e 's,${WORKDIR},,g' ${D}/${libdir}/cmake/llvm/LLVMConfig.cmake |
| 133 | fi | 138 | fi |
| 139 | |||
| 140 | # Remove clang bits from target packages, we are not providing it for the system | ||
| 141 | if ${@bb.utils.contains('PACKAGECONFIG', 'libclc', 'true', 'false', d)} && | ||
| 142 | [ "${CLASSOVERRIDE}" != "class-native" ] ; then | ||
| 143 | rm -f ${D}${bindir}/clang* | ||
| 144 | rm -fr ${D}${libdir}/clang | ||
| 145 | rm -fr ${D}${datadir}/clang | ||
| 146 | |||
| 147 | rm -f ${D}${bindir}/scan* | ||
| 148 | rm -fr ${D}${libdir}/libscanbuild | ||
| 149 | rm -fr ${D}${datadir}/scan-build | ||
| 150 | rm -fr ${D}${datadir}/scan-view | ||
| 151 | |||
| 152 | rm -fr ${D}${libdir}/libear | ||
| 153 | fi | ||
| 154 | |||
| 155 | # Try to clean up datadir if it is empty, but don't fail if there are | ||
| 156 | # libclc files there | ||
| 157 | rmdir ${D}${datadir} || true | ||
| 134 | } | 158 | } |
| 135 | 159 | ||
| 136 | do_install:append:class-native() { | 160 | do_install:append:class-native() { |
| 137 | install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen${PV} | 161 | install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen${PV} |
| 138 | install -D -m 0755 ${B}/bin/llvm-config ${D}${bindir}/llvm-config${PV} | 162 | install -D -m 0755 ${B}/bin/llvm-config ${D}${bindir}/llvm-config${PV} |
| 139 | ln -sf llvm-config${PV} ${D}${bindir}/llvm-config | 163 | ln -sf llvm-config${PV} ${D}${bindir}/llvm-config |
| 164 | |||
| 165 | if ${@bb.utils.contains('PACKAGECONFIG', 'libclc', 'true', 'false', d)} ; then | ||
| 166 | install -D -m 0755 ${B}/bin/prepare_builtins ${D}${bindir}/prepare_builtins | ||
| 167 | fi | ||
| 140 | } | 168 | } |
| 141 | 169 | ||
| 142 | SYSROOT_PREPROCESS_FUNCS:append:class-target = " llvm_sysroot_preprocess" | 170 | SYSROOT_PREPROCESS_FUNCS:append:class-target = " llvm_sysroot_preprocess" |
| @@ -148,9 +176,11 @@ llvm_sysroot_preprocess() { | |||
| 148 | ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV} | 176 | ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV} |
| 149 | } | 177 | } |
| 150 | 178 | ||
| 151 | PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto" | 179 | PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto ${PN}-clc" |
| 180 | PROVIDES = "${@bb.utils.filter('PACKAGECONFIG', 'libclc', d)}" | ||
| 152 | 181 | ||
| 153 | RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks" | 182 | RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks" |
| 183 | RPROVIDES:${PN}-clc = "${@bb.utils.filter('PACKAGECONFIG', 'libclc', d)}" | ||
| 154 | 184 | ||
| 155 | FILES:${PN}-bugpointpasses = "\ | 185 | FILES:${PN}-bugpointpasses = "\ |
| 156 | ${libdir}/BugpointPasses.so \ | 186 | ${libdir}/BugpointPasses.so \ |
| @@ -183,6 +213,8 @@ FILES:${PN}-staticdev += "\ | |||
| 183 | ${libdir}/*.a \ | 213 | ${libdir}/*.a \ |
| 184 | " | 214 | " |
| 185 | 215 | ||
| 216 | FILES:${PN}-clc += "${datadir}/clc" | ||
| 217 | |||
| 186 | INSANE_SKIP:${PN}-libllvm += "dev-so" | 218 | INSANE_SKIP:${PN}-libllvm += "dev-so" |
| 187 | 219 | ||
| 188 | BBCLASSEXTEND = "native nativesdk" | 220 | BBCLASSEXTEND = "native nativesdk" |
