From patchwork Mon Nov 30 00:52:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Murray X-Patchwork-Id: 106330 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.23234.1795999967044210636 for ; Sun, 29 Nov 2026 16:52:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@konsulko.com header.s=google header.b=IEYdyZ/4; spf=pass (domain: konsulko.com, ip: 209.85.222.173, mailfrom: scott.murray@konsulko.com) Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-94958650b09so954330185a.1 for ; Sun, 29 Nov 2026 16:52:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1795999966; x=1796604766; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ZR36cT2WtrfrO1hj5VhVHL109gge+XefjHpbQygSt5s=; b=IEYdyZ/4K47wVDU1u/r2qeX0+PIIXBO0jZJmRffkisPEegr6UBGiZjTkbl8A8ghUbS wUV132a9Hc4Qn9KEFJDLueB3uyAJysZjnLHDBMAve1B0V1hiFaTtPUhcsZ52rtOV7LEi ZSiCCdJJ/FI2NuChhsNMfTaE6MfUvIQr+ayCw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795999966; x=1796604766; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=ZR36cT2WtrfrO1hj5VhVHL109gge+XefjHpbQygSt5s=; b=g6T6Zbz/nHtWxV+EYGQq9vfb1eZN3/vYU/iwagAZ4BVrWQOTN2eKrrx8bnVyXZoUVr iLeDpmK9+hg1ZXIh1y0fa5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UK gxj8Dn8l4mMtva+TNpJxio6W8kCOngs/soXEzWx/gMvlwA9HHP9uZIr+zVPO1bqUyVw== X-Received: by 2002:a05:620a:1713:b0:948:e2fc:177a with SMTP id af79cd13be357-949baa0d7a2mr5750017985a.60.1795999965675; Sun, 29 Nov 2026 16:52:45 -0800 (PST) Return-Path: Received: from ghidorah.spiteful.org (107-179-213-3.cpe.teksavvy.com. [107.179.213.3]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921787fd72asm141946796d6.12.2026.11.29.16.52.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 16:52:45 -0800 (PST) From: Scott Murray To: yocto-patches@lists.yoctoproject.org Subject: [meta-lts-mixins][wrynose/rust][PATCH 05/10] rust: drop native libLLVM path for non-host architectures Date: Sun, 29 Nov 2026 19:52:23 -0500 Message-ID: X-Mailer: git-send-email 2.56.1 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Mon, 30 Nov 2026 00:52:52 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5592 From: Hemanth Kumar M D With the recent refactoring of the LLVM handling in rust bootstrap [1], the library search path of the native LLVM (recipe-sysroot-native/usr/lib) is added to the link of the target rustc_llvm when rustc is cross-built. rustc_llvm/build.rs only adjusts these -L paths by replacing the host triple with the target triple. In OE the native and target sysroot paths do not contain a triple, so the native path is kept and the linker finds the native libLLVM before the target one. A linker that cannot read the native library fails with: libLLVM-23.so: file not recognized: file format not recognized Add a patch to drop -L paths that point into recipe-sysroot-native when cross-building. The target libLLVM is still found through the target --sysroot. This is a workaround. The issue has been reported upstream [2] and the patch can be dropped once it is fixed there. [1] https://github.com/rust-lang/rust/pull/161247 [2] https://github.com/rust-lang/rust/issues/165385 Signed-off-by: Hemanth Kumar M D Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie (adapted from oe-core commit 49c30208e9fc84bd8bf054ee7ffc853126fdd0bd) Signed-off-by: Scott Murray --- ...native-sysroot-L-when-cross-building.patch | 49 +++++++++++++++++++ recipes-devtools/rust/rust-source.inc | 1 + 2 files changed, 50 insertions(+) create mode 100644 recipes-devtools/rust/files/0005-rustc_llvm-drop-native-sysroot-L-when-cross-building.patch diff --git a/recipes-devtools/rust/files/0005-rustc_llvm-drop-native-sysroot-L-when-cross-building.patch b/recipes-devtools/rust/files/0005-rustc_llvm-drop-native-sysroot-L-when-cross-building.patch new file mode 100644 index 0000000..8fd17c1 --- /dev/null +++ b/recipes-devtools/rust/files/0005-rustc_llvm-drop-native-sysroot-L-when-cross-building.patch @@ -0,0 +1,49 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Hemanth Kumar M D +Date: Mon, 16 Nov 2026 03:14:17 -0800 +Subject: [PATCH] rustc_llvm: drop native sysroot -L when cross-building + +With the recent refactoring of the LLVM handling in rust bootstrap [1], +the library search path of the native LLVM +(recipe-sysroot-native/usr/lib) is added to the link of the target +rustc_llvm when rustc is cross-built. + +rustc_llvm/build.rs only adjusts these -L paths by replacing the host +triple with the target triple. In OE the native and target sysroot +paths do not contain a triple, so the native path is kept and the +linker finds the native libLLVM before the target one. A linker that +cannot read the native library fails with: + + libLLVM-23.so: file not recognized: file format not recognized + +Drop -L paths that point into recipe-sysroot-native when +cross-building. The target libLLVM is still found through the target +--sysroot. + +Upstream-Status: Inappropriate [https://github.com/rust-lang/rust/issues/165385] + +[1] https://github.com/rust-lang/rust/pull/161247 + +Signed-off-by: Hemanth Kumar M D +--- + compiler/rustc_llvm/build.rs | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs +index 450b98f..05ff9dc 100644 +--- a/compiler/rustc_llvm/build.rs ++++ b/compiler/rustc_llvm/build.rs +@@ -452,7 +452,12 @@ fn main() { + if let Some(stripped) = lib.strip_prefix("-LIBPATH:") { + println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target)); + } else if let Some(stripped) = lib.strip_prefix("-L") { +- println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target)); ++ // OE: the build-machine llvm-config reports a libdir in the ++ // native sysroot, which holds a wrong-arch libLLVM. ++ let rewritten = stripped.replace(&host, &target); ++ if !rewritten.contains("recipe-sysroot-native") { ++ println!("cargo:rustc-link-search=native={rewritten}"); ++ } + } + } else if let Some(stripped) = lib.strip_prefix("-LIBPATH:") { + println!("cargo:rustc-link-search=native={stripped}"); diff --git a/recipes-devtools/rust/rust-source.inc b/recipes-devtools/rust/rust-source.inc index 8b5b59b..ed779f3 100644 --- a/recipes-devtools/rust/rust-source.inc +++ b/recipes-devtools/rust/rust-source.inc @@ -7,6 +7,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n file://0002-Fix-rust-build-failure-with-unstable-options.patch;patchdir=${RUSTSRC} \ file://0003-cargo-omit-host-triple-from-unit-metadata-hash.patch;patchdir=${RUSTSRC} \ file://0004-Re-bless-tests-adjust-for-new-Cargo-lints.patch;patchdir=${RUSTSRC} \ + file://0005-rustc_llvm-drop-native-sysroot-L-when-cross-building.patch;patchdir=${RUSTSRC} \ " SRC_URI[rust.sha256sum] = "90dab90b8084eb57c35ae2b1d0b70c8e5138ace6023b22c60a5a400f586f63b2"