mirror of
https://git.yoctoproject.org/poky
synced 2026-02-07 01:06:37 +01:00
Currently the CMake configuration for llvm finds the python pygments and pyyaml if they are installed on the host. This makes builds non-reproducible across different machines, some having those modules installed and some others not. This has been causing a 'reproducible' failure on one of the autobuilders: AssertionError: The following deb packages are missing or different and not in exclusion list: /home/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB/tmp/deploy/deb/./core2-64/llvm-dev_14.0.4-r0_amd64.deb The following ipk packages are missing or different and not in exclusion list: /home/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB/tmp/deploy/ipk/./core2-64/llvm-dev_14.0.4-r0_core2-64.ipk The following rpm packages are missing or different and not in exclusion list: /home/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB/tmp/deploy/rpm/./core2_64/llvm-dev-14.0.4-r0.core2_64.rpm Fix by adding an explicit PACKAGECONFIG to control the LLVM_HAVE_OPT_VIEWER_MODULES option in CMake. If unset, it forces CMake to ignore pygments and pyyaml, no matter it they are available on the host. If set, it DEPENDS on the pygments and pyyaml modules so that CMake will find and use them. Based on suggestions from Stefan and Markus -- thanks. Proposed-by: "Stefan Herbrechtsmeier" <stefan.herbrechtsmeier-oss@weidmueller.com> Proposed-by: "Markus Volk" <f_l_k@t-online.de> (From OE-Core rev: 78b6a08db4e8eb3b4e1d52fcdb39a5b3415f5a3f) Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
166 lines
5.3 KiB
BlitzBasic
166 lines
5.3 KiB
BlitzBasic
# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
|
|
# Released under the MIT license (see COPYING.MIT for the terms)
|
|
|
|
DESCRIPTION = "The LLVM Compiler Infrastructure"
|
|
HOMEPAGE = "http://llvm.org"
|
|
LICENSE = "Apache-2.0-with-LLVM-exception"
|
|
SECTION = "devel"
|
|
|
|
LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe"
|
|
|
|
DEPENDS = "libffi libxml2 zlib libedit ninja-native llvm-native"
|
|
|
|
COMPATIBLE_HOST:riscv64 = "null"
|
|
COMPATIBLE_HOST:riscv32 = "null"
|
|
|
|
RDEPENDS:${PN}:append:class-target = " ncurses-terminfo"
|
|
|
|
inherit cmake pkgconfig
|
|
|
|
PROVIDES += "llvm${PV}"
|
|
|
|
PV = "14.0.4"
|
|
|
|
MAJOR_VERSION = "${@oe.utils.trim_version("${PV}", 1)}"
|
|
|
|
LLVM_RELEASE = "${PV}"
|
|
|
|
BRANCH = "release/${MAJOR_VERSION}.x"
|
|
SRCREV = "29f1039a7285a5c3a9c353d054140bf2556d4c4d"
|
|
SRC_URI = "git://github.com/llvm/llvm-project.git;branch=${BRANCH};protocol=https \
|
|
file://0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch;striplevel=2 \
|
|
file://0007-llvm-allow-env-override-of-exe-path.patch;striplevel=2 \
|
|
file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch;striplevel=2 \
|
|
"
|
|
|
|
UPSTREAM_CHECK_GITTAGREGEX = "llvmorg-(?P<pver>\d+(\.\d+)+)"
|
|
|
|
S = "${WORKDIR}/git/llvm"
|
|
|
|
LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
|
|
|
|
def get_llvm_arch(bb, d, arch_var):
|
|
import re
|
|
a = d.getVar(arch_var)
|
|
if re.match(r'(i.86|athlon|x86.64)$', a): return 'X86'
|
|
elif re.match(r'arm$', a): return 'ARM'
|
|
elif re.match(r'armeb$', a): return 'ARM'
|
|
elif re.match(r'aarch64$', a): return 'AArch64'
|
|
elif re.match(r'aarch64_be$', a): return 'AArch64'
|
|
elif re.match(r'mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
|
|
elif re.match(r'riscv(32|64)(eb|)$', a): return 'RISCV'
|
|
elif re.match(r'p(pc|owerpc)(|64)', a): return 'PowerPC'
|
|
else:
|
|
raise bb.parse.SkipRecipe("Cannot map '%s' to a supported LLVM architecture" % a)
|
|
|
|
def get_llvm_host_arch(bb, d):
|
|
return get_llvm_arch(bb, d, 'HOST_ARCH')
|
|
|
|
PACKAGECONFIG ??= ""
|
|
# 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"
|
|
|
|
#
|
|
# Default to build all OE-Core supported target arches (user overridable).
|
|
#
|
|
LLVM_TARGETS ?= "AMDGPU;${@get_llvm_host_arch(bb, d)}"
|
|
|
|
ARM_INSTRUCTION_SET:armv5 = "arm"
|
|
ARM_INSTRUCTION_SET:armv4t = "arm"
|
|
|
|
EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
|
|
-DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
|
|
-DLLVM_ENABLE_PIC=ON \
|
|
-DLLVM_BINDINGS_LIST='' \
|
|
-DLLVM_LINK_LLVM_DYLIB=ON \
|
|
-DLLVM_ENABLE_FFI=ON \
|
|
-DLLVM_ENABLE_RTTI=ON \
|
|
-DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
|
|
-DLLVM_OPTIMIZED_TABLEGEN=ON \
|
|
-DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS}' \
|
|
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \
|
|
-DPYTHON_EXECUTABLE=${HOSTTOOLS_DIR}/python3 \
|
|
-G Ninja"
|
|
|
|
EXTRA_OECMAKE:append:class-target = "\
|
|
-DCMAKE_CROSSCOMPILING:BOOL=ON \
|
|
-DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \
|
|
-DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \
|
|
"
|
|
|
|
EXTRA_OECMAKE:append:class-nativesdk = "\
|
|
-DCMAKE_CROSSCOMPILING:BOOL=ON \
|
|
-DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \
|
|
-DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \
|
|
"
|
|
|
|
# patch out build host paths for reproducibility
|
|
do_compile:prepend:class-target() {
|
|
sed -i -e "s,${WORKDIR},,g" ${B}/tools/llvm-config/BuildVariables.inc
|
|
}
|
|
|
|
do_compile() {
|
|
ninja -v ${PARALLEL_MAKE}
|
|
}
|
|
|
|
do_compile:class-native() {
|
|
ninja -v ${PARALLEL_MAKE} llvm-config llvm-tblgen
|
|
}
|
|
|
|
do_install() {
|
|
DESTDIR=${D} ninja -v install
|
|
|
|
# llvm harcodes usr/lib as install path, so this corrects it to actual libdir
|
|
mv -T -n ${D}/${prefix}/lib ${D}/${libdir} || true
|
|
|
|
# Remove opt-viewer: https://llvm.org/docs/Remarks.html
|
|
rm -rf ${D}${datadir}/opt-viewer
|
|
rmdir ${D}${datadir}
|
|
|
|
# reproducibility
|
|
sed -i -e 's,${WORKDIR},,g' ${D}/${libdir}/cmake/llvm/LLVMConfig.cmake
|
|
}
|
|
|
|
do_install:class-native() {
|
|
install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen${PV}
|
|
install -D -m 0755 ${B}/bin/llvm-config ${D}${bindir}/llvm-config${PV}
|
|
}
|
|
|
|
PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto"
|
|
|
|
RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks"
|
|
|
|
FILES:${PN}-bugpointpasses = "\
|
|
${libdir}/BugpointPasses.so \
|
|
"
|
|
|
|
FILES:${PN}-libllvm = "\
|
|
${libdir}/libLLVM-${MAJOR_VERSION}.so \
|
|
"
|
|
|
|
FILES:${PN}-liblto += "\
|
|
${libdir}/libLTO.so.* \
|
|
"
|
|
|
|
FILES:${PN}-liboptremarks += "\
|
|
${libdir}/libRemarks.so.* \
|
|
"
|
|
|
|
FILES:${PN}-llvmhello = "\
|
|
${libdir}/LLVMHello.so \
|
|
"
|
|
|
|
FILES:${PN}-dev += " \
|
|
${libdir}/llvm-config \
|
|
${libdir}/libRemarks.so \
|
|
${libdir}/libLLVM-${PV}.so \
|
|
"
|
|
|
|
FILES:${PN}-staticdev += "\
|
|
${libdir}/*.a \
|
|
"
|
|
|
|
INSANE_SKIP:${PN}-libllvm += "dev-so"
|
|
|
|
BBCLASSEXTEND = "native nativesdk"
|