File protobuf-gh23194.patch of Package protobuf
From cbe193ab7ef6f8979cc33a876073217b364f4118 Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <github@carlo.cab>
Date: Tue, 19 Aug 2025 10:15:15 -0700
Subject: [PATCH] Use ACLE __crc32cd intrinsic on Arm (#23164)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Switch from __builtin_arm_crc32cd to __crc32cd so code compiles on both AArch32 and AArch64 when CRC32 is available.
Before this change, users of the `google/prototobuf/port.h` header on AArch64 Linux error out with
/home/linuxbrew/.linuxbrew/include/google/protobuf/port.h: In function ‘uint32_t google::protobuf::internal::Crc32(uint32_t, uint64_t)’: /home/linuxbrew/.linuxbrew/include/google/protobuf/port.h:798:10: error: ‘__builtin_arm_crc32cd’ was not declared in this scope; did you mean ‘__builtin_aarch64_crc32cx’?
798 | return __builtin_arm_crc32cd(crc, v);
| ^~~~~~~~~~~~~~~~~~~~~
| __builtin_aarch64_crc32cx
gmake[2]: *** [CMakeFiles/test.dir/build.make:79: CMakeFiles/test.dir/test.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/test.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
Closes #23164
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/23164 from carlocab:aarch64-crc32-fix 1cd12a573b8d629ae69f6123e24db5c71e92e18c
PiperOrigin-RevId: 796924525
---
src/google/protobuf/port.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/google/protobuf/port.h b/src/google/protobuf/port.h
index 10667c69b505e..b04ea1b6abd81 100644
--- a/src/google/protobuf/port.h
+++ b/src/google/protobuf/port.h
@@ -23,6 +23,10 @@
#include <type_traits>
#include <typeinfo>
+#if defined(__ARM_FEATURE_CRC32)
+#include <arm_acle.h>
+#endif
+
#include "absl/base/optimization.h"
@@ -802,9 +806,7 @@ inline uint32_t Crc32(uint32_t crc, uint64_t v) {
#elif defined(__ARM_FEATURE_CRC32)
constexpr bool HasCrc32() { return true; }
-inline uint32_t Crc32(uint32_t crc, uint64_t v) {
- return __builtin_arm_crc32cd(crc, v);
-}
+inline uint32_t Crc32(uint32_t crc, uint64_t v) { return __crc32cd(crc, v); }
#else