git: a4de2fe2eeeb - main - databases/clickhouse-devel: enable on powerpc64le

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Fri, 16 Oct 2026 14:14:53 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a4de2fe2eeeb419e50ef6bb232e828342744c7c2

commit a4de2fe2eeeb419e50ef6bb232e828342744c7c2
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-10-14 17:05:58 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-10-16 14:13:52 +0000

    databases/clickhouse-devel: enable on powerpc64le
    
    The bundled OpenSSL ships POWER8 assembly pre-generated with the
    big-endian "linux64v2" perlasm flavour, which gives wrong AES results
    on little-endian. Regenerate it with "linux64le" before configuring.
    
    Until rtld annotates the end of the stack on powerpc64, the bundled
    libunwind crashes when it collects a backtrace on the main thread.
    Drop its fallback to the link register, as the base libunwind does.
---
 databases/clickhouse-devel/Makefile                | 17 +++++++++++--
 ...lvm-project_libunwind_src_DwarfInstructions.hpp | 13 ++++++++++
 .../patch-contrib_openldap-cmake_CMakeLists.txt    | 28 ++++++++++++++++++++++
 .../patch-contrib_openssl-cmake_CMakeLists.txt     | 14 +++++++++++
 ..._range_range__tree_lib_portability_toku__time.h | 25 +++++++++++++++++++
 5 files changed, 95 insertions(+), 2 deletions(-)

diff --git a/databases/clickhouse-devel/Makefile b/databases/clickhouse-devel/Makefile
index dd04cc05a116..94a035de8331 100644
--- a/databases/clickhouse-devel/Makefile
+++ b/databases/clickhouse-devel/Makefile
@@ -16,8 +16,8 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 
 CONFLICTS_INSTALL=	clickhouse-[0-9]*
 
-ONLY_FOR_ARCHS=	aarch64 amd64
-ONLY_FOR_ARCHS_REASON=	only supported on aarch64 and amd64
+ONLY_FOR_ARCHS=	aarch64 amd64 powerpc64le
+ONLY_FOR_ARCHS_REASON=	only supported on aarch64, amd64 and powerpc64le
 
 BUILD_DEPENDS=	bash:shells/bash \
 	gfind:misc/findutils \
@@ -89,6 +89,10 @@ USES+=	llvm:min=21
 CFLAGS+=-Wno-error=int-conversion
 .endif
 
+.if ${ARCH:Mpowerpc64*} && ${OSVERSION} < 1600028
+EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-contrib_llvm-project_libunwind_src_DwarfInstructions.hpp
+.endif
+
 .if ${OPSYS} == FreeBSD
 SUB_LIST+=	LEGACY_LIMITS="@comment " \
 		MODERN_LIMITS=""
@@ -109,6 +113,15 @@ post-patch:
 	@${REINPLACE_CMD} -e '/clickhouse-docker-init/d; /add_subdirectory \(docker-init\)/d' ${WRKSRC}/programs/CMakeLists.txt
 	@${REINPLACE_CMD} -e '/mainEntryClickHouseDockerInit/d' ${WRKSRC}/programs/main.cpp
 
+.if ${ARCH} == powerpc64le
+# Bundled pre-generated POWER8 asm lacks the little-endian fixups
+pre-configure:
+.  for f in aes/aesp8-ppc modes/ghashp8-ppc modes/aes-gcm-ppc
+	${PERL} ${WRKSRC}/contrib/openssl/crypto/${f:H}/asm/${f:T}.pl linux64le \
+		${WRKSRC}/contrib/openssl-cmake/asm/crypto/${f}.s
+.  endfor
+.endif
+
 post-install:
 	@${RM} ${STAGEDIR}${PREFIX}/bin/config-processor
 	@${RM} -r ${STAGEDIR}${PREFIX}/include/gtest
