Problem occurs when native llvm-config binary is required by another recipe. RUNPATH is hardcoded to $ORIGIN/../lib:$ORIGIN/../../lib which depending upon architecture 'lib' directory name may vary (i.e 'lib64').
Commit fixes issue by updating rpath on binary to include architecture dependent directory name. Commit also fixes issue with llvm-config --libdir command by setting LLVM_LIBDIR_SUFFIX. Command will return proper architecture dependent directory name. Signed-off-by: Vincent Davis Jr <vi...@underview.tech> --- meta/recipes-devtools/llvm/llvm_git.bb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/meta/recipes-devtools/llvm/llvm_git.bb b/meta/recipes-devtools/llvm/llvm_git.bb index 1f47e5d0fb..29eb119be5 100644 --- a/meta/recipes-devtools/llvm/llvm_git.bb +++ b/meta/recipes-devtools/llvm/llvm_git.bb @@ -56,6 +56,14 @@ def get_llvm_arch(bb, d, arch_var): def get_llvm_host_arch(bb, d): return get_llvm_arch(bb, d, 'HOST_ARCH') +def get_llvm_libdir_suffix(bb, d): + import re + arch = d.getVar('HOST_ARCH') + if re.match(r'(x86.64)$', arch): + return 64 + else: + return "" + 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" @@ -64,6 +72,7 @@ PACKAGECONFIG[optviewer] = ",-DPY_PYGMENTS_FOUND=OFF -DPY_PYGMENTS_LEXERS_C_CPP_ # Default to build all OE-Core supported target arches (user overridable). # LLVM_TARGETS ?= "AMDGPU;${@get_llvm_host_arch(bb, d)}" +LLVM_TARGET_LIBDIR_SUFFIX ?= "${@get_llvm_libdir_suffix(bb, d)}" ARM_INSTRUCTION_SET:armv5 = "arm" ARM_INSTRUCTION_SET:armv4t = "arm" @@ -83,6 +92,10 @@ EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ -DCMAKE_BUILD_TYPE=Release \ -G Ninja" +EXTRA_OECMAKE:append:class-native = "\ + -DLLVM_LIBDIR_SUFFIX=${LLVM_TARGET_LIBDIR_SUFFIX} \ + " + EXTRA_OECMAKE:append:class-target = "\ -DCMAKE_CROSSCOMPILING:BOOL=ON \ -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \ @@ -129,6 +142,7 @@ do_install:class-native() { } SYSROOT_PREPROCESS_FUNCS:append:class-target = " llvm_sysroot_preprocess" +SYSROOT_PREPROCESS_FUNCS:append:class-native = " llvm_sysroot_preprocess_native" llvm_sysroot_preprocess() { install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/ @@ -136,6 +150,18 @@ llvm_sysroot_preprocess() { ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV} } +# All of LLVM's shipping binaries have an rpath pointing at ``$ORIGIN/../lib``. +# Recipe llvm requires llvm-native to compile. When compiling llvm build libraries +# are located in $ORIGIN/../lib directory. When the llvm-config binary required +# in another recipe depending upon HOST_ARCH variable libraries may be located +# in a different directory. Account for both situations here. +llvm_sysroot_preprocess_native() { + chrpath --replace '$ORIGIN'/../lib${LLVM_TARGET_LIBDIR_SUFFIX}:'$ORIGIN'/../../lib${LLVM_TARGET_LIBDIR_SUFFIX}:'$ORIGIN'/../lib:'$ORIGIN'/../../lib \ + ${SYSROOT_DESTDIR}${bindir}/llvm-tblgen${PV} + chrpath --replace '$ORIGIN'/../lib${LLVM_TARGET_LIBDIR_SUFFIX}:'$ORIGIN'/../../lib${LLVM_TARGET_LIBDIR_SUFFIX}:'$ORIGIN'/../lib:'$ORIGIN'/../../lib \ + ${SYSROOT_DESTDIR}${bindir}/llvm-config${PV} +} + PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto" RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks" -- 2.34.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#173187): https://lists.openembedded.org/g/openembedded-core/message/173187 Mute This Topic: https://lists.openembedded.org/mt/94995332/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-