clang: improve opt-viewer PACKAGECONFIG
PATCH v2 1/6 clang: improve opt-viewer PACKAGECONFIG
Instead of patching the python module detection, we can use the hidden option LLVM_TOOL_OPT_VIEWER_BUILD.
--- ...-users-to-set-LLVM_HAVE_OPT_VIEWER_M.patch | 70 ------------------- meta/recipes-devtools/clang/clang_git.bb | 2 +- meta/recipes-devtools/clang/common.inc | 1 - 3 files changed, 1 insertion(+), 72 deletions(-) delete mode 100644 meta/recipes-devtools/clang/clang/0041-opt-viewer-Allow-users-to-set-LLVM_HAVE_OPT_VIEWER_M.patch
meta/recipes-devtools/clang/clang/0041-opt-viewer-Allow-users-to-set-LLVM_HAVE_OPT_VIEWER_M.patch deleted +0 -70
@@ -1,70 +0,0 @@ -From 93a51605fccf0f99868f8bae212a08823d01b03a Mon Sep 17 00:00:00 2001 -From: Khem Raj <[email protected]> -Date: Sat, 2 Aug 2025 17:58:20 -0700 -Subject: [PATCH] [opt-viewer] Allow users to set LLVM_HAVE_OPT_VIEWER_MODULES - manually from the CMake - -Check right before setting LLVM_HAVE_OPT_VIEWER_MODULES -so that if the user specifies the variable on the commandline -it takes precedence. If not, fall back to the old logic - -Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/151845] -Signed-off-by: Khem Raj <[email protected]> ---- - llvm/CMakeLists.txt | 2 ++ - llvm/cmake/config-ix.cmake | 13 ++++++++++--- - llvm/include/llvm/Config/config.h.cmake | 3 +++ - 3 files changed, 15 insertions(+), 3 deletions(-) - -diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt -index cb945b578e46..e4ed9eca6014 100644 ---- a/llvm/CMakeLists.txt -+++ b/llvm/CMakeLists.txt -@@ -7,6 +7,8 @@ set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) - include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake - NO_POLICY_SCOPE) - -+option(LLVM_HAVE_OPT_VIEWER_MODULES "Enable opt-viewer modules support" ON) -+ - # Builds with custom install names and installation rpath setups may not work - # in the build tree. Allow these cases to use CMake's default build tree - # behavior by setting `LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE` to do this. -diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake -index a8e4e5a63244..17af3dc1e93f 100644 ---- a/llvm/cmake/config-ix.cmake -+++ b/llvm/cmake/config-ix.cmake -@@ -805,10 +805,17 @@ foreach(module ${PYTHON_MODULES}) - find_python_module(${module}) - endforeach() - --if(PY_PYGMENTS_FOUND AND PY_PYGMENTS_LEXERS_C_CPP_FOUND AND PY_YAML_FOUND) -- set (LLVM_HAVE_OPT_VIEWER_MODULES 1) -+if(NOT DEFINED LLVM_HAVE_OPT_VIEWER_MODULES) -+ if(PY_PYGMENTS_FOUND AND PY_PYGMENTS_LEXERS_C_CPP_FOUND AND PY_YAML_FOUND) -+ set (LLVM_HAVE_OPT_VIEWER_MODULES 1) -+ else() -+ set (LLVM_HAVE_OPT_VIEWER_MODULES 0) -+ endif() -+elseif(LLVM_HAVE_OPT_VIEWER_MODULES) -+ # Use the user-provided value -+ set(LLVM_HAVE_OPT_VIEWER_MODULES 1) - else() -- set (LLVM_HAVE_OPT_VIEWER_MODULES 0) -+ set(LLVM_HAVE_OPT_VIEWER_MODULES 0) - endif() - - function(llvm_get_host_prefixes_and_suffixes) -diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake -index ce83de8e4cba..02cf6d2ec363 100644 ---- a/llvm/include/llvm/Config/config.h.cmake -+++ b/llvm/include/llvm/Config/config.h.cmake -@@ -287,6 +287,9 @@ - /* Define to a function implementing strdup */ - #cmakedefine strdup ${strdup} - -+/* Define indicating opt-viewer modules */ -+#cmakedefine LLVM_HAVE_OPT_VIEWER_MODULES -+ - /* Whether GlobalISel rule coverage is being collected */ - #cmakedefine01 LLVM_GISEL_COV_ENABLED -
meta/recipes-devtools/clang/clang_git.bb +1 -1
@@ -59,7 +59,7 @@ PACKAGECONFIG[libedit] = "-DLLVM_ENABLE_LIBEDIT=ON,-DLLVM_ENABLE_LIBEDIT=OFF,lib PACKAGECONFIG[libomp] = "-DCLANG_DEFAULT_OPENMP_RUNTIME=libomp,," PACKAGECONFIG[lld] = "-DCLANG_DEFAULT_LINKER=lld,,," PACKAGECONFIG[lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils," -PACKAGECONFIG[opt-viewer] = "-DLLVM_HAVE_OPT_VIEWER_MODULES=ON,-DLLVM_HAVE_OPT_VIEWER_MODULES=OFF, \ +PACKAGECONFIG[opt-viewer] = "-DLLVM_TOOL_OPT_VIEWER_BUILD=ON,-DLLVM_TOOL_OPT_VIEWER_BUILD=OFF, \ python3-pyyaml-native python3-pygments-native python3-pyyaml python3-pygments, \ python3-pyyaml python3-pygments," PACKAGECONFIG[pfm] = "-DLLVM_ENABLE_LIBPFM=ON,-DLLVM_ENABLE_LIBPFM=OFF,libpfm,"
meta/recipes-devtools/clang/common.inc +0 -1
@@ -61,7 +61,6 @@ SRC_URI = "\ file://0038-Revert-libc-Remap-headers-in-the-debug-info-when-bui.patch \ file://0039-Prevent-revisiting-block-when-searching-for-noreturn.patch \ file://0040-Only-build-c-index-test-when-clang-tests-are-include.patch \ - file://0041-opt-viewer-Allow-users-to-set-LLVM_HAVE_OPT_VIEWER_M.patch \ " # Fallback to no-PIE if not set GCCPIE ??= ""
Signature · 1 line
2.43.0
PATCH v2 2/6 clang: disable all test targets
We don't install the tests, or run them in the build tree, so tell cmake not to generate the targets at all. This removes internal dependencies which means we can turn off more components that we don't want.
--- meta/recipes-devtools/clang/clang_git.bb | 1 + 1 file changed, 1 insertion(+)
meta/recipes-devtools/clang/clang_git.bb +1 -0
@@ -120,6 +120,7 @@ EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \ -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \ -DLLVM_HEADERS_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-min-tblgen \ + -DLLVM_INCLUDE_TESTS=OFF \ " EXTRA_OECMAKE:append:class-nativesdk = "\
Signature · 1 line
2.43.0
PATCH v2 3/6 clang: add option for llvm-exegesis
In reply to Ross BurtonQuoting from the README:
llvm-exegesis is a benchmarking tool that accepts or generates snippets and can measure characteristics of those snippets by executing it while keeping track of performance counters.
Potentially useful but not essential. This reduces the size of llvm-bin by ~30MB and llvm-dbg by ~1100MB.
--- meta/recipes-devtools/clang/clang_git.bb | 1 + 1 file changed, 1 insertion(+)
meta/recipes-devtools/clang/clang_git.bb +1 -0
@@ -54,6 +54,7 @@ PACKAGECONFIG[clangd-dexp] = "-DCLANGD_BUILD_DEXP=ON,-DCLANGD_BUILD_DEXP=OFF,," PACKAGECONFIG[compiler-rt] = "-DCLANG_DEFAULT_RTLIB=compiler-rt,," PACKAGECONFIG[eh] = "-DLLVM_ENABLE_EH=ON,-DLLVM_ENABLE_EH=OFF,," +PACKAGECONFIG[exegesis] = "-DLLVM_TOOL_LLVM_EXEGESIS_BUILD=ON,-DLLVM_TOOL_LLVM_EXEGESIS_BUILD=OFF" PACKAGECONFIG[libcplusplus] = "-DCLANG_DEFAULT_CXX_STDLIB=libc++,," PACKAGECONFIG[libedit] = "-DLLVM_ENABLE_LIBEDIT=ON,-DLLVM_ENABLE_LIBEDIT=OFF,libedit libedit-native" PACKAGECONFIG[libomp] = "-DCLANG_DEFAULT_OPENMP_RUNTIME=libomp,,"
Signature · 1 line
2.43.0
PATCH v2 4/6 clang: remove obsolete install steps
In reply to Ross Burtonclang-pseudo and clang-rename have both been removed from upstream, so don't try to install them anymore:
llvm 40c45b6b4318 ("Remove clang-rename (#108988)") llvm ed8f78827895 ("Remove clang-pseudo (#109154)")
--- meta/recipes-devtools/clang/clang_git.bb | 6 ------ 1 file changed, 6 deletions(-)
meta/recipes-devtools/clang/clang_git.bb +0 -6
@@ -168,12 +168,6 @@ do_configure:append:class-nativesdk() { } do_install:append() { - for t in clang-pseudo clang-pseudo-gen clang-rename; do - if [ -e ${B}${BINPATHPREFIX}/bin/$t ]; then - install -Dm 0755 ${B}${BINPATHPREFIX}/bin/$t ${D}${bindir}/$t - fi - done - oe_multilib_header llvm/Config/llvm-config.h oe_multilib_header clang/Config/config.h }
Signature · 1 line
2.43.0
PATCH v2 5/6 llvm: add recipe for just the LLVM libraries
In reply to Ross BurtonWhilst 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.
--- meta/conf/distro/include/maintainers.inc | 1 + meta/recipes-devtools/clang/llvm_git.bb | 132 +++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 meta/recipes-devtools/clang/llvm_git.bb
meta/conf/distro/include/maintainers.inc +1 -0
@@ -483,6 +483,7 @@ RECIPE_MAINTAINER:pn-lld = "Khem Raj <[email protected]>" RECIPE_MAINTAINER:pn-lldb = "Khem Raj <[email protected]>" RECIPE_MAINTAINER:pn-llvm-project-source-21.1.0 = "Khem Raj <[email protected]>" RECIPE_MAINTAINER:pn-llvm-tblgen-native = "Khem Raj <[email protected]>" +RECIPE_MAINTAINER:pn-llvm = "Khem Raj <[email protected]>" RECIPE_MAINTAINER:pn-logrotate = "Yi Zhao <[email protected]>" RECIPE_MAINTAINER:pn-log4cplus = "Unassigned <[email protected]>" RECIPE_MAINTAINER:pn-lrzsz = "Anuj Mittal <[email protected]>"
meta/recipes-devtools/clang/llvm_git.bb new file +132 -0
132 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 6/6 clang: use llvm recipe
In reply to Ross BurtonChange this recipe to build just clang and clang-tools-extra, using the LLVM provided by the llvm recipe.
This adds an 'extra-tools' PACKAGECONFIG (enabled by default) that controls whether to build the clang-tools-extra project. This includes clang-tidy and clangd, but the compile time and size for these components is not insignificant.
--- meta/recipes-devtools/clang/clang_git.bb | 165 ++++------------------- 1 file changed, 24 insertions(+), 141 deletions(-)
meta/recipes-devtools/clang/clang_git.bb +24 -141
@@ -19,7 +19,7 @@ require common-source.inc BPN = "clang" -CVE_PRODUCT += "llvm:clang" +CVE_PRODUCT = "llvm:clang" INHIBIT_DEFAULT_DEPS:class-native = "1"
@@ -28,72 +28,31 @@ LDFLAGS:append:class-target:mips = " -Wl,--no-as-needed -latomic -Wl,--as-needed inherit cmake pkgconfig multilib_header python3-dir -PACKAGECONFIG_CLANG_COMMON = "build-id eh libedit rtti shared-libs libclang-python \ - ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', 'lld', '', d)} \ - ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcplusplus libomp unwindlib', '', d)} \ - " - -PACKAGECONFIG ??= "${PACKAGECONFIG_CLANG_COMMON} \ +PACKAGECONFIG ??= "build-id extra-tools clangd libclang-python \ ${@bb.utils.filter('DISTRO_FEATURES', 'lto thin-lto', d)} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', 'lld', '', d)} \ + ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcplusplus libomp unwindlib', '', d)} \ " -PACKAGECONFIG:class-native = "clangd \ - ${PACKAGECONFIG_CLANG_COMMON} \ - " -PACKAGECONFIG:class-nativesdk = "clangd \ - ${PACKAGECONFIG_CLANG_COMMON} \ - ${@bb.utils.filter('DISTRO_FEATURES', 'lto thin-lto', d)} \ - " +PACKAGECONFIG:remove:class-native = "lto thin-lto" PACKAGECONFIG[build-id] = "-DENABLE_LINKER_BUILD_ID=ON,-DENABLE_LINKER_BUILD_ID=OFF,," PACKAGECONFIG[clangd] = "-DCLANG_ENABLE_CLANGD=ON,-DCLANG_ENABLE_CLANGD=OFF,," - # Activate to build the dexp tool in clangd # Disabled by default for -native since it is known to trigger compiler failure on Debian 11 # See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15803 PACKAGECONFIG[clangd-dexp] = "-DCLANGD_BUILD_DEXP=ON,-DCLANGD_BUILD_DEXP=OFF,," - PACKAGECONFIG[compiler-rt] = "-DCLANG_DEFAULT_RTLIB=compiler-rt,," -PACKAGECONFIG[eh] = "-DLLVM_ENABLE_EH=ON,-DLLVM_ENABLE_EH=OFF,," -PACKAGECONFIG[exegesis] = "-DLLVM_TOOL_LLVM_EXEGESIS_BUILD=ON,-DLLVM_TOOL_LLVM_EXEGESIS_BUILD=OFF" +PACKAGECONFIG[extra-tools] = "-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=${S}/clang-tools-extra" PACKAGECONFIG[libcplusplus] = "-DCLANG_DEFAULT_CXX_STDLIB=libc++,," -PACKAGECONFIG[libedit] = "-DLLVM_ENABLE_LIBEDIT=ON,-DLLVM_ENABLE_LIBEDIT=OFF,libedit libedit-native" PACKAGECONFIG[libomp] = "-DCLANG_DEFAULT_OPENMP_RUNTIME=libomp,," PACKAGECONFIG[lld] = "-DCLANG_DEFAULT_LINKER=lld,,," PACKAGECONFIG[lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils," -PACKAGECONFIG[opt-viewer] = "-DLLVM_TOOL_OPT_VIEWER_BUILD=ON,-DLLVM_TOOL_OPT_VIEWER_BUILD=OFF, \ - python3-pyyaml-native python3-pygments-native python3-pyyaml python3-pygments, \ - python3-pyyaml python3-pygments," -PACKAGECONFIG[pfm] = "-DLLVM_ENABLE_LIBPFM=ON,-DLLVM_ENABLE_LIBPFM=OFF,libpfm," -PACKAGECONFIG[rtti] = "-DLLVM_ENABLE_RTTI=ON,-DLLVM_ENABLE_RTTI=OFF,," -PACKAGECONFIG[shared-libs] = "-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON,,," -PACKAGECONFIG[split-dwarf] = "-DLLVM_USE_SPLIT_DWARF=ON,-DLLVM_USE_SPLIT_DWARF=OFF,," PACKAGECONFIG[thin-lto] = "-DLLVM_ENABLE_LTO=Thin -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils," PACKAGECONFIG[unwindlib] = "-DCLANG_DEFAULT_UNWINDLIB=libunwind,-DCLANG_DEFAULT_UNWINDLIB=libgcc,," PACKAGECONFIG[libclang-python] = "-DCLANG_PYTHON_BINDINGS_VERSIONS=${PYTHON_BASEVERSION},," -OECMAKE_SOURCEPATH = "${S}/llvm" +OECMAKE_SOURCEPATH = "${S}/clang" -# By default we build all the supported CPU architectures, and the GPU targets -# if the opengl or vulkan DISTRO_FEATURES are enabled. -# -# For target builds we default to building that specific architecture, BPF, and the GPU targets if required. -# -# The available target list can be seen in the source code -# in the LLVM_ALL_TARGETS assignment: -# https://github.com/llvm/llvm-project/blob/main/llvm/CMakeLists.txt -LLVM_TARGETS_GPU ?= "${@bb.utils.contains_any('DISTRO_FEATURES', 'opengl vulkan', 'AMDGPU;NVPTX;SPIRV', '', d)}" -LLVM_TARGETS_TO_BUILD ?= "AArch64;ARM;BPF;Mips;PowerPC;RISCV;X86;LoongArch;${LLVM_TARGETS_GPU}" -LLVM_TARGETS_TO_BUILD:class-target ?= "${@get_clang_host_arch(bb, d)};BPF;${LLVM_TARGETS_GPU}" - -LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ?= "" - -HF = "" -HF:class-target = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}" -HF[vardepvalue] = "${HF}" - -# Ensure that LLVM_PROJECTS does not contain compiler runtime components e.g. libcxx etc -# they are enabled via LLVM_ENABLE_RUNTIMES -LLVM_PROJECTS ?= "clang;clang-tools-extra" # linux hosts (.so) on Windows .pyd SOLIBSDEV:mingw32 = ".pyd"
@@ -102,25 +61,18 @@ SOLIBSDEV:mingw32 = ".pyd" EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ -DLLVM_APPEND_VC_REV=OFF \ - -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \ -DLLVM_ENABLE_PIC=ON \ -DCLANG_DEFAULT_PIE_ON_LINUX=ON \ - -DLLVM_BINDINGS_LIST='' \ - -DLLVM_ENABLE_FFI=ON \ - -DLLVM_ENABLE_ZSTD=ON \ -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \ -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON \ -DCMAKE_SYSTEM_NAME=Linux \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_PROJECTS='${LLVM_PROJECTS}' \ - -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR} \ -DLLVM_VERSION_SUFFIX='${VER_SUFFIX}' \ - -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ - -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS_TO_BUILD}' \ - -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \ - -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \ - -DLLVM_HEADERS_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-min-tblgen \ + -DLLVM_CMAKE_DIR=${STAGING_LIBDIR}/cmake/llvm \ -DLLVM_INCLUDE_TESTS=OFF \ "
@@ -132,58 +84,27 @@ EXTRA_OECMAKE:append:class-nativesdk = "\ -DCMAKE_STRIP=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-strip \ " EXTRA_OECMAKE:append:class-target = "\ + -DLLVM_NATIVE_TOOL_DIR=${STAGING_BINDIR_NATIVE} \ + -DLLVM_TABLEGEN_EXE=${STAGING_BINDIR_NATIVE}/llvm-tblgen \ -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \ -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \ -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \ -DCMAKE_STRIP=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-strip \ - -DLLVM_TARGET_ARCH=${HOST_ARCH} \ - -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_SYS}${HF} \ - -DLLVM_HOST_TRIPLE=${TARGET_SYS}${HF} \ -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} \ " -DEPENDS = "binutils zlib zstd libffi libxml2 libxml2-native llvm-tblgen-native" +DEPENDS = "llvm-tblgen-native llvm binutils zlib zstd libffi libxml2 libxml2-native" DEPENDS:append:class-nativesdk = " clang-crosssdk-${SDK_SYS} virtual/nativesdk-cross-binutils" DEPENDS:append:class-target = " ${MLPREFIX}clang-cross-${TARGET_ARCH} ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcxx', '', d)}" RDEPENDS:${PN}:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', ' lld', '', d)}" RRECOMMENDS:${PN}:append:class-target = "binutils ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', ' libcxx-dev', '', d)}" -# patch out build host paths for reproducibility -reproducible_build_variables() { - sed -i -e "s,${DEBUG_PREFIX_MAP},,g" \ - -e "s,--sysroot=${RECIPE_SYSROOT},,g" \ - -e "s,${STAGING_DIR_HOST},,g" \ - -e "s,${S}/llvm,,g" \ - -e "s,${B},,g" \ - ${B}/tools/llvm-config/BuildVariables.inc -} - -do_configure:append:class-target() { - reproducible_build_variables -} - -do_configure:append:class-nativesdk() { - reproducible_build_variables -} - do_install:append() { - oe_multilib_header llvm/Config/llvm-config.h oe_multilib_header clang/Config/config.h } do_install:append:class-target () { - # Allow bin path to change based on YOCTO_ALTERNATE_EXE_PATH - sed -i 's;${_IMPORT_PREFIX}/bin;${_IMPORT_PREFIX_BIN};g' ${D}${libdir}/cmake/llvm/LLVMExports-release.cmake - - # Insert function to populate Import Variables - sed -i "4i\ -if(DEFINED ENV{YOCTO_ALTERNATE_EXE_PATH})\n\ - execute_process(COMMAND \"llvm-config\" \"--bindir\" OUTPUT_VARIABLE _IMPORT_PREFIX_BIN OUTPUT_STRIP_TRAILING_WHITESPACE)\n\ -else()\n\ - set(_IMPORT_PREFIX_BIN \"\${_IMPORT_PREFIX}/bin\")\n\ -endif()\n" ${D}${libdir}/cmake/llvm/LLVMExports-release.cmake - if [ -n "${LLVM_LIBDIR_SUFFIX}" ]; then mkdir -p ${D}${nonarch_libdir} mv ${D}${libdir}/clang ${D}${nonarch_libdir}/clang
@@ -194,44 +115,18 @@ endif()\n" ${D}${libdir}/cmake/llvm/LLVMExports-release.cmake llvm-addr2line llvm-dwp llvm-size llvm-strings llvm-cov; do ln -sf $t ${D}${bindir}/${TARGET_PREFIX}$t done - - # reproducibility - sed -i -e 's,${B},,g' ${D}${libdir}/cmake/llvm/LLVMConfig.cmake } do_install:append:class-native () { - if ${@bb.utils.contains('PACKAGECONFIG', 'clangd', 'true', 'false', d)}; then - install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clangd-indexer ${D}${bindir}/clangd-indexer + if ${@bb.utils.contains('PACKAGECONFIG', 'extra-tools', 'true', 'false', d)}; then + install -Dm 0755 ${B}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen fi - install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen - - for f in `find ${D}${bindir} -executable -type f -not -type l`; do - test -n "`file -b $f|grep -i ELF`" && ${STRIP} $f - echo "stripped $f" - done - ln -sf llvm-config ${D}${bindir}/llvm-config${PV} - - # These are provided by llvm-tblgen-native - rm ${D}${bindir}/*-tblgen } do_install:append:class-nativesdk () { if [ -e ${D}${libdir}/cmake/llvm/LLVMConfig.cmake ] ; then sed -i -e "s|${B}/./bin/||g" ${D}${libdir}/cmake/llvm/LLVMConfig.cmake fi - if ${@bb.utils.contains('PACKAGECONFIG', 'clangd', 'true', 'false', d)}; then - install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clangd-indexer ${D}${bindir}/clangd-indexer - fi - install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tblgen ${D}${bindir}/clang-tblgen - install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen - for f in `find ${D}${bindir} -executable -type f -not -type l`; do - test -n "`file -b $f|grep -i ELF`" && ${STRIP} $f - done - ln -sf clang-tblgen ${D}${bindir}/clang-tblgen${PV} - ln -sf llvm-tblgen ${D}${bindir}/llvm-tblgen${PV} - ln -sf llvm-config ${D}${bindir}/llvm-config${PV} - rm -rf ${D}${datadir}/llvm/cmake - rm -rf ${D}${datadir}/llvm #reproducibility if [ -e ${D}${libdir}/cmake/llvm/LLVMConfig.cmake ] ; then
@@ -239,12 +134,7 @@ do_install:append:class-nativesdk () { fi } -PROVIDES:append:class-native = " llvm-native" -PROVIDES:append:class-target = " llvm" -PROVIDES:append:class-nativesdk = " nativesdk-llvm" - -PACKAGES =+ "${PN}-libllvm ${PN}-libclang-python ${PN}-libclang-cpp ${PN}-tidy ${PN}-format ${PN}-tools \ - libclang llvm-linker-tools" +PACKAGES =+ "${PN}-libclang-python ${PN}-libclang-cpp ${PN}-tidy ${PN}-format ${PN}-tools libclang" BBCLASSEXTEND = "native nativesdk"
@@ -262,8 +152,6 @@ RDEPENDS:${PN}-tools += "\ RRECOMMENDS:${PN}-tidy += "${PN}-tools" -FILES:llvm-linker-tools = "${libdir}/LLVMgold* ${libdir}/libLTO.so.* ${libdir}/LLVMPolly*" - FILES:${PN}-libclang-cpp = "${libdir}/libclang-cpp.so.*" FILES:${PN}-libclang-python = "${PYTHON_SITEPACKAGES_DIR}/clang/*"
@@ -326,12 +214,6 @@ FILES:${PN} += "\ ${nonarch_libdir}/${BPN}/*/include/ \ " -FILES:${PN}-libllvm =+ "\ - ${libdir}/libLLVM.so.${MAJOR_VER}.${MINOR_VER} \ - ${libdir}/libLLVM-${MAJOR_VER}.so \ - ${libdir}/libRemarks.so.* \ -" - FILES:libclang = "\ ${libdir}/libclang.so.* \ "
@@ -352,7 +234,6 @@ FILES:${PN}:remove = "${libdir}/${BPN}/*" INSANE_SKIP:${PN} += "already-stripped" #INSANE_SKIP:${PN}-dev += "dev-elf" -INSANE_SKIP:${PN}-libllvm = "dev-so" #Avoid SSTATE_SCAN_COMMAND running sed over llvm-config. SSTATE_SCAN_FILES:remove = "*-config"
@@ -366,15 +247,17 @@ SYSROOT_PREPROCESS_FUNCS:append:class-target = " clang_sysroot_preprocess" SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " clang_sysroot_preprocess" clang_sysroot_preprocess() { - install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/ - install -m 0755 ${S}/llvm/tools/llvm-config/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/ - ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV} + install -d ${SYSROOT_DESTDIR}${bindir}/ binaries="diagtool clang-${MAJOR_VER} clang-format clang-offload-packager clang-offload-bundler clang-scan-deps clang-repl - clang-refactor clang-check clang-extdef-mapping clang-apply-replacements - clang-reorder-fields clang-tidy clang-change-namespace clang-doc clang-include-fixer - find-all-symbols clang-move clang-query pp-trace modularize" + clang-refactor clang-check clang-extdef-mapping" + + if ${@bb.utils.contains('PACKAGECONFIG', 'extra-tools', 'true', 'false', d)}; then + binaries="${binaries} clang-apply-replacements clang-reorder-fields + clang-tidy clang-change-namespace clang-doc clang-include-fixer + find-all-symbols clang-move clang-query pp-trace modularize" + fi if ${@bb.utils.contains('PACKAGECONFIG', 'clangd', 'true', 'false', d)}; then binaries="${binaries} clangd"
Signature · 1 line
2.43.0
Quoted 3 lines · Ross Burton via lists.openembedded.org
Instead of patching the python module detection, we can use the hidden option
LLVM_TOOL_OPT_VIEWER_BUILD.
How are these hidden options materialized ? it will be good to describe that because there is no description of LLVM_HAVE_OPT_VIEWER_BUILD
anywhere in llvm sources.
Quoted 122 lines
Signed-off-by Ross Burton <[email protected]>--- ...-users-to-set-LLVM_HAVE_OPT_VIEWER_M.patch | 70 ------------------- meta/recipes-devtools/clang/clang_git.bb | 2 +- meta/recipes-devtools/clang/common.inc | 1 - 3 files changed, 1 insertion(+), 72 deletions(-) delete mode 100644 meta/recipes-devtools/clang/clang/0041-opt-viewer-Allow-users-to-set-LLVM_HAVE_OPT_VIEWER_M.patchmeta/recipes-devtools/clang/clang/0041-opt-viewer-Allow-users-to-set-LLVM_HAVE_OPT_VIEWER_M.patch deleted +0
-70@@ -1,70 +0,0 @@ -From 93a51605fccf0f99868f8bae212a08823d01b03a Mon Sep 17 00:00:00 2001 -From: Khem Raj <[email protected]> -Date: Sat, 2 Aug 2025 17:58:20 -0700 -Subject: [PATCH] [opt-viewer] Allow users to set LLVM_HAVE_OPT_VIEWER_MODULES - manually from the CMake - -Check right before setting LLVM_HAVE_OPT_VIEWER_MODULES -so that if the user specifies the variable on the commandline -it takes precedence. If not, fall back to the old logic - -Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/151845] -Signed-off-by: Khem Raj <[email protected]> ---- - llvm/CMakeLists.txt | 2 ++ - llvm/cmake/config-ix.cmake | 13 ++++++++++--- - llvm/include/llvm/Config/config.h.cmake | 3 +++ - 3 files changed, 15 insertions(+), 3 deletions(-) - -diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt -index cb945b578e46..e4ed9eca6014 100644 ---- a/llvm/CMakeLists.txt -+++ b/llvm/CMakeLists.txt -@@ -7,6 +7,8 @@ set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) - include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake - NO_POLICY_SCOPE) - -+option(LLVM_HAVE_OPT_VIEWER_MODULES "Enable opt-viewer modules support" ON) -+ - # Builds with custom install names and installation rpath setups may not work - # in the build tree. Allow these cases to use CMake's default build tree - # behavior by setting `LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE` to do this. -diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake -index a8e4e5a63244..17af3dc1e93f 100644 ---- a/llvm/cmake/config-ix.cmake -+++ b/llvm/cmake/config-ix.cmake -@@ -805,10 +805,17 @@ foreach(module ${PYTHON_MODULES}) - find_python_module(${module}) - endforeach() - --if(PY_PYGMENTS_FOUND AND PY_PYGMENTS_LEXERS_C_CPP_FOUND AND PY_YAML_FOUND) -- set (LLVM_HAVE_OPT_VIEWER_MODULES 1) -+if(NOT DEFINED LLVM_HAVE_OPT_VIEWER_MODULES) -+ if(PY_PYGMENTS_FOUND AND PY_PYGMENTS_LEXERS_C_CPP_FOUND AND PY_YAML_FOUND) -+ set (LLVM_HAVE_OPT_VIEWER_MODULES 1) -+ else() -+ set (LLVM_HAVE_OPT_VIEWER_MODULES 0) -+ endif() -+elseif(LLVM_HAVE_OPT_VIEWER_MODULES) -+ # Use the user-provided value -+ set(LLVM_HAVE_OPT_VIEWER_MODULES 1) - else() -- set (LLVM_HAVE_OPT_VIEWER_MODULES 0) -+ set(LLVM_HAVE_OPT_VIEWER_MODULES 0) - endif() - - function(llvm_get_host_prefixes_and_suffixes) -diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake -index ce83de8e4cba..02cf6d2ec363 100644 ---- a/llvm/include/llvm/Config/config.h.cmake -+++ b/llvm/include/llvm/Config/config.h.cmake -@@ -287,6 +287,9 @@ - /* Define to a function implementing strdup */ - #cmakedefine strdup ${strdup} - -+/* Define indicating opt-viewer modules */ -+#cmakedefine LLVM_HAVE_OPT_VIEWER_MODULES -+ - /* Whether GlobalISel rule coverage is being collected */ - #cmakedefine01 LLVM_GISEL_COV_ENABLED -meta/recipes-devtools/clang/clang_git.bb +1
-1@@ -59,7 +59,7 @@ PACKAGECONFIG[libedit] = "-DLLVM_ENABLE_LIBEDIT=ON,-DLLVM_ENABLE_LIBEDIT=OFF,lib PACKAGECONFIG[libomp] = "-DCLANG_DEFAULT_OPENMP_RUNTIME=libomp,," PACKAGECONFIG[lld] = "-DCLANG_DEFAULT_LINKER=lld,,," PACKAGECONFIG[lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils," -PACKAGECONFIG[opt-viewer] = "-DLLVM_HAVE_OPT_VIEWER_MODULES=ON,-DLLVM_HAVE_OPT_VIEWER_MODULES=OFF, \ +PACKAGECONFIG[opt-viewer] = "-DLLVM_TOOL_OPT_VIEWER_BUILD=ON,-DLLVM_TOOL_OPT_VIEWER_BUILD=OFF, \ python3-pyyaml-native python3-pygments-native python3-pyyaml python3-pygments, \ python3-pyyaml python3-pygments," PACKAGECONFIG[pfm] = "-DLLVM_ENABLE_LIBPFM=ON,-DLLVM_ENABLE_LIBPFM=OFF,libpfm,"meta/recipes-devtools/clang/common.inc +0
-2@@ -61,7 +61,6 @@ SRC_URI = "\ file://0038-Revert-libc-Remap-headers-in-the-debug-info-when-bui.patch \ file://0039-Prevent-revisiting-block-when-searching-for-noreturn.patch \ file://0040-Only-build-c-index-test-when-clang-tests-are-include.patch \ - file://0041-opt-viewer-Allow-users-to-set-LLVM_HAVE_OPT_VIEWER_M.patch \ " # Fallback to no-PIE if not set GCCPIE ??= "" --2.43.0
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#223351): https://lists.openembedded.org/g/openembedded-core/message/223351
Mute This Topic: https://lists.openembedded.org/mt/115236806/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 11 lines · Khem Raj
Quoted 3 lines · Ross Burton via lists.openembedded.org
Instead of patching the python module detection, we can use the hidden option
LLVM_TOOL_OPT_VIEWER_BUILD.How are these hidden options materialized ? it will be good to describe that because there is no description of
LLVM_HAVE_OPT_VIEWER_BUILD
anywhere in llvm sources.
Holding back my rant about the llvm build system…. all of the directories in llvm/tools/ have enable/disable options created for them, which are marked as “advanced” so they don’t even appear in the “list the options” output.
(llvm/tools/CMakeLists calls create_llvm_tool_options() which calls create_subdirectory_options() with LLVM and TOOL which creates options for each directory it finds).
Ross
Quoted 9 lines · Ross Burton
Quoted 7 lines · Khem Raj
Quoted 3 lines · Ross Burton via lists.openembedded.org
Instead of patching the python module detection, we can use the hidden option
LLVM_TOOL_OPT_VIEWER_BUILD.
Quoted 8 lines
Quoted 4 lines
How are these hidden options materialized ? it will be good to describe that because there is no description of
LLVM_HAVE_OPT_VIEWER_BUILD
anywhere in llvm sources.Holding back my rant about the llvm build system…. all of the directories in llvm/tools/ have enable/disable options created for them, which are marked as “advanced” so they don’t even appear in the “list the options” output.
(llvm/tools/CMakeLists calls
create_llvm_tool_options()which callscreate_subdirectory_options()with LLVM and TOOL which creates options for each directory it finds).
Right. A note for this would be good to have in commit or sources to remind us in future when we forget.
Quoted 2 lines
Ross
Quoted 5 lines · Ross Burton via lists.openembedded.org
Instead of patching the python module detection, we can use the hidden option
LLVM_TOOL_OPT_VIEWER_BUILD.Signed-off-by Ross Burton <[email protected]>---
Ho Ross,
I just launched a reproducibility test build. It did not crash, but we still got some issues:
AssertionError: The following deb packages are different and not in exclusion list:/srv/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB-extended/tmp/deploy/deb/./x86-64-v3/clang-dbg_21.1.1-r0_amd64.deb /srv/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB-extended/tmp/deploy/deb/./x86-64-v3/clang-format_21.1.1-r0_amd64.deb /srv/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB-extended/tmp/deploy/deb/./x86-64-v3/clang-tidy_21.1.1-r0_amd64.deb /srv/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB-extended/tmp/deploy/deb/./x86-64-v3/clang-tools_21.1.1-r0_amd64.deb /srv/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB-extended/tmp/deploy/deb/./x86-64-v3/clang_21.1.1-r0_amd64.deb /srv/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB-extended/tmp/deploy/deb/./x86-64-v3/libclang-cpp21.1_21.1.1-r0_amd64.deb /srv/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleB-extended/tmp/deploy/deb/./x86-64-v3/libclang21.1_21.1.1-r0_amd64.deb
...
(same with ipk and rpm)
https://autobuilder.yoctoproject.org/valkyrie/#/builders/37/builds/2497
http://valkyrie.yocto.io/pub/repro-fail/oe-reproducible-20250914-yhzvpnom/packages/diff-html/
Thanks,
Mathieu
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com