diff --git a/databases/clickhouse-devel/files/extra-patch-contrib_llvm-project_libunwind_src_DwarfInstructions.hpp b/databases/clickhouse-devel/files/extra-patch-contrib_llvm-project_libunwind_src_DwarfInstructions.hpp
new file mode 100644
index 000000000000..07d17d4e8270
--- /dev/null
+++ b/databases/clickhouse-devel/files/extra-patch-contrib_llvm-project_libunwind_src_DwarfInstructions.hpp
@@ -0,0 +1,13 @@
+--- contrib/llvm-project/libunwind/src/DwarfInstructions.hpp.orig	2026-06-10 14:59:56 UTC
++++ contrib/llvm-project/libunwind/src/DwarfInstructions.hpp
+@@ -292,10 +292,6 @@ int DwarfInstructions<A, R>::stepWithDwarf(
+                                     prolog.savedRegisters[i]));
+           else
+             return UNW_EBADREG;
+-        } else if (i == (int)cieInfo.returnAddressRegister) {
+-            // Leaf function keeps the return address in register and there is no
+-            // explicit instructions how to restore it.
+-            returnAddress = registers.getRegister(cieInfo.returnAddressRegister);
+         }
+       }
+ 
diff --git a/databases/clickhouse-devel/files/patch-contrib_openldap-cmake_CMakeLists.txt b/databases/clickhouse-devel/files/patch-contrib_openldap-cmake_CMakeLists.txt
new file mode 100644
index 000000000000..61638ff9c5f7
--- /dev/null
+++ b/databases/clickhouse-devel/files/patch-contrib_openldap-cmake_CMakeLists.txt
@@ -0,0 +1,28 @@
+--- contrib/openldap-cmake/CMakeLists.txt.orig	2026-10-13 00:00:00 UTC
++++ contrib/openldap-cmake/CMakeLists.txt
+@@ -14,6 +14,8 @@
+     set (_system_processor "x86_64")
+ elseif ("${_system_processor}" STREQUAL "arm64")
+     set (_system_processor "aarch64")
++elseif ("${_system_processor}" STREQUAL "powerpc64le")
++    set (_system_processor "ppc64le")
+ endif ()
+ if (NOT(
+     ( "${_system_name}" STREQUAL "linux"   AND "${_system_processor}" STREQUAL "x86_64"  ) OR
+@@ -23,6 +25,7 @@
+     ( "${_system_name}" STREQUAL "linux"   AND "${_system_processor}" STREQUAL "loongarch64") OR
+     ( "${_system_name}" STREQUAL "freebsd" AND "${_system_processor}" STREQUAL "x86_64"  ) OR
+     ( "${_system_name}" STREQUAL "freebsd" AND "${_system_processor}" STREQUAL "aarch64" ) OR
++    ( "${_system_name}" STREQUAL "freebsd" AND "${_system_processor}" STREQUAL "ppc64le" ) OR
+     ( "${_system_name}" STREQUAL "darwin"  AND "${_system_processor}" STREQUAL "x86_64"  ) OR
+     ( "${_system_name}" STREQUAL "darwin"  AND "${_system_processor}" STREQUAL "aarch64"   )
+ ))
+@@ -58,6 +61,8 @@
+     "${_system_processor}" STREQUAL "arm64"
+ )
+     set (_system_processor "aarch64")
++elseif("${_system_processor}" STREQUAL "powerpc64le")
++    set (_system_processor "ppc64le")
+ endif()
+ 
+ set(_extra_build_dir "${CMAKE_CURRENT_SOURCE_DIR}/${_system_name}_${_system_processor}")
diff --git a/databases/clickhouse-devel/files/patch-contrib_openssl-cmake_CMakeLists.txt b/databases/clickhouse-devel/files/patch-contrib_openssl-cmake_CMakeLists.txt
new file mode 100644
index 000000000000..86eac111ba6e
--- /dev/null
+++ b/databases/clickhouse-devel/files/patch-contrib_openssl-cmake_CMakeLists.txt
@@ -0,0 +1,14 @@
+--- contrib/openssl-cmake/CMakeLists.txt.orig	2026-10-13 00:00:00 UTC
++++ contrib/openssl-cmake/CMakeLists.txt
+@@ -1220,8 +1220,10 @@
+         ${OPENSSL_SOURCE_DIR}/crypto/rc4/rc4_skey.c
+         ${OPENSSL_SOURCE_DIR}/crypto/sha/keccak1600.c
+         ${OPENSSL_SOURCE_DIR}/crypto/whrlpool/wp_block.c
+-        ${OPENSSL_SOURCE_DIR}/engines/e_afalg.c
+     )
++    if (OS_LINUX)
++        set(CRYPTO_SRC ${CRYPTO_SRC} ${OPENSSL_SOURCE_DIR}/engines/e_afalg.c)
++    endif()
+ elseif(ARCH_S390X)
+     set(CRYPTO_SRC ${CRYPTO_SRC}
+         asm/crypto/aes/aes-s390x.S
diff --git a/databases/clickhouse-devel/files/patch-contrib_rocksdb_utilities_transactions_lock_range_range__tree_lib_portability_toku__time.h b/databases/clickhouse-devel/files/patch-contrib_rocksdb_utilities_transactions_lock_range_range__tree_lib_portability_toku__time.h
new file mode 100644
index 000000000000..a8eb647693b9
--- /dev/null
+++ b/databases/clickhouse-devel/files/patch-contrib_rocksdb_utilities_transactions_lock_range_range__tree_lib_portability_toku__time.h
@@ -0,0 +1,25 @@
+--- contrib/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h.orig	2026-10-14 00:00:00 UTC
++++ contrib/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h
+@@ -58,7 +58,7 @@
+ #include <stdint.h>
+ #include <sys/time.h>
+ #include <time.h>
+-#if defined(__powerpc__)
++#if defined(__powerpc__) && defined(__linux__)
+ #include <sys/platform/ppc.h>
+ #endif
+ 
+@@ -132,7 +132,13 @@
+   __asm __volatile__("mrs %[rt], cntvct_el0" : [rt] "=r"(result));
+   return result;
+ #elif defined(__powerpc__)
++#ifdef __linux__
+   return __ppc_get_timebase();
++#elif defined(__FreeBSD__)
++  int64_t tbr;
++  asm volatile("mfspr %0, 268" : "=r"(tbr));
++  return tbr;
++#endif
+ #elif defined(__s390x__)
+   uint64_t result;
+   asm volatile("stckf %0" : "=Q"(result) : : "cc");