From 75b4301eca8048f1de84c6e13544603c02cc1b25 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 16 Oct 2025 06:33:51 +0000 Subject: [PATCH] fix worse AES encoding/decoding due to missing C flags Signed-off-by: lizzie --- .patch/mbedtls/0002-aesni-fix.patch | 13 +++++++++++++ .patch/mbedtls/0003-aesni-fix.patch | 22 ++++++++++++++++++++++ CMakeLists.txt | 4 ++++ externals/cpmfile.json | 6 +++++- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .patch/mbedtls/0002-aesni-fix.patch create mode 100644 .patch/mbedtls/0003-aesni-fix.patch diff --git a/.patch/mbedtls/0002-aesni-fix.patch b/.patch/mbedtls/0002-aesni-fix.patch new file mode 100644 index 0000000000..dc5d3153b7 --- /dev/null +++ b/.patch/mbedtls/0002-aesni-fix.patch @@ -0,0 +1,13 @@ +diff --git a/library/aesni.h b/library/aesni.h +index 754c984c79..59e27afd3e 100644 +--- a/library/aesni.h ++++ b/library/aesni.h +@@ -35,7 +35,7 @@ + /* GCC-like compilers: currently, we only support intrinsics if the requisite + * target flag is enabled when building the library (e.g. `gcc -mpclmul -msse2` + * or `clang -maes -mpclmul`). */ +-#if (defined(__GNUC__) || defined(__clang__)) && defined(__AES__) && defined(__PCLMUL__) ++#if defined(__GNUC__) || defined(__clang__) + #define MBEDTLS_AESNI_HAVE_INTRINSICS + #endif + /* For 32-bit, we only support intrinsics */ diff --git a/.patch/mbedtls/0003-aesni-fix.patch b/.patch/mbedtls/0003-aesni-fix.patch new file mode 100644 index 0000000000..c620b42554 --- /dev/null +++ b/.patch/mbedtls/0003-aesni-fix.patch @@ -0,0 +1,22 @@ +diff --git a/library/aesni.c b/library/aesni.c +index 2857068..3e104ab 100644 +--- a/library/aesni.c ++++ b/library/aesni.c +@@ -31,16 +31,14 @@ + #include + #endif + +-#if defined(MBEDTLS_ARCH_IS_X86) + #if defined(MBEDTLS_COMPILER_IS_GCC) + #pragma GCC push_options + #pragma GCC target ("pclmul,sse2,aes") + #define MBEDTLS_POP_TARGET_PRAGMA +-#elif defined(__clang__) && (__clang_major__ >= 5) ++#elif defined(__clang__) + #pragma clang attribute push (__attribute__((target("pclmul,sse2,aes"))), apply_to=function) + #define MBEDTLS_POP_TARGET_PRAGMA + #endif +-#endif + + #if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY) + /* diff --git a/CMakeLists.txt b/CMakeLists.txt index e0466da3bd..fa35ca3d16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,10 @@ if (PLATFORM_SUN) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") endif() + if (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") + endif() endif() # Needed for FFmpeg w/ VAAPI and DRM diff --git a/externals/cpmfile.json b/externals/cpmfile.json index 669357588a..9025ec2787 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -97,7 +97,11 @@ "version": "3", "git_version": "3.6.4", "artifact": "%TAG%.tar.bz2", - "skip_updates": true + "skip_updates": true, + "patches": [ + "0002-aesni-fix.patch", + "0003-aesni-fix.patch" + ] }, "enet": { "repo": "lsalzman/enet",