git: e6a60afa18ab - main - databases/xtrabackup80: make it buildable on i386

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Tue, 14 May 2024 06:09:11 UTC
The branch main has been updated by eugen:

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

commit e6a60afa18abd01d0ea4b553ebb2c5f702b2b94a
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2024-05-14 06:05:39 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2024-05-14 06:05:39 +0000

    databases/xtrabackup80: make it buildable on i386
    
    Modern clang cannot build the port on i386 systems.
    Use GCC13 to make working package.
    
    Approved by:    Eugene M. Zheganin (maintainer)
---
 databases/xtrabackup80/Makefile                    | 75 ++++++++++++++--------
 .../files/patch-cmake_os_FreeBSD.cmake             | 23 -------
 databases/xtrabackup80/pkg-plist.i386              | 55 ++++++++++++++++
 3 files changed, 103 insertions(+), 50 deletions(-)

diff --git a/databases/xtrabackup80/Makefile b/databases/xtrabackup80/Makefile
index 65315e7d2baf..84640040fc1a 100644
--- a/databases/xtrabackup80/Makefile
+++ b/databases/xtrabackup80/Makefile
@@ -14,17 +14,6 @@ WWW=		https://www.percona.com/doc/percona-xtrabackup/
 LICENSE=	GPLv2
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-BUILD_DEPENDS=	protobuf>=3.0:devel/protobuf \
-		rapidjson>=1.1.0:devel/rapidjson \
-		libevent>=2.1:devel/libevent
-LIB_DEPENDS=	libcurl.so:ftp/curl \
-		libev.so:devel/libev \
-		libgcrypt.so:security/libgcrypt \
-		libgpg-error.so:security/libgpg-error \
-		libicudata.so:devel/icu \
-		libprotobuf-lite.so:devel/protobuf \
-		libunwind.so:devel/libunwind \
-		libzstd.so:archivers/zstd
 RUN_DEPENDS=	qpress:archivers/qpress
 
 USES=		bison cmake compiler:c++14-lang cpe pkgconfig ssl
@@ -33,10 +22,6 @@ CMAKE_ARGS=	-DBUILD_CONFIG:STRING=xtrabackup_release \
 		-DWITHOUT_COMPONENT_KEYRING_KMIP:STRING=yes \
 		-DWITH_VERSION_CHECK=false
 
