]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
rust: enable lld linker option deepesh/ys_rust_lld
authorYash Shinde <Yash.Shinde@windriver.com>
Wed, 29 Oct 2025 14:07:07 +0000 (07:07 -0700)
committerDeepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
Thu, 6 Nov 2025 06:39:40 +0000 (22:39 -0800)
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 <Yash.Shinde@windriver.com>
Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
meta/recipes-devtools/rust/rust_1.90.0.bb

index e7f3985332de2ecbaab1e560273acea21d85a092..113d8a0984c8ddbb77599a62ea856dc496271959 100644 (file)
@@ -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