From f9ce2b1ac105e80a50ca4f683d865ff8f6b6b807 Mon Sep 17 00:00:00 2001 From: Yash Shinde Date: Wed, 29 Oct 2025 07:07:07 -0700 Subject: [PATCH] rust: enable lld linker option WIP To enable and use rust-lld. Configure the PACKAGECONFIG option to enable users to select their preferred linker. Test lld. Signed-off-by: Yash Shinde Signed-off-by: Deepesh Varatharajan --- meta/recipes-devtools/rust/rust_1.90.0.bb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/meta/recipes-devtools/rust/rust_1.90.0.bb b/meta/recipes-devtools/rust/rust_1.90.0.bb index e7f3985332..113d8a0984 100644 --- a/meta/recipes-devtools/rust/rust_1.90.0.bb +++ b/meta/recipes-devtools/rust/rust_1.90.0.bb @@ -7,7 +7,7 @@ LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=11a3899825f4376896e438c8c753f8dc" inherit rust inherit cargo_common -DEPENDS += "llvm" +DEPENDS += "llvm lld" # native rust uses cargo/rustc from binary snapshots to bootstrap # but everything else should use our native builds DEPENDS:append:class-target = " cargo-native rust-native" @@ -134,9 +134,7 @@ python do_configure() { config.set("rust", "rpath", e(True)) config.set("rust", "remap-debuginfo", e(True)) config.set("rust", "download-rustc", e(False)) - config.set("rust", "llvm-tools", e(False)) - config.set("rust", "lld", e(False)) - config.set("rust", "use-lld", e(False)) + config.set("rust", "llvm-tools", e(True)) config.set("rust", "channel", e(d.expand("${RUST_CHANNEL}"))) # Whether or not to optimize the compiler and standard library @@ -230,7 +228,7 @@ rust_runx () { unset CXXFLAGS unset CPPFLAGS - export RUSTFLAGS="${RUST_DEBUG_REMAP} -Clink-arg=-lz -Clink-arg=-lzstd" + export RUSTFLAGS="${RUST_DEBUG_REMAP} -Clink-arg=-lz -Clink-arg=-lzstd -C link-arg=-fuse-ld=lld" # Copy the natively built llvm-config into the target so we can run it. Horrible, # but works! @@ -238,6 +236,7 @@ rust_runx () { mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}` cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH} + cp -rf ${STAGING_BINDIR_NATIVE}/* ${STAGING_BINDIR} fi oe_cargo_fix_env @@ -302,6 +301,7 @@ rust_do_install:class-nativesdk() { rm ${D}${libdir}/rustlib/install.log rm ${D}${libdir}/rustlib/manifest* rm ${D}${libdir}/rustlib/${RUST_HOST_SYS}/lib/libstd*.so + rm ${D}${libdir}/rustlib/${RUST_HOST_SYS}/bin/rust-objcopy ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d mkdir "${ENV_SETUP_DIR}" @@ -340,6 +340,7 @@ rust_do_install:class-target() { rm ${D}${libdir}/rustlib/install.log rm ${D}${libdir}/rustlib/manifest* rm ${D}${libdir}/rustlib/${RUST_HOST_SYS}/lib/libstd*.so + rm ${D}${libdir}/rustlib/${RUST_HOST_SYS}/bin/rust-objcopy } addtask do_update_snapshot after do_patch -- 2.47.3