diff options
| author | Ross Burton <ross.burton@arm.com> | 2025-10-07 11:42:45 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-10-07 13:53:07 +0100 |
| commit | b2c14772297fb2f0ac619703d7185ae9e53b698e (patch) | |
| tree | a86dac6f3c10242037f420d915c50f38924f7d2f | |
| parent | afd954067337dfb41d9d334424a7c52d0f71e66f (diff) | |
| download | poky-b2c14772297fb2f0ac619703d7185ae9e53b698e.tar.gz | |
llvm: add recipe for just the LLVM libraries
Whilst it's convenient to build all of the LLVM project in one big
recipe, that's not ideal when we may just need LLVM on target and not
the rest.
Bring back a LLVM recipe that can be used by both clang (shortly) and
Rust (in the future)
Set the build type to MinSizeRel and DEBUG_LEVELFLAG to -g1 (instead of
the default, -g): the LLVM debug symbols are very large (several
gigabytes) and this reduces them to hundreds of megabytes.
(From OE-Core rev: 0117f37cd2b0c06b4e8d1571e33d3222abfa6cc2)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/conf/distro/include/maintainers.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/clang/llvm_git.bb | 129 |
2 files changed, 130 insertions, 0 deletions
diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc index 0e5150895f..d2c613b8e9 100644 --- a/meta/conf/distro/include/maintainers.inc +++ b/meta/conf/distro/include/maintainers.inc | |||
| @@ -483,6 +483,7 @@ RECIPE_MAINTAINER:pn-lld = "Khem Raj <raj.khem@gmail.com>" | |||
| 483 | RECIPE_MAINTAINER:pn-lldb = "Khem Raj <raj.khem@gmail.com>" | 483 | RECIPE_MAINTAINER:pn-lldb = "Khem Raj <raj.khem@gmail.com>" |
| 484 | RECIPE_MAINTAINER:pn-llvm-project-source-21.1.2 = "Khem Raj <raj.khem@gmail.com>" | 484 | RECIPE_MAINTAINER:pn-llvm-project-source-21.1.2 = "Khem Raj <raj.khem@gmail.com>" |
| 485 | RECIPE_MAINTAINER:pn-llvm-tblgen-native = "Khem Raj <raj.khem@gmail.com>" | 485 | RECIPE_MAINTAINER:pn-llvm-tblgen-native = "Khem Raj <raj.khem@gmail.com>" |
| 486 | RECIPE_MAINTAINER:pn-llvm = "Khem Raj <raj.khem@gmail.com>" | ||
| 486 | RECIPE_MAINTAINER:pn-logrotate = "Yi Zhao <yi.zhao@windriver.com>" | 487 | RECIPE_MAINTAINER:pn-logrotate = "Yi Zhao <yi.zhao@windriver.com>" |
| 487 | RECIPE_MAINTAINER:pn-log4cplus = "Unassigned <unassigned@yoctoproject.org>" | 488 | RECIPE_MAINTAINER:pn-log4cplus = "Unassigned <unassigned@yoctoproject.org>" |
| 488 | RECIPE_MAINTAINER:pn-lrzsz = "Unassigned <unassigned@yoctoproject.org>" | 489 | RECIPE_MAINTAINER:pn-lrzsz = "Unassigned <unassigned@yoctoproject.org>" |
diff --git a/meta/recipes-devtools/clang/llvm_git.bb b/meta/recipes-devtools/clang/llvm_git.bb new file mode 100644 index 0000000000..d2b060ff88 --- /dev/null +++ b/meta/recipes-devtools/clang/llvm_git.bb | |||
| @@ -0,0 +1,129 @@ | |||
| 1 | # Copyright (C) 2017 Khem Raj <raj.khem@gmail.com> | ||
| 2 | # Released under the MIT license (see COPYING.MIT for the terms) | ||
| 3 | |||
| 4 | SUMMARY = "The LLVM Compiler Infrastructure" | ||
| 5 | HOMEPAGE = "http://llvm.org" | ||
| 6 | LICENSE = "Apache-2.0-with-LLVM-exception" | ||
| 7 | SECTION = "devel" | ||
| 8 | |||
| 9 | require common-clang.inc | ||
| 10 | require common-source.inc | ||
| 11 | |||
| 12 | LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe" | ||
| 13 | |||
| 14 | DEPENDS = "llvm-tblgen-native libffi libxml2 zlib zstd" | ||
| 15 | |||
| 16 | inherit cmake pkgconfig lib_package | ||
| 17 | |||
| 18 | OECMAKE_SOURCEPATH = "${S}/llvm" | ||
| 19 | |||
| 20 | # By default we build all the supported CPU architectures, and the GPU targets | ||
| 21 | # if the opencl, opengl or vulkan DISTRO_FEATURES are enabled. | ||
| 22 | # | ||
| 23 | # For target builds we default to building that specific architecture, BPF, and the GPU targets if required. | ||
| 24 | # | ||
| 25 | # The available target list can be seen in the source code | ||
| 26 | # in the LLVM_ALL_TARGETS assignment: | ||
| 27 | # https://github.com/llvm/llvm-project/blob/main/llvm/CMakeLists.txt | ||
| 28 | LLVM_TARGETS_GPU ?= "${@bb.utils.contains_any('DISTRO_FEATURES', 'opencl opengl vulkan', 'AMDGPU;NVPTX;SPIRV', '', d)}" | ||
| 29 | LLVM_TARGETS_TO_BUILD ?= "AArch64;ARM;BPF;Mips;PowerPC;RISCV;X86;LoongArch;${LLVM_TARGETS_GPU}" | ||
| 30 | LLVM_TARGETS_TO_BUILD:class-target ?= "${@get_clang_host_arch(bb, d)};BPF;${LLVM_TARGETS_GPU}" | ||
| 31 | |||
| 32 | LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ?= "" | ||
| 33 | |||
| 34 | HF = "" | ||
| 35 | HF:class-target = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}" | ||
| 36 | HF[vardepvalue] = "${HF}" | ||
| 37 | |||
| 38 | EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=MinSizeRel \ | ||
| 39 | -DLLVM_ENABLE_BINDINGS=OFF \ | ||
| 40 | -DLLVM_ENABLE_FFI=ON \ | ||
| 41 | -DLLVM_ENABLE_RTTI=ON \ | ||
| 42 | -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS_TO_BUILD}' \ | ||
| 43 | -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \ | ||
| 44 | -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \ | ||
| 45 | -DLLVM_VERSION_SUFFIX='${VER_SUFFIX}' \ | ||
| 46 | -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ | ||
| 47 | -DLLVM_INCLUDE_TESTS=OFF \ | ||
| 48 | -DLLVM_INCLUDE_EXAMPLES=OFF \ | ||
| 49 | -DLLVM_TOOL_OBJ2YAML_BUILD=OFF \ | ||
| 50 | -DLLVM_TOOL_YAML2OBJ_BUILD=OFF \ | ||
| 51 | -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \ | ||
| 52 | -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \ | ||
| 53 | -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake' \ | ||
| 54 | " | ||
| 55 | |||
| 56 | EXTRA_OECMAKE:append:class-target = "\ | ||
| 57 | -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_SYS}${HF} \ | ||
| 58 | -DLLVM_TARGET_ARCH=${HOST_ARCH} \ | ||
| 59 | -DLLVM_HOST_TRIPLE=${TARGET_SYS}${HF} \ | ||
| 60 | -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config \ | ||
| 61 | " | ||
| 62 | |||
| 63 | EXTRA_OECMAKE:append:class-nativesdk = "\ | ||
| 64 | -DLLVM_HOST_TRIPLE=${SDK_SYS} \ | ||
| 65 | -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config \ | ||
| 66 | " | ||
| 67 | |||
| 68 | PACKAGECONFIG ??= "eh rtti shared-libs ${@bb.utils.filter('DISTRO_FEATURES', 'lto thin-lto', d)}" | ||
| 69 | PACKAGECONFIG:remove:class-native = "lto thin-lto" | ||
| 70 | |||
| 71 | PACKAGECONFIG[eh] = "-DLLVM_ENABLE_EH=ON,-DLLVM_ENABLE_EH=OFF" | ||
| 72 | PACKAGECONFIG[exegesis] = "-DLLVM_TOOL_LLVM_EXEGESIS_BUILD=ON,-DLLVM_TOOL_LLVM_EXEGESIS_BUILD=OFF" | ||
| 73 | PACKAGECONFIG[libedit] = "-DLLVM_ENABLE_LIBEDIT=ON,-DLLVM_ENABLE_LIBEDIT=OFF,libedit" | ||
| 74 | PACKAGECONFIG[rtti] = "-DLLVM_ENABLE_RTTI=ON,-DLLVM_ENABLE_RTTI=OFF" | ||
| 75 | PACKAGECONFIG[shared-libs] = "-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON,-DLLVM_BUILD_LLVM_DYLIB=OFF -DLLVM_LINK_LLVM_DYLIB=OFF" | ||
| 76 | PACKAGECONFIG[split-dwarf] = "-DLLVM_USE_SPLIT_DWARF=ON,-DLLVM_USE_SPLIT_DWARF=OFF" | ||
| 77 | PACKAGECONFIG[opt-viewer] = "-DLLVM_TOOL_OPT_VIEWER_BUILD=ON,-DLLVM_TOOL_OPT_VIEWER_BUILD=OFF, \ | ||
| 78 | python3-pyyaml-native python3-pygments-native python3-pyyaml python3-pygments, \ | ||
| 79 | python3-pyyaml python3-pygments," | ||
| 80 | PACKAGECONFIG[lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils," | ||
| 81 | PACKAGECONFIG[thin-lto] = "-DLLVM_ENABLE_LTO=Thin -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils," | ||
| 82 | |||
| 83 | # LLVM debug symbols are very large (several gigabytes), reduce the debug level | ||
| 84 | # so they're just hundreds of megabytes. | ||
| 85 | DEBUG_LEVELFLAG = "-g1" | ||
| 86 | |||
| 87 | reproducible_build_variables() { | ||
| 88 | sed -i -e "s,${DEBUG_PREFIX_MAP},,g" \ | ||
| 89 | -e "s,--sysroot=${RECIPE_SYSROOT},,g" \ | ||
| 90 | -e "s,${STAGING_DIR_HOST},,g" \ | ||
| 91 | -e "s,${S}/llvm,,g" \ | ||
| 92 | -e "s,${B},,g" \ | ||
| 93 | ${B}/tools/llvm-config/BuildVariables.inc | ||
| 94 | } | ||
| 95 | |||
| 96 | do_configure:append:class-target() { | ||
| 97 | reproducible_build_variables | ||
| 98 | } | ||
| 99 | do_configure:append:class-nativesdk() { | ||
| 100 | reproducible_build_variables | ||
| 101 | } | ||
| 102 | |||
| 103 | do_install:append() { | ||
| 104 | # llvm hardcodes lib as install path, this corrects it to actual libdir. | ||
| 105 | # https://github.com/llvm/llvm-project/issues/152193 | ||
| 106 | if [ -d ${D}/${prefix}/lib -a ! -d ${D}/${libdir} ]; then | ||
| 107 | mv ${D}/${prefix}/lib ${D}/${libdir} | ||
| 108 | fi | ||
| 109 | |||
| 110 | # Reproducibility fixes | ||
| 111 | sed -i -e 's,${WORKDIR},,g' ${D}/${libdir}/cmake/llvm/LLVMConfig.cmake | ||
| 112 | } | ||
| 113 | |||
| 114 | do_install:append:class-native() { | ||
| 115 | # These are provided by llvm-tblgen-native | ||
| 116 | rm ${D}${bindir}/*-tblgen | ||
| 117 | } | ||
| 118 | |||
| 119 | SYSROOT_PREPROCESS_FUNCS:append:class-target = " llvm_sysroot_preprocess" | ||
| 120 | SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " llvm_sysroot_preprocess" | ||
| 121 | |||
| 122 | llvm_sysroot_preprocess() { | ||
| 123 | install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/ | ||
| 124 | install -m 0755 ${S}/llvm/tools/llvm-config/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/ | ||
| 125 | } | ||
| 126 | |||
| 127 | FILES:${PN}-dev += "${libdir}/llvm-config" | ||
| 128 | |||
| 129 | BBCLASSEXTEND = "native nativesdk" | ||
