From: Vincent Davis Jr <vince@underview.tech>
To: openembedded-core@lists.openembedded.org
Cc: Vincent Davis Jr <vince@underview.tech>
Subject: [PATCH] llvm: fix native llvm-config RUNPATH
Date: Sun, 13 Nov 2022 02:44:29 -0600 [thread overview]
Message-ID: <20221113084429.329094-1-vince@underview.tech> (raw)
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 <vince@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
next reply other threads:[~2022-11-13 8:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-13 8:44 Vincent Davis Jr [this message]
2022-11-13 17:44 ` [OE-core] [PATCH] llvm: fix native llvm-config RUNPATH Alexander Kanavin
2022-11-13 19:17 ` Vincent Davis Jr
2022-11-13 21:54 ` [OE-core] " Alexander Kanavin
2022-11-13 21:55 ` Alexander Kanavin
2022-11-14 0:09 ` Vincent Davis Jr
2022-11-14 0:40 ` Vincent Davis Jr
2022-11-14 12:17 ` [OE-core] " Alexander Kanavin
[not found] ` <172772A94B18DE42.10474@lists.openembedded.org>
2022-11-14 13:36 ` Alexander Kanavin
2022-11-14 14:46 ` Vincent Davis Jr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221113084429.329094-1-vince@underview.tech \
--to=vince@underview.tech \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox