public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/php-pecl-yac] epel10: fix big endian build using upstream patch
@ 2026-10-29  5:48 Remi Collet
  0 siblings, 0 replies; only message in thread
From: Remi Collet @ 2026-10-29  5:48 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/php-pecl-yac
            Branch : epel10
            Commit : 66af43dea8b70a107d668e5ccafe69e78633340d
            Author : Remi Collet <remi@fedoraproject.org>
            Date   : 2026-10-29T06:48:02+01:00
            Stats  : +147/-4 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/php-pecl-yac/c/66af43dea8b70a107d668e5ccafe69e78633340d?branch=epel10

            Log:
            fix big endian build using upstream patch

(cherry picked from commit bde43b2904c6cfcd32a005f474950d9bf76479c2)

---
diff --git a/php-pecl-yac.spec b/php-pecl-yac.spec
index b54e7ae..b35562a 100644
--- a/php-pecl-yac.spec
+++ b/php-pecl-yac.spec
@@ -25,14 +25,14 @@ Name:           php-pecl-%{pecl_name}
 Summary:        Lockless user data cache
 License:        PHP-3.01
 Version:        3.0.1
-Release:        1%{?dist}
+Release:        2%{?dist}
 %forgemeta
 URL:            %{forgeurl}
 Source0:        %{forgesource}
 
-# Broken on big endian
-# https://github.com/laruence/yac/issues/134
-ExcludeArch:    %{ix86} s390x
+Patch0:         upstream.patch
+
+ExcludeArch:    %{ix86}
 
 BuildRequires:  make
 BuildRequires:  gcc
@@ -69,6 +69,7 @@ that your product is not very sensitive to that.
 
 %prep
 %forgesetup
+%patch -P0 -p1
 
 # drop bundled lz4 to ensure it is not used
 rm -r compressor/lz4
@@ -141,6 +142,9 @@ TEST_PHP_ARGS="$OPTS -d extension=$PWD/modules/%{pecl_name}.so" \
 
 
 %changelog
+* Thu Oct 29 2026 Remi Collet <remi@remirepo.net> - 3.0.1-2
+- fix big endian build using upstream patch
+
 * Wed Oct 28 2026 Remi Collet <remi@remirepo.net> - 3.0.1-1
 - update to 3.0.1
 - drop support for alternative serializer

