diff mbox series

[meta-oe] php: Fix GCC 12 -Og

Message ID 20230412065752.2905789-1-mingli.yu@eng.windriver.com
State Under Review
Headers show
Series [meta-oe] php: Fix GCC 12 -Og | expand

Commit Message

mingli.yu@eng.windriver.com April 12, 2023, 6:57 a.m. UTC
From: Mingli Yu <mingli.yu@windriver.com>

Change whether to inline XXH3_hashLong_withSecret to a config option
to fix GCC 12 -Og.

Ref: https://github.com/Cyan4973/xxHash/commit/ace22bddc7a366a5dd8a71e8b8247694530684ec

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 ...o-inline-XXH3_hashLong_withSecret-to.patch | 93 +++++++++++++++++++
 meta-oe/recipes-devtools/php/php_8.2.4.bb     |  1 +
 2 files changed, 94 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/php/php/0001-Change-whether-to-inline-XXH3_hashLong_withSecret-to.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/php/php/0001-Change-whether-to-inline-XXH3_hashLong_withSecret-to.patch b/meta-oe/recipes-devtools/php/php/0001-Change-whether-to-inline-XXH3_hashLong_withSecret-to.patch
new file mode 100644
index 000000000..5b8c76209
--- /dev/null
+++ b/meta-oe/recipes-devtools/php/php/0001-Change-whether-to-inline-XXH3_hashLong_withSecret-to.patch
@@ -0,0 +1,93 @@ 
+From 1eeb59366d6140a799f6051fb9f57d988b81fd5b Mon Sep 17 00:00:00 2001
+From: easyaspi314 <easyaspi314@users.noreply.github.com>
+Date: Wed, 12 Apr 2023 13:33:07 +0800
+Subject: [PATCH] Change whether to inline XXH3_hashLong_withSecret to a config
+ option
+
+Change whether to inline XXH3_hashLong_withSecret to a config option to fix
+GCC 12 -Og.
+
+Upstream-Status: Submitted [https://github.com/php/php-src/pull/11062]
+
+Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
+---
+ ext/hash/xxhash/xxhash.h | 35 +++++++++++++++++++++++++++++++++--
+ 1 file changed, 33 insertions(+), 2 deletions(-)
+
+diff --git a/ext/hash/xxhash/xxhash.h b/ext/hash/xxhash/xxhash.h
+index b5bd2864..8e816c05 100644
+--- a/ext/hash/xxhash/xxhash.h
++++ b/ext/hash/xxhash/xxhash.h
+@@ -1375,6 +1375,23 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
+  */
+ #  define XXH_NO_INLINE_HINTS 0
+ 
++/*!
++ * @def XXH3_INLINE_SECRET
++ * @brief Determines whether to inline the XXH3 withSecret code.
++ *
++ * When the secret size is known, the compiler can improve the performance
++ * of XXH3_64bits_withSecret() and XXH3_128bits_withSecret().
++ *
++ * However, if the secret size is not known, it doesn't have any benefit. This
++ * happens when xxHash is compiled into a global symbol. Therefore, if
++ * @ref XXH_INLINE_ALL is *not* defined, this will be defined to 0.
++ *
++ * Additionally, this defaults to 0 on GCC 12+, which has an issue with function pointers
++ * that are *sometimes* force inline on -Og, and it is impossible to automatically
++ * detect this optimization level.
++ */
++#  define XXH3_INLINE_SECRET 0
++
+ /*!
+  * @def XXH32_ENDJMP
+  * @brief Whether to use a jump for `XXH32_finalize`.
+@@ -1439,6 +1456,15 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
+ #  endif
+ #endif
+ 
++#ifndef XXH3_INLINE_SECRET
++#  if (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12) \
++     || !defined(XXH_INLINE_ALL)
++#    define XXH3_INLINE_SECRET 0
++#  else
++#    define XXH3_INLINE_SECRET 1
++#  endif
++#endif
++
+ #ifndef XXH32_ENDJMP
+ /* generally preferable for performance */
+ #  define XXH32_ENDJMP 0
+@@ -1515,6 +1541,11 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
+ #  define XXH_NO_INLINE static
+ #endif
+ 
++#if XXH3_INLINE_SECRET
++#  define XXH3_WITH_SECRET_INLINE XXH_FORCE_INLINE
++#else
++#  define XXH3_WITH_SECRET_INLINE XXH_NO_INLINE
++#endif
+ 
+ 
+ /* *************************************
+@@ -4465,7 +4496,7 @@ XXH3_hashLong_64b_internal(const void* XXH_RESTRICT input, size_t len,
+  * so that the compiler can properly optimize the vectorized loop.
+  * This makes a big performance difference for "medium" keys (<1 KB) when using AVX instruction set.
+  */
+-XXH_FORCE_INLINE XXH64_hash_t
++XXH3_WITH_SECRET_INLINE XXH64_hash_t
+ XXH3_hashLong_64b_withSecret(const void* XXH_RESTRICT input, size_t len,
+                              XXH64_hash_t seed64, const xxh_u8* XXH_RESTRICT secret, size_t secretLen)
+ {
+@@ -5263,7 +5294,7 @@ XXH3_hashLong_128b_default(const void* XXH_RESTRICT input, size_t len,
+  * It's important for performance to pass @secretLen (when it's static)
+  * to the compiler, so that it can properly optimize the vectorized loop.
+  */
+-XXH_FORCE_INLINE XXH128_hash_t
++XXH3_WITH_SECRET_INLINE XXH128_hash_t
+ XXH3_hashLong_128b_withSecret(const void* XXH_RESTRICT input, size_t len,
+                               XXH64_hash_t seed64,
+                               const void* XXH_RESTRICT secret, size_t secretLen)
+-- 
+2.25.1
+
diff --git a/meta-oe/recipes-devtools/php/php_8.2.4.bb b/meta-oe/recipes-devtools/php/php_8.2.4.bb
index aec222b58..d5954d976 100644
--- a/meta-oe/recipes-devtools/php/php_8.2.4.bb
+++ b/meta-oe/recipes-devtools/php/php_8.2.4.bb
@@ -19,6 +19,7 @@  SRC_URI = "http://php.net/distributions/php-${PV}.tar.bz2 \
            file://0006-ext-phar-Makefile.frag-Fix-phar-packaging.patch \
            file://0009-php-don-t-use-broken-wrapper-for-mkdir.patch \
            file://0010-iconv-fix-detection.patch \
+           file://0001-Change-whether-to-inline-XXH3_hashLong_withSecret-to.patch \
           "
 
 SRC_URI:append:class-target = " \