-.for component in EDITLINE ICU LIBEVENT PROTOBUF RAPIDJSON ZSTD
-CMAKE_ARGS+=	-DWITH_${component}:STRING=system
-.endfor
-
 CONFLICTS_INSTALL=	${PORTNAME:C/.$//}*
 
 # Bundle last supported Boost release
@@ -56,22 +41,48 @@ WRKSRC=		${WRKDIR}/${PPORTNAME}-${DVERSION}
 .include <bsd.port.pre.mk>
 
 # Since MySQL 8.0.20 InnoDB engine uses new memory alligned allocator
-# which is broken on i386 due to different size of types and causes a
-# 'static_assert(alignof(T) <= alignof(std::max_align_t))' error
+# which is broken on i386 with Clang due to different size of types
+# and causes a 'static_assert(alignof(T) <= alignof(std::max_align_t))' error
 .if ${ARCH} == i386
-CXXFLAGS+=	-malign-double
-.endif
+GCCVER=		13
+CC=		${PREFIX}/bin/gcc${GCCVER}
+CXX=		${PREFIX}/bin/g++${GCCVER}
+CPP=		${PREFIX}/bin/cpp${GCCVER}
+CXXFLAGS+=	--std=c++17 -march=i586
+LDFLAGS_i386=	-latomic -Wl,-rpath=${PREFIX}/lib/gcc${GCCVER} -Wl,-rpath=${PREFIX}/lib/private
+PLIST=		${PKGDIR}/pkg-plist.i386
+USE_LDCONFIG=	${PREFIX}/lib/private
+
+BUILD_DEPENDS=	c++${GCCVER}:lang/gcc${GCCVER}
+LIB_DEPENDS=	libcurl.so:ftp/curl \
+		libev.so:devel/libev \
+		libgcrypt.so:security/libgcrypt \
+		libgpg-error.so:security/libgpg-error \
+		libunwind.so:devel/libunwind
 
-KEEP_EXTRA=	lz4 robin-hood-hashing zlib
+RUN_DEPENDS=	${PREFIX}/lib/gcc${GCCVER}/libatomic.so.1:lang/gcc${GCCVER}
 
-post-patch:
-.for d in storage/innobase/xtrabackup/src sql/protobuf
-	${REINPLACE_CMD} 's,%%PREFIX%%,${PREFIX},' ${WRKSRC}/${d}/CMakeLists.txt
+.for component in EDITLINE ICU LIBEVENT PROTOBUF RAPIDJSON ZSTD
+CMAKE_ARGS+=	-DWITH_${component}:STRING=bundled
 .endfor
-.if ${COMPILER_TYPE} == clang && ${COMPILER_VERSION} >= 160
-	@${REINPLACE_CMD} -e 's|std::unary_function|std::__unary_function|' \
-		${WRKSRC}/../boost_${BOOST_VERSION_UNDER}/boost/container_hash/hash.hpp
-.endif
+.else
+BUILD_DEPENDS=	protobuf>=3.0:devel/protobuf \
+		rapidjson>=1.1.0:devel/rapidjson \
+		libevent>=2.1:devel/libevent
+LIB_DEPENDS=	libcurl.so:ftp/curl \
+		libev.so:devel/libev \
+		libgcrypt.so:security/libgcrypt \
+		libgpg-error.so:security/libgpg-error \
+		libicudata.so:devel/icu \
+		libprotobuf-lite.so:devel/protobuf \
+		libunwind.so:devel/libunwind \
+		libzstd.so:archivers/zstd
+
+.for component in EDITLINE ICU LIBEVENT PROTOBUF RAPIDJSON ZSTD
+CMAKE_ARGS+=	-DWITH_${component}:STRING=system
+.endfor
+
+KEEP_EXTRA=	lz4 robin-hood-hashing zlib
 
 pre-configure:
 .for dir in ${KEEP_EXTRA}
@@ -81,6 +92,16 @@ pre-configure:
 .for dir in ${KEEP_EXTRA}
 	@${MV} ${WRKDIR}/${dir} ${WRKSRC}/extra
 .endfor
+.endif
+
+post-patch:
+.for d in storage/innobase/xtrabackup/src sql/protobuf
+	${REINPLACE_CMD} 's,%%PREFIX%%,${PREFIX},' ${WRKSRC}/${d}/CMakeLists.txt
+.endfor
+.if ${COMPILER_TYPE} == clang && ${COMPILER_VERSION} >= 160
+	@${REINPLACE_CMD} -e 's|std::unary_function|std::__unary_function|' \
+		${WRKSRC}/../boost_${BOOST_VERSION_UNDER}/boost/container_hash/hash.hpp
+.endif
 
 post-stage:
 	@${RM} -r ${STAGEDIR}${PREFIX}/docs ${STAGEDIR}${PREFIX}/man
diff --git a/databases/xtrabackup80/files/patch-cmake_os_FreeBSD.cmake b/databases/xtrabackup80/files/patch-cmake_os_FreeBSD.cmake
deleted file mode 100644
index 624f462e7542..000000000000
--- a/databases/xtrabackup80/files/patch-cmake_os_FreeBSD.cmake
+++ /dev/null
@@ -1,23 +0,0 @@
---- cmake/os/FreeBSD.cmake.orig	2020-05-26 05:35:19 UTC
-+++ cmake/os/FreeBSD.cmake
-@@ -36,6 +36,20 @@ IF(NOT FORCE_UNSUPPORTED_COMPILER)
-     IF(GCC_VERSION VERSION_LESS 4.4)
-       MESSAGE(FATAL_ERROR "GCC 4.4 or newer is required!")
-     ENDIF()
-+    CHECK_C_SOURCE_RUNS("
-+      int main()
-+      {
-+        return (__clang_major__ >= 4);
-+      }" I386_ATOMIC_BUILTINS)
-+    IF((CMAKE_SYSTEM_PROCESSOR MATCHES "i386") AND (NOT I386_ATOMIC_BUILTINS))
-+      SET(HAVE_GCC_ATOMIC_BUILTINS CACHE  INTERNAL "")
-+    ENDIF()
-+  ELSEIF(CMAKE_COMPILER_IS_GNUCC)
-+    EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion
-+                    OUTPUT_VARIABLE GCC_VERSION)
-+    IF(GCC_VERSION VERSION_LESS 4.4)
-+      MESSAGE(FATAL_ERROR "GCC 4.4 or newer is required!")
-+    ENDIF()
-   ELSE()
-     MESSAGE(FATAL_ERROR "Unsupported compiler!")
-   ENDIF()
diff --git a/databases/xtrabackup80/pkg-plist.i386 b/databases/xtrabackup80/pkg-plist.i386
new file mode 100644
index 000000000000..d40f9d36c930
--- /dev/null
+++ b/databases/xtrabackup80/pkg-plist.i386
@@ -0,0 +1,55 @@
+bin/xbcloud
+bin/xbcloud_osenv
+bin/xbcrypt
+bin/xbstream
+bin/xtrabackup
+lib/libmysqlservices.a
+lib/plugin/component_keyring_file.so
+lib/plugin/component_keyring_kms.so
+lib/plugin/keyring_file.so
+lib/plugin/keyring_vault.so
+lib/private/icudt73l/brkitr/burmesedict.dict
+lib/private/icudt73l/brkitr/char.brk
+lib/private/icudt73l/brkitr/cjdict.dict
+lib/private/icudt73l/brkitr/de.res
+lib/private/icudt73l/brkitr/el.res
+lib/private/icudt73l/brkitr/en.res
+lib/private/icudt73l/brkitr/en_US.res
+lib/private/icudt73l/brkitr/en_US_POSIX.res
+lib/private/icudt73l/brkitr/es.res
+lib/private/icudt73l/brkitr/fi.res
+lib/private/icudt73l/brkitr/fr.res
+lib/private/icudt73l/brkitr/it.res
+lib/private/icudt73l/brkitr/ja.res
+lib/private/icudt73l/brkitr/khmerdict.dict
+lib/private/icudt73l/brkitr/ko.res
+lib/private/icudt73l/brkitr/laodict.dict
+lib/private/icudt73l/brkitr/line.brk
+lib/private/icudt73l/brkitr/line_cj.brk
+lib/private/icudt73l/brkitr/line_loose.brk
+lib/private/icudt73l/brkitr/line_loose_cj.brk
+lib/private/icudt73l/brkitr/line_loose_phrase_cj.brk
+lib/private/icudt73l/brkitr/line_normal.brk
+lib/private/icudt73l/brkitr/line_normal_cj.brk
+lib/private/icudt73l/brkitr/line_normal_phrase_cj.brk
+lib/private/icudt73l/brkitr/line_phrase_cj.brk
+lib/private/icudt73l/brkitr/pt.res
+lib/private/icudt73l/brkitr/res_index.res
+lib/private/icudt73l/brkitr/root.res
+lib/private/icudt73l/brkitr/ru.res
+lib/private/icudt73l/brkitr/sent.brk
+lib/private/icudt73l/brkitr/sent_el.brk
+lib/private/icudt73l/brkitr/sv.res
+lib/private/icudt73l/brkitr/thaidict.dict
+lib/private/icudt73l/brkitr/title.brk
+lib/private/icudt73l/brkitr/word.brk
+lib/private/icudt73l/brkitr/word_POSIX.brk
+lib/private/icudt73l/brkitr/word_fi_sv.brk
+lib/private/icudt73l/brkitr/zh.res
+lib/private/icudt73l/brkitr/zh_Hant.res
+lib/private/icudt73l/cnvalias.icu
+lib/private/icudt73l/uemoji.icu
+lib/private/icudt73l/ulayout.icu
+lib/private/icudt73l/unames.icu
+lib/private/libprotobuf-lite.so.3.19.4
+lib/private/libprotobuf.so.3.19.4