diff --git a/upstream.patch b/upstream.patch
new file mode 100644
index 0000000..dd14d47
--- /dev/null
+++ b/upstream.patch
@@ -0,0 +1,139 @@
+From 45f5c2bbb6dd75566eb9dfbd69c2979b024a71eb Mon Sep 17 00:00:00 2001
+From: Xinchen Hui <laruence@gmail.com>
+Date: Thu, 29 Oct 2026 11:46:38 +0800
+Subject: [PATCH] Try to fix big-endian CRC-32C in the slicing-by-8 fallback
+ (issue #134)
+
+---
+ .github/workflows/s390x.yml | 42 +++++++++++++++++++++++++++++++++++++
+ storage/crc/yac_crc32.c     |  8 +++++++
+ 2 files changed, 50 insertions(+)
+ create mode 100644 .github/workflows/s390x.yml
+
+diff --git a/.github/workflows/s390x.yml b/.github/workflows/s390x.yml
+new file mode 100644
+index 0000000..042011d
+--- /dev/null
++++ b/.github/workflows/s390x.yml
+@@ -0,0 +1,42 @@
++name: s390x
++on:
++  workflow_dispatch:
++
++jobs:
++  s390x:
++    name: "Linux s390x (big endian, QEMU)"
++    runs-on: ubuntu-latest
++    timeout-minutes: 90
++    steps:
++      - name: Checkout
++        uses: actions/checkout@v5
++        with:
++          submodules: true
++      - name: Setup QEMU
++        run: |
++          sudo apt-get update
++          sudo apt-get install -y qemu-user-static binfmt-support
++          # register the s390x interpreter for the host kernel
++          docker run --rm --privileged multiarch/qemu-user-static --reset -p yes || true
++      - name: Build and test in an s390x container
++        run: |
++          docker run --rm --platform linux/s390x \
++            -v "$PWD:/yac" -w /yac \
++            ubuntu:24.04 \
++            bash -euxc '
++              uname -m;
++              echo -e "deb [trusted=yes] https://ports.ubuntu.com/ubuntu-ports noble main universe\n\
++          deb [trusted=yes] https://ports.ubuntu.com/ubuntu-ports noble-updates main universe" \
++                > /etc/apt/sources.list;
++              apt-get update;
++              DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
++                php-cli php-dev liblz4-dev re2c build-essential pkg-config;
++              php -v | head -1;
++              phpize;
++              ./configure;
++              make -j"$(nproc)";
++              php -n -d extension=$PWD/modules/yac.so -m | grep -qx yac;
++              TEST_PHP_EXECUTABLE=$(which php) \
++              NO_INTERACTION=1 REPORT_EXIT_STATUS=1 \
++              php run-tests.php -q -n -p "$(which php)" -d extension=$PWD/modules/yac.so --show-diff
++            '
+diff --git a/storage/crc/yac_crc32.c b/storage/crc/yac_crc32.c
+index a2e5ea9..e86ae51 100644
+--- a/storage/crc/yac_crc32.c
++++ b/storage/crc/yac_crc32.c
+@@ -356,6 +356,11 @@ static uint32_t snapshot_interleaved(char *dst, const char *buf, unsigned int si
+  * bit for bit; tables in yac_crc32_tab.h, verified against RFC 3720 B.4
+  * ("123456789" -> 0xe3069283)
+  *
++ * the table indexing below assumes the word is laid out little-endian
++ * (first byte in memory == low byte of w); byteswap on big-endian so the
++ * checksum matches hardware builds and, crucially, does not depend on
++ * the buffer's alignment (issue #134)
++ *
+  * x86 needs this at runtime (the SSE4.2 probe can fail) and a build with
+  * neither ISA has nothing else, but an ARM build is arch-gated rather than
+  * probed, so yac_crc32_startup() below cannot reach the fallback there --
+@@ -381,6 +386,9 @@ static uint32_t slice8_core(char *dst, const char *data, unsigned int size) {
+ 		uint64_t w;
+ 
+ 		memcpy(&w, p, sizeof(uint64_t));
++#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
++		w = __builtin_bswap64(w);
++#endif
+ 		if (dst) {
+ 			memcpy(dst, &w, sizeof(uint64_t));
+ 			dst += sizeof(uint64_t);
+From 953def636e5e00cdbe0bece79261ce11f1e04d7d Mon Sep 17 00:00:00 2001
+From: Xinchen Hui <laruence@gmail.com>
+Date: Thu, 29 Oct 2026 11:51:09 +0800
+Subject: [PATCH] Guard the big-endian bswap behind defined(__BYTE_ORDER__),
+ MSVC leaves it undefined
+
+---
+ storage/crc/yac_crc32.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/storage/crc/yac_crc32.c b/storage/crc/yac_crc32.c
+index 1800218..d4ac2c7 100644
+--- a/storage/crc/yac_crc32.c
++++ b/storage/crc/yac_crc32.c
+@@ -381,7 +381,7 @@ static uint32_t slice8_core(char *dst, const char *data, unsigned int size) {
+ 		uint64_t w;
+ 
+ 		memcpy(&w, p, sizeof(uint64_t));
+-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
++#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ 		w = __builtin_bswap64(w);
+ #endif
+ 		if (dst) {
+From cca98d159d31da3e0e0315db39cb1e8f3f315000 Mon Sep 17 00:00:00 2001
+From: Xinchen Hui <laruence@gmail.com>
+Date: Thu, 29 Oct 2026 12:48:45 +0800
+Subject: [PATCH] Fix snapshot bytes swapped on big-endian in the CRC fix
+
+---
+ storage/crc/yac_crc32.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/storage/crc/yac_crc32.c b/storage/crc/yac_crc32.c
+index d4ac2c7..117eaea 100644
+--- a/storage/crc/yac_crc32.c
++++ b/storage/crc/yac_crc32.c
+@@ -381,13 +381,13 @@ static uint32_t slice8_core(char *dst, const char *data, unsigned int size) {
+ 		uint64_t w;
+ 
+ 		memcpy(&w, p, sizeof(uint64_t));
+-#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+-		w = __builtin_bswap64(w);
+-#endif
+ 		if (dst) {
+ 			memcpy(dst, &w, sizeof(uint64_t));
+ 			dst += sizeof(uint64_t);
+ 		}
++#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
++		w = __builtin_bswap64(w);
++#endif
+ 		crc ^= (uint32_t)w;
+ 		crc = yac_crc32c_tab[7][crc & 0xFF]
+ 			^ yac_crc32c_tab[6][(crc >> 8) & 0xFF]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-29  5:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-29  5:48 [rpms/php-pecl-yac] epel10: fix big endian build using upstream patch Remi Collet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox