* [PATCH] rust: enable dynamic LLVM linking by default
@ 2026-03-13 16:01 sunilkumar.dora
2026-03-16 16:44 ` Randy MacLeod
0 siblings, 1 reply; 3+ messages in thread
From: sunilkumar.dora @ 2026-03-13 16:01 UTC (permalink / raw)
To: openembedded-core; +Cc: Randy.MacLeod, alex, Sundeep.Kokkonda, sunilkumar.dora
From: Sunil Dora <sunilkumar.dora@windriver.com>
Fixes [YOCTO #16058]
Enable dynamic linking with LLVM (link-shared) for all rust variants
(native, nativesdk and target) via a PACKAGECONFIG option, enabled
by default. This prevents segmentation faults when reusing sstate
artifacts built with different host toolchains.
Update multilib library symlinking to include shared libraries and
adjust the rust selftest to install llvm so the dynamically linked
compiler can run correctly.
Suggested-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com>
---
meta/lib/oeqa/selftest/cases/rust.py | 2 +-
meta/recipes-devtools/rust/rust_1.94.0.bb | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/meta/lib/oeqa/selftest/cases/rust.py b/meta/lib/oeqa/selftest/cases/rust.py
index 3ae1946e43..7614941661 100644
--- a/meta/lib/oeqa/selftest/cases/rust.py
+++ b/meta/lib/oeqa/selftest/cases/rust.py
@@ -47,7 +47,7 @@ class RustSelfTestSystemEmulated(OESelftestTestCase, OEPTestResultTestCase):
bitbake("{} -c test_compile".format(recipe))
builddir = get_bb_var("RUSTSRC", "rust")
# build core-image-minimal with required packages
- default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp", "libzstd", "openssl"]
+ default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp", "libzstd", "llvm", "openssl"]
features = []
features.append('IMAGE_FEATURES += "ssh-server-dropbear"')
features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
diff --git a/meta/recipes-devtools/rust/rust_1.94.0.bb b/meta/recipes-devtools/rust/rust_1.94.0.bb
index 2be0bd8d89..0d34a312c0 100644
--- a/meta/recipes-devtools/rust/rust_1.94.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.94.0.bb
@@ -15,6 +15,9 @@ DEPENDS:append:class-nativesdk = " cargo-native rust-native"
RDEPENDS:${PN}:append:class-target = " gcc g++ binutils"
+PACKAGECONFIG ??= "llvm-shared"
+PACKAGECONFIG[llvm-shared] = ",,,"
+
# Otherwise we'll depend on what we provide
INHIBIT_DEFAULT_RUST_DEPS:class-native = "1"
# We don't need to depend on gcc-native because yocto assumes it exists
@@ -124,8 +127,7 @@ python do_configure() {
# [llvm]
config.add_section("llvm")
- if d.getVar('PN') == "rust-native":
- config.set("llvm", "link-shared", e(True))
+ config.set("llvm", "link-shared", e(bb.utils.contains('PACKAGECONFIG', 'llvm-shared', True, False, d)))
config.set("llvm", "static-libstdcpp", e(False))
config.set("llvm", "download-ci-llvm", e(False))
if "llvm" in (d.getVar('TC_CXX_RUNTIME') or ""):
@@ -190,7 +192,7 @@ python do_configure() {
bb.build.exec_func("setup_cargo_environment", d)
}
-# llvm-config expects static libraries to be in the 'lib' directory rather than 'lib64' when
+# llvm-config expects static/dynamic libraries to be in the 'lib' directory rather than 'lib64' when
# multilibs enabled. Since we are copying the natively built llvm-config into the target sysroot
# and executing it there, it will default to searching in 'lib', as it is unaware of the 'lib64'
# directory. To ensure llvm-config can locate the necessary libraries, create a symlink from 'lib'
@@ -207,7 +209,7 @@ do_compile:append:class-target() {
# Only do per-file symlinking if lib is a real directory (not symlink)
if [ -d "$lib_dir" ] && [ ! -L "$lib_dir" ]; then
- for lib64_file in "${lib64_dir}"/libLLVM*.a; do
+ for lib64_file in "${lib64_dir}"/libLLVM*.a "${lib64_dir}"/libLLVM*.so*; do
if [ -e "$lib64_file" ]; then
lib_name=$(basename "${lib64_file}")
target_link="${lib_dir}/${lib_name}"
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] rust: enable dynamic LLVM linking by default
2026-03-13 16:01 [PATCH] rust: enable dynamic LLVM linking by default sunilkumar.dora
@ 2026-03-16 16:44 ` Randy MacLeod
2026-03-16 16:49 ` Dora, Sunil Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Randy MacLeod @ 2026-03-16 16:44 UTC (permalink / raw)
To: sunilkumar.dora, openembedded-core; +Cc: alex, Sundeep.Kokkonda
[-- Attachment #1: Type: text/plain, Size: 4290 bytes --]
On 2026-03-13 12:01 p.m., sunilkumar.dora@windriver.com wrote:
> From: Sunil Dora<sunilkumar.dora@windriver.com>
>
> Fixes [YOCTO #16058]
>
> Enable dynamic linking with LLVM (link-shared) for all rust variants
> (native, nativesdk and target) via a PACKAGECONFIG option, enabled
> by default. This prevents segmentation faults when reusing sstate
> artifacts built with different host toolchains.
>
> Update multilib library symlinking to include shared libraries and
> adjust the rust selftest to install llvm so the dynamically linked
> compiler can run correctly.
Sunil,
Please simplify the reproduction and report this upstream to GCC folks.
reply with the bug if any.
The goal is that eventually, 5+ years, we could revert this change
if this is really an upstream bug.
../Randy
> Suggested-by: Alexander Kanavin<alex@linutronix.de>
> Signed-off-by: Sunil Dora<sunilkumar.dora@windriver.com>
> ---
> meta/lib/oeqa/selftest/cases/rust.py | 2 +-
> meta/recipes-devtools/rust/rust_1.94.0.bb | 10 ++++++----
> 2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/meta/lib/oeqa/selftest/cases/rust.py b/meta/lib/oeqa/selftest/cases/rust.py
> index 3ae1946e43..7614941661 100644
> --- a/meta/lib/oeqa/selftest/cases/rust.py
> +++ b/meta/lib/oeqa/selftest/cases/rust.py
> @@ -47,7 +47,7 @@ class RustSelfTestSystemEmulated(OESelftestTestCase, OEPTestResultTestCase):
> bitbake("{} -c test_compile".format(recipe))
> builddir = get_bb_var("RUSTSRC", "rust")
> # build core-image-minimal with required packages
> - default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp", "libzstd", "openssl"]
> + default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp", "libzstd", "llvm", "openssl"]
> features = []
> features.append('IMAGE_FEATURES += "ssh-server-dropbear"')
> features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
> diff --git a/meta/recipes-devtools/rust/rust_1.94.0.bb b/meta/recipes-devtools/rust/rust_1.94.0.bb
> index 2be0bd8d89..0d34a312c0 100644
> --- a/meta/recipes-devtools/rust/rust_1.94.0.bb
> +++ b/meta/recipes-devtools/rust/rust_1.94.0.bb
> @@ -15,6 +15,9 @@ DEPENDS:append:class-nativesdk = " cargo-native rust-native"
>
> RDEPENDS:${PN}:append:class-target = " gcc g++ binutils"
>
> +PACKAGECONFIG ??= "llvm-shared"
> +PACKAGECONFIG[llvm-shared] = ",,,"
> +
> # Otherwise we'll depend on what we provide
> INHIBIT_DEFAULT_RUST_DEPS:class-native = "1" # We don't need to depend on gcc-native because yocto assumes it
> exists @@ -124,8 +127,7 @@ python do_configure() { # [llvm]
> config.add_section("llvm")
> - if d.getVar('PN') == "rust-native":
> - config.set("llvm", "link-shared", e(True))
> + config.set("llvm", "link-shared", e(bb.utils.contains('PACKAGECONFIG', 'llvm-shared', True, False, d)))
> config.set("llvm", "static-libstdcpp", e(False))
> config.set("llvm", "download-ci-llvm", e(False))
> if "llvm" in (d.getVar('TC_CXX_RUNTIME') or ""): @@ -190,7 +192,7 @@ python do_configure() { bb.build.exec_func("setup_cargo_environment", d)
> }
>
> -# llvm-config expects static libraries to be in the 'lib' directory rather than 'lib64' when
> +# llvm-config expects static/dynamic libraries to be in the 'lib' directory rather than 'lib64' when
> # multilibs enabled. Since we are copying the natively built llvm-config into the target sysroot
> # and executing it there, it will default to searching in 'lib', as it is unaware of the 'lib64'
> # directory. To ensure llvm-config can locate the necessary libraries, create a symlink from 'lib'
> @@ -207,7 +209,7 @@ do_compile:append:class-target() {
>
> # Only do per-file symlinking if lib is a real directory (not symlink)
> if [ -d "$lib_dir" ] && [ ! -L "$lib_dir" ]; then
> - for lib64_file in "${lib64_dir}"/libLLVM*.a; do
> + for lib64_file in "${lib64_dir}"/libLLVM*.a "${lib64_dir}"/libLLVM*.so*; do
> if [ -e "$lib64_file" ]; then
> lib_name=$(basename "${lib64_file}")
> target_link="${lib_dir}/${lib_name}"
--
# Randy MacLeod
# Wind River Linux
[-- Attachment #2: Type: text/html, Size: 5929 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] rust: enable dynamic LLVM linking by default
2026-03-16 16:44 ` Randy MacLeod
@ 2026-03-16 16:49 ` Dora, Sunil Kumar
0 siblings, 0 replies; 3+ messages in thread
From: Dora, Sunil Kumar @ 2026-03-16 16:49 UTC (permalink / raw)
To: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 331 bytes --]
On Mon, Mar 16, 2026 at 10:14 PM, Randy MacLeod wrote:
>
>
>
> Sunil,
>
>
>
> Please simplify the reproduction and report this upstream to GCC folks.
>
> reply with the bug if any.
>
>
Sure Randy. I will simplify the repro and report upstream. I’ll share the bug once available.
Thanks,
Sunil Dora
[-- Attachment #2: Type: text/html, Size: 378 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-16 16:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 16:01 [PATCH] rust: enable dynamic LLVM linking by default sunilkumar.dora
2026-03-16 16:44 ` Randy MacLeod
2026-03-16 16:49 ` Dora, Sunil Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox