From fa5a76751bf61ceaa5093b8a84a3eb89b7eba1bd Mon Sep 17 00:00:00 2001 From: eshiner Date: Tue, 23 Sep 2025 17:42:43 +0800 Subject: [PATCH] [compiler-rt] Support HARDCODE_NO_LSE to disable lse atomic Currently in compiler-rt, using dynamic detect for LSE support. But for some soc/ship, there was something wrong with LSE atomic instructions, so we need DISBALE it by HARDCODE. Signed-off-by: eshiner --- ...ort-HARDCODE_NO_LSE-to-disable-lse-a.patch | 113 ++++++++++++++++++ rust.spec | 7 +- 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 0001-compiler-rt-Support-HARDCODE_NO_LSE-to-disable-lse-a.patch diff --git a/0001-compiler-rt-Support-HARDCODE_NO_LSE-to-disable-lse-a.patch b/0001-compiler-rt-Support-HARDCODE_NO_LSE-to-disable-lse-a.patch new file mode 100644 index 0000000..baac454 --- /dev/null +++ b/0001-compiler-rt-Support-HARDCODE_NO_LSE-to-disable-lse-a.patch @@ -0,0 +1,113 @@ +From 8ed31fc5c8722d5f94a90e28cdc8d99fd66f943e Mon Sep 17 00:00:00 2001 +From: eshiner +Date: Tue, 23 Sep 2025 17:27:15 +0800 +Subject: [PATCH] [compiler-rt] Support HARDCODE_NO_LSE to disable lse atomic + +Currently in compiler-rt, using dynamic detect for LSE support. +But for some soc/ship, there was something wrong with LSE atomic +instructions, so we need DISBALE it by HARDCODE. + +Signed-off-by: eshiner +--- + .../compiler-rt/lib/builtins/aarch64/lse.S | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S b/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S +index 1fe18f4..31577a4 100644 +--- a/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S ++++ b/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S +@@ -129,6 +129,7 @@ HIDDEN(___aarch64_have_lse_atomics) + #define tmp1 17 + #define tmp2 15 + ++#ifndef HARDCODED_NO_LSE + // Macro for branch to label if no LSE available + .macro JUMP_IF_NOT_LSE label + #if !defined(__APPLE__) +@@ -140,11 +141,15 @@ HIDDEN(___aarch64_have_lse_atomics) + #endif + cbz w(tmp0), \label + .endm ++#endif // HARDCODED_NO_LSE + + #ifdef L_cas + DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) ++#ifndef HARDCODED_NO_LSE + JUMP_IF_NOT_LSE 8f ++#endif // HARDCODED_NO_LSE + #if SIZE < 16 ++#ifndef HARDCODED_NO_LSE + #ifdef HAS_ASM_LSE + #define CAS GLUE4(cas, A, L, S) s(0), s(1), [x2] + #else +@@ -153,6 +158,8 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) + CAS // s(0), s(1), [x2] + ret + 8: ++#endif // HARDCODED_NO_LSE ++ mov s(tmp0), s(0) + UXT s(tmp0), s(0) + 0: + LDXR s(0), [x2] +@@ -171,6 +178,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) + #define LDXP GLUE3(ld, A, xp) + #endif + #define STXP GLUE3(st, L, xp) ++#ifndef HARDCODED_NO_LSE + #ifdef HAS_ASM_LSE + #define CASP GLUE3(casp, A, L) x0, x1, x2, x3, [x4] + #else +@@ -180,6 +188,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) + CASP // x0, x1, x2, x3, [x4] + ret + 8: ++#endif // HARDCODED_NO_LSE + mov x(tmp0), x0 + mov x(tmp1), x1 + 0: +@@ -197,16 +206,20 @@ END_COMPILERRT_OUTLINE_FUNCTION(NAME(cas)) + #endif // L_cas + + #ifdef L_swp ++#ifndef HARDCODED_NO_LSE + #ifdef HAS_ASM_LSE + #define SWP GLUE4(swp, A, L, S) s(0), s(0), [x1] + #else + #define SWP .inst 0x38208020 + B + N + #endif ++#endif // HARDCODED_NO_LSE + DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(swp)) ++#ifndef HARDCODED_NO_LSE + JUMP_IF_NOT_LSE 8f + SWP // s(0), s(0), [x1] + ret + 8: ++#endif // HARDCODED_NO_LSE + mov s(tmp0), s(0) + 0: + LDXR s(0), [x1] +@@ -240,17 +253,21 @@ END_COMPILERRT_OUTLINE_FUNCTION(NAME(swp)) + #error + #endif + ++#ifndef HARDCODED_NO_LSE + #ifdef HAS_ASM_LSE + #define LDOP GLUE4(LDNM, A, L, S) s(0), s(0), [x1] + #else + #define LDOP .inst 0x38200020 + OPN + B + N + #endif ++#endif // HARDCODED_NO_LSE + + DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(LDNM)) ++#ifndef HARDCODED_NO_LSE + JUMP_IF_NOT_LSE 8f + LDOP // s(0), s(0), [x1] + ret + 8: ++#endif // HARDCODED_NO_LSE + mov s(tmp0), s(0) + 0: + LDXR s(0), [x1] +-- +2.51.0.windows.1 + diff --git a/rust.spec b/rust.spec index c898517..4421d9b 100644 --- a/rust.spec +++ b/rust.spec @@ -26,7 +26,7 @@ Name: rust Version: 1.82.0 -Release: 13 +Release: 14 Summary: The Rust Programming Language License: Apache-2.0 OR MIT URL: https://www.rust-lang.org @@ -48,6 +48,7 @@ Patch0003: 0001-add-support-for-ppc64le.patch Patch0004: 0001-Fix-enabling-wasm-component-ld-to-match-other-tools.patch Patch0005: 0001-fix-build-error-for-loongarch64.patch Patch0006: 0001-add-support-for-sw64.patch +Patch0007: 0001-compiler-rt-Support-HARDCODE_NO_LSE-to-disable-lse-a.patch %{lua: function rust_triple(arch) local abi = "gnu" @@ -300,6 +301,7 @@ sed -i.try-python -e '/^try python3 /i try "%{python}" "$@"' ./configure %patch -P 0004 -p1 %patch -P 0005 -p1 %patch -P 0006 -p1 +%patch -P 0007 -p1 rm -rf vendor/curl-sys*/curl/ rm -rf vendor/jemalloc-sys/jemalloc/ rm -rf vendor/libffi-sys*/libffi/ @@ -566,6 +568,9 @@ export %{rust_env} %{_mandir}/man1/cargo*.1* %changelog +* Tue Sep 23 2025 eshiner - 1.82.0-14 +- Support HARDCODE_NO to disable lse atomic + * Tue Aug 19 2025 xiaochn - 1.82.0-13 - Modify openEuler to vendor -- Gitee