rust: Enable dynamic linking with llvm
PATCH v3 1/1 rust: Enable dynamic linking with llvm
From: Sunil Dora <[email protected]>
Fixes [Yocto #16058]
A segmentation fault occurs in rustc (e.g. in llvm::X86ReadAdvanceTable) when reusing sstate artifacts built with different host toolchain versions.
Issue sequence:
1. llvm-native is built with a newer toolchain
(e.g. GCC 15/Binutils 2.45).
2. rust-native is later built with an older linker. (e.g. GCC 12/Binutils 2.40).
3. The older linker statically links parts of llvm-native into librustc_driver.
4. The resulting binary crashes at runtime inside the statically linked LLVM code.
The corruption happens at link time when mixing static native objects produced by different toolchain generations.
Enable dynamic LLVM linking (link-shared = true) for rust-native so rustc links against libLLVM.so instead of static archives, avoiding host linker incompatibilities when reusing sstate artifacts.
---
# v2 Feedback: # rust-native should link LLVM dynamically # rust-target should remain static # Workaround limited to -native only
meta/recipes-devtools/rust/rust_1.93.0.bb | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-devtools/rust/rust_1.93.0.bb +2 -0
@@ -124,6 +124,8 @@ python do_configure() { # [llvm] config.add_section("llvm") + if d.getVar('PN') == "rust-native": + config.set("llvm", "link-shared", e(True)) config.set("llvm", "static-libstdcpp", e(False)) config.set("llvm", "download-ci-llvm", e(False)) if "llvm" in (d.getVar('TC_CXX_RUNTIME') or ""):
Signature · 1 line
2.49.0