From: sunilkumar.dora@windriver.com
To: openembedded-core@lists.openembedded.org
Cc: yoann.congal@smile.fr, alex.kanavin@gmail.com,
sundeep.kokkonda@windriver.com, Randy.MacLeod@windriver.com,
Deepesh.Varatharajan@windriver.com
Subject: [scarthgap][PATCH 1/2] rust-llvm: build and install the LLVM shared library
Date: Thu, 19 Nov 2026 19:28:45 -0800 [thread overview]
Message-ID: <20261120032846.2692732-2-sunilkumar.dora@windriver.com> (raw)
In-Reply-To: <20261120032846.2692732-1-sunilkumar.dora@windriver.com>
From: Sunil Dora <sunilkumar.dora@windriver.com>
For the rustc segfault in [YOCTO #16058] rust has to link LLVM
dynamically. On master libLLVM.so comes from the llvm recipe, rust-llvm
was dropped there [1]. scarthgap still builds LLVM for rust from this
recipe and it builds only static libs. So add the shared lib here.
Need both LLVM_BUILD_LLVM_DYLIB and LLVM_LINK_LLVM_DYLIB. With only the
first one "llvm-config --link-shared --libs" gives the per component
libs (which don't exist) instead of -lLLVM-17. llvm-config and
llvm-tblgen stay static, so the native llvm-config rust uses keeps
working. master had the same two options for rust-llvm [2] when it
still had the recipe.
LLVM installs the lib as ${libdir}/llvm-rust/lib/libLLVM-17.so. Nothing
looks there at runtime, it is not a default loader path and the RUNPATH
of the rust binaries does not point there. So move it to ${libdir} and
keep a symlink behind, the -L path from llvm-config still works at link
time.
Package it as ${PN}-libllvm. Otherwise the .so goes to ${PN}-dev by the
default rules and rust would rdepend on a -dev package. Static libs are
still installed, rust without llvm-shared is not affected.
[1] https://git.openembedded.org/openembedded-core/commit/?id=c116828a876853cd5b53f7bd4607f0037fef4ee4
[2] https://git.openembedded.org/openembedded-core/commit/?id=2b6a6d4199e4eed65f20351d077a04a7cf9da460
[YOCTO #16058]
Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com>
---
meta/recipes-devtools/rust/rust-llvm_1.75.0.bb | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-devtools/rust/rust-llvm_1.75.0.bb b/meta/recipes-devtools/rust/rust-llvm_1.75.0.bb
index cba41c739e..76335dc055 100644
--- a/meta/recipes-devtools/rust/rust-llvm_1.75.0.bb
+++ b/meta/recipes-devtools/rust/rust-llvm_1.75.0.bb
@@ -47,6 +47,8 @@ EXTRA_OECMAKE = " \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_FFI=OFF \
-DLLVM_INSTALL_UTILS=ON \
+ -DLLVM_BUILD_LLVM_DYLIB=ON \
+ -DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_BUILD_TESTS=OFF \
@@ -84,15 +86,26 @@ export YOCTO_ALTERNATE_EXE_PATH = "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config"
do_install:append () {
# we don't need any of this stuff to build Rust
rm -rf "${D}/usr/lib/cmake"
+
+ # rustc links to libLLVM (llvm-shared in rust). Nothing searches
+ # llvm-rust/lib at runtime, so move the library to ${libdir} and keep
+ # a symlink for the -L path given by llvm-config.
+ for lib in ${D}${libdir}/llvm-rust/lib*/libLLVM-*.so; do
+ [ -f "$lib" ] && [ ! -L "$lib" ] || continue
+ mv "$lib" ${D}${libdir}/
+ ln -s ../../$(basename "$lib") "$lib"
+ done
}
-PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liblto"
+PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liblto ${PN}-libllvm"
# Add the extra locations to avoid the complaints about unpackaged files
FILES:${PN}-bugpointpasses = "${libdir}/llvm-rust/lib/BugpointPasses.so"
FILES:${PN}-llvmhello = "${libdir}/llvm-rust/lib/LLVMHello.so"
FILES:${PN}-liblto = "${libdir}/llvm-rust/lib/libLTO.so.*"
+FILES:${PN}-libllvm = "${libdir}/libLLVM-*.so"
FILES:${PN}-staticdev =+ "${libdir}/llvm-rust/*/*.a"
+RDEPENDS:${PN}-dev += "${PN}-libllvm"
FILES:${PN} += "${libdir}/libLLVM*.so.* ${libdir}/llvm-rust/lib/*.so.* ${libdir}/llvm-rust/bin"
FILES:${PN}-dev += "${datadir}/llvm ${libdir}/llvm-rust/lib/*.so ${libdir}/llvm-rust/include ${libdir}/llvm-rust/share ${libdir}/llvm-rust/lib/cmake"
--
2.49.0
next prev parent reply other threads:[~2026-11-20 3:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 3:28 [scarthgap][PATCH 0/2] rust: link LLVM dynamically sunilkumar.dora
2026-11-20 3:28 ` sunilkumar.dora [this message]
2026-11-20 3:28 ` [scarthgap][PATCH 2/2] rust: enable dynamic LLVM linking by default sunilkumar.dora
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=20261120032846.2692732-2-sunilkumar.dora@windriver.com \
--to=sunilkumar.dora@windriver.com \
--cc=Deepesh.Varatharajan@windriver.com \
--cc=Randy.MacLeod@windriver.com \
--cc=alex.kanavin@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=sundeep.kokkonda@windriver.com \
--cc=yoann.congal@smile.fr \
/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