diff mbox series

[1/3] rust: add missing zlib and zstd dependencies

Message ID 20251027102900.65173-2-peter.tatrai.ext@siemens.com
State New
Headers show
Series Fix Rust self-test failures on PowerPC | expand

Commit Message

P. Tatrai Oct. 27, 2025, 10:28 a.m. UTC
From: Peter Tatrai <peter.tatrai.ext@siemens.com>

Use WRAPPER_TARGET_EXTRALD to pass '-lz -lzstd' to the target linker wrapper,

Rust's internal LLVM requires zlib and zstd compression libraries when
building rustc_codegen_llvm and other compiler components.
Without these dependencies, building Rust for PowerPC target fails
with linker errors:

  error: linking with `target-rust-ccld` failed: exit status: 1
  = note: undefined reference to `compress2'
  = note: undefined reference to `uncompress'
  = note: undefined reference to `ZSTD_decompress'
  = note: undefined reference to `ZSTD_isError'
  = note: undefined reference to `ZSTD_compress2'
  = note: undefined reference to `crc32'

This manifested in oe-selftest failure on qemuppc:
  oe-selftest -r rust.RustSelfTestSystemEmulated.test_rust

Fix rust-common.bbclass wrapper generation to properly split EXTRALD flags
into separate arguments (extend instead of append), making the wrapper
mechanism work correctly for multi-flag values like '-lz -lzstd'.

Signed-off-by: Peter Tatrai <peter.tatrai.ext@siemens.com>
---
 meta/classes-recipe/rust-common.bbclass   | 2 +-
 meta/recipes-devtools/rust/rust_1.90.0.bb | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/rust-common.bbclass b/meta/classes-recipe/rust-common.bbclass
index 31331c7a26..d9f7a7a932 100644
--- a/meta/classes-recipe/rust-common.bbclass
+++ b/meta/classes-recipe/rust-common.bbclass
@@ -149,7 +149,7 @@  create_wrapper_rust () {
 	binary = orig_binary.split()[0]
 	args = orig_binary.split() + sys.argv[1:]
 	if extras:
-	    args.append(extras)
+	    args.extend(extras.split())
 	os.execvp(binary, args)
 	EOF
 	chmod +x "${file}"
diff --git a/meta/recipes-devtools/rust/rust_1.90.0.bb b/meta/recipes-devtools/rust/rust_1.90.0.bb
index 0319d73b93..8247e9a10a 100644
--- a/meta/recipes-devtools/rust/rust_1.90.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.90.0.bb
@@ -69,6 +69,11 @@  do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
 do_rust_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER"
 do_rust_setup_snapshot[depends] += "patchelf-native:do_populate_sysroot"
 
+# Pass zlib/zstd link flags to the target linker wrapper via WRAPPER_TARGET_EXTRALD.
+# This ensures LLVM-using components (like rustc_codegen_llvm) can find compression libraries.
+# The wrapper will split this into separate arguments automatically.
+WRAPPER_TARGET_EXTRALD:append:class-target = " -lz -lzstd"
+
 RUSTC_BOOTSTRAP = "${STAGING_BINDIR_NATIVE}/rustc"
 CARGO_BOOTSTRAP = "${STAGING_BINDIR_NATIVE}/cargo"
 RUSTC_BOOTSTRAP:class-native = "${WORKDIR}/rust-snapshot/bin/rustc"