]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
rust: backport cstring-merging test fix for PowerPC targets
authorPeter Tatrai <peter.tatrai.ext@siemens.com>
Mon, 11 Aug 2025 08:43:34 +0000 (10:43 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 14 Aug 2025 07:18:49 +0000 (08:18 +0100)
The Rust cstring-merging assembly test was failing on PowerPC targets due to
LLVM's GlobalMerge optimization pass merging all global string constants into
a single merged global. This caused the test's CHECK directives to fail as
they expected separate .Lanon labels for each string literal ("foo", "bar",
"baz").

The test verifies that C-style string literals are correctly placed in
mergeable read-only sections (.rodata.str1.1) with proper section flags
(aMS - Allocatable, Merge, Strings) for linker optimization.

This backports the upstream fix that disables the GlobalMerge pass
(-Cllvm-args=-enable-global-merge=0) specifically for this test, allowing
it to verify the expected assembly structure without interference from
the optimization.

Fixes test failure:
- tests/assembly/cstring-merging.rs on powerpc-poky-linux-gnu

Backport of https://github.com/rust-lang/rust/commit/2d51acd2fbcbadb6f30709c5dd305494d413d388

Signed-off-by: Peter Tatrai <peter.tatrai.ext@siemens.com>
Tested-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/rust/files/backport-fix-test-string-merging.patch [new file with mode: 0644]
meta/recipes-devtools/rust/rust-source.inc

diff --git a/meta/recipes-devtools/rust/files/backport-fix-test-string-merging.patch b/meta/recipes-devtools/rust/files/backport-fix-test-string-merging.patch
new file mode 100644 (file)
index 0000000..1e72c10
--- /dev/null
@@ -0,0 +1,27 @@
+From 2d51acd2fbcbadb6f30709c5dd305494d413d388 Mon Sep 17 00:00:00 2001
+From: Jens Reidel <adrian@travitia.xyz>
+Date: Fri, 18 Jul 2025 19:44:20 +0200
+Subject: [PATCH] tests: assembly: cstring-merging: Disable GlobalMerge pass
+
+The test relies on LLVM not merging all the globals into one and would
+currently otherwise fail on powerpc64le.
+
+Signed-off-by: Peter Tatrai <Peter.Tatrai@siemens.com>
+Upstream-Status: Backport [https://github.com/rust-lang/rust/commit/2d51acd2fbcbadb6f30709c5dd305494d413d388]
+---
+ tests/assembly/cstring-merging.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tests/assembly/cstring-merging.rs b/tests/assembly/cstring-merging.rs
+index f7d0775f7affd..03688e0068b79 100644
+--- a/tests/assembly/cstring-merging.rs
++++ b/tests/assembly/cstring-merging.rs
+@@ -2,7 +2,7 @@
+ // other architectures (including ARM and x86-64) use the prefix `.Lanon.`
+ //@ only-linux
+ //@ assembly-output: emit-asm
+-//@ compile-flags: --crate-type=lib -Copt-level=3
++//@ compile-flags: --crate-type=lib -Copt-level=3 -Cllvm-args=-enable-global-merge=0
+ //@ edition: 2024
+ use std::ffi::CStr;
index 1a5d98d9dcf5d53f6f8eb5fe784e3c5c0063e735..8f341a0e5b21f3a7242feba2c5aaf90402b471e5 100644 (file)
@@ -11,6 +11,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
             file://0001-Disable-libunwind-cross-architecture-unwinding.patch;patchdir=${RUSTSRC} \
             file://triagebot.patch;patchdir=${RUSTSRC} \
             file://0001-riscv32-Define-plain-syscalls-as-their-time64-varian.patch;patchdir=${RUSTSRC} \
+            file://backport-fix-test-string-merging.patch;patchdir=${RUSTSRC} \
 "
 SRC_URI[rust.sha256sum] = "0c1dcbb4f762513d021e1a282c0ac58c0a423642b3a6bf581cafb5414df4193e"