| Message ID | 20251027102900.65173-2-peter.tatrai.ext@siemens.com |
|---|---|
| State | New |
| Headers | show |
| Series | Fix Rust self-test failures on PowerPC | expand |
On Mon, 2025-10-27 at 11:28 +0100, Tatrai, Peter via lists.openembedded.org wrote: > 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(-) Why do we only see this on powerpc? Cheers, Richard
On 27 Oct 2025, at 10:28, Tatrai, Peter via lists.openembedded.org <peter.tatrai.ext=siemens.com@lists.openembedded.org> wrote: > > 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: Is this still the case after we dropped rust-llvm and now use the same llvm as clang? Notably, the patch to switch from rust-llvm to llvm included this: - export RUSTFLAGS="${RUST_DEBUG_REMAP}" + export RUSTFLAGS="${RUST_DEBUG_REMAP} -Clink-arg=-lz -Clink-arg=-lzstd" Ross
> > 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: > Is this still the case after we dropped rust-llvm and now use the same llvm as clang? Dropping rust-llvm has introduced this issue. It worked before because rust-llvm was configured with "-DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_ZSTD=OFF" > Notably, the patch to switch from rust-llvm to llvm included this: > - export RUSTFLAGS="${RUST_DEBUG_REMAP}" > + export RUSTFLAGS="${RUST_DEBUG_REMAP} -Clink-arg=-lz -Clink-arg=-lzstd" These arguments don't help when compiling test binaries. Providing -lz -lzstd works. Also notable is that on other platforms, it's not needed to add libz and libzstd .so files into the qemu image used for testing. Peter.
> Notably, the patch to switch from rust-llvm to llvm included this: > > - export RUSTFLAGS="${RUST_DEBUG_REMAP}" > + export RUSTFLAGS="${RUST_DEBUG_REMAP} -Clink-arg=-lz -Clink-arg=-lzstd" I realized that these RUSTFLAGS exported at the recipe level don't propagate to the rust self-test. The test directly runs 'python3 src/bootstrap/bootstrap.py test --target' in an environment where recipe-level variables aren't visible. I'm sending a v2 that fixes this specifically in the selftest harness (meta/lib/oeqa/selftest/cases/rust.py) by passing the link args via RUSTFLAGS in the test command itself, plus adding libzstd to the QEMU test image. This approach is more targeted and only affects the selftest execution. Peter
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"