git: e53ce2ccfe89 - main - filesystems/openzfs: unbreak build on i386

From: Martin Matuska <mm_at_FreeBSD.org>
Date: Sun, 30 Mar 2025 00:19:00 UTC
The branch main has been updated by mm:

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

commit e53ce2ccfe89d39729a6d356124bb459457a82cd
Author:     Martin Matuska <mm@FreeBSD.org>
AuthorDate: 2025-03-30 00:18:14 +0000
Commit:     Martin Matuska <mm@FreeBSD.org>
CommitDate: 2025-03-30 00:18:14 +0000

    filesystems/openzfs: unbreak build on i386
---
 filesystems/openzfs/Makefile                       | 14 +++++++-
 .../openzfs/files/patch-cmd_zfs_zfs__main.c        | 26 +++++++++++++++
 .../openzfs/files/patch-cmd_zinject_zinject.c      | 32 ++++++++++++++++++
 .../files/patch-tests_zfs-tests_cmd_clonefile.c    | 39 ++++++++++++++++++++++
 ...s_tests_functional_vdev__disk_page__alignment.c | 29 ++++++++++++++++
 5 files changed, 139 insertions(+), 1 deletion(-)

diff --git a/filesystems/openzfs/Makefile b/filesystems/openzfs/Makefile
index a62e4223557f..55b213d81dd4 100644
--- a/filesystems/openzfs/Makefile
+++ b/filesystems/openzfs/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	openzfs
 PORTVERSION=	2.3.1
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	filesystems sysutils
 MASTER_SITES=   https://github.com/openzfs/zfs/releases/download/zfs-${PORTVERSION}/
@@ -53,6 +54,8 @@ CONFIGURE_ARGS+=	--without-python
 PYTHON_NO_DEPENDS=yes
 .endif
 
+.include <bsd.port.pre.mk>
+
 post-extract:
 	# Change certain shebangs into something that shebang fix understands
 	cd ${WRKSRC} && ${SED} -i '' '1s:@PYTHON_SHEBANG@:python3:' \
@@ -62,4 +65,13 @@ post-extract:
 		cmd/dbufstat.in \
 		cmd/zilstat.in
 
-.include <bsd.port.mk>
+post-patch:
+.if ${ARCH} == i386
+	${REINPLACE_CMD} \
+	-e 's,-c -o lib/libspl/libspl_la-atomic.lo,-Wno-error=atomic-alignment -c -o lib/libspl/libspl_la-atomic.lo,' \
+	-e 's,-c -o module/icp/algs/sha2/libicp_la-sha256_impl.lo,-Wno-unused-function -c -o module/icp/algs/sha2/libicp_la-sha256_impl.lo,' \
+	-e 's,-c -o module/icp/algs/sha2/libicp_la-sha512_impl.lo,-Wno-unused-function -c -o module/icp/algs/sha2/libicp_la-sha512_impl.lo,' \
+	${WRKSRC}/Makefile.in
+.endif
+
+.include <bsd.port.post.mk>
diff --git a/filesystems/openzfs/files/patch-cmd_zfs_zfs__main.c b/filesystems/openzfs/files/patch-cmd_zfs_zfs__main.c
new file mode 100644
index 000000000000..f2beed5672e1
--- /dev/null
+++ b/filesystems/openzfs/files/patch-cmd_zfs_zfs__main.c
@@ -0,0 +1,26 @@
+--- cmd/zfs/zfs_main.c.orig	2025-03-30 00:09:17 UTC
++++ cmd/zfs/zfs_main.c
+@@ -6845,7 +6845,11 @@ print_holds(boolean_t scripted, int nwidth, int tagwid
+ 
+ 			if (scripted) {
+ 				if (parsable) {
++#if defined(__FreeBSD__) && defined(__i386__)
++					(void) printf("%s\t%s\t%d\n", zname,
++#else
+ 					(void) printf("%s\t%s\t%ld\n", zname,
++#endif
+ 					    tagname, time);
+ 				} else {
+ 					(void) printf("%s\t%s\t%s\n", zname,
+@@ -6853,7 +6857,11 @@ print_holds(boolean_t scripted, int nwidth, int tagwid
+ 				}
+ 			} else {
+ 				if (parsable) {
++#if defined(__FreeBSD__) && defined(__i386__)
++					(void) printf("%-*s  %-*s  %d\n",
++#else
+ 					(void) printf("%-*s  %-*s  %ld\n",
++#endif
+ 					    nwidth, zname, tagwidth,
+ 					    tagname, time);
+ 				} else {
diff --git a/filesystems/openzfs/files/patch-cmd_zinject_zinject.c b/filesystems/openzfs/files/patch-cmd_zinject_zinject.c
new file mode 100644
index 000000000000..a817c794e5b7
--- /dev/null
+++ b/filesystems/openzfs/files/patch-cmd_zinject_zinject.c
@@ -0,0 +1,32 @@
+--- cmd/zinject/zinject.c.orig	2025-03-29 23:43:40 UTC
++++ cmd/zinject/zinject.c
+@@ -453,7 +453,8 @@ print_data_handler(int id, const char *pool, zinject_r
+ 
+ 
+ 	(void) printf("%3d  %-15s  %-6llu  %-6llu  %-8s  %-3d  0x%02x  %-15s  "
+-	    "%6lu  %6lu\n", id, pool, (u_longlong_t)record->zi_objset,
++	    "%6" PRIu64 "  %6" PRIu64 "\n", id, pool,
++	    (u_longlong_t)record->zi_objset,
+ 	    (u_longlong_t)record->zi_object, type_to_name(record->zi_type),
+ 	    record->zi_level, record->zi_dvas, rangebuf,
+ 	    record->zi_match_count, record->zi_inject_count);
+@@ -490,7 +491,8 @@ print_device_handler(int id, const char *pool, zinject
+ 	    (((double)record->zi_freq) / ZI_PERCENTAGE_MAX) * 100.0f;
+ 
+ 	(void) printf("%3d  %-15s  %llx  %-5s  %-10s  %8.4f%%  "
+-	    "%6lu  %6lu\n", id, pool, (u_longlong_t)record->zi_guid,
++	    "%6" PRIu64 "  %6" PRIu64 "\n", id, pool,
++	    (u_longlong_t)record->zi_guid,
+ 	    iotype_to_str(record->zi_iotype), err_to_str(record->zi_error),
+ 	    freq, record->zi_match_count, record->zi_inject_count);
+ 
+@@ -525,7 +527,8 @@ print_delay_handler(int id, const char *pool, zinject_
+ 	    (((double)record->zi_freq) / ZI_PERCENTAGE_MAX) * 100.0f;
+ 
+ 	(void) printf("%3d  %-15s  %llx  %10llu  %5llu  %8.4f%%  "
+-	    "%6lu  %6lu\n", id, pool, (u_longlong_t)record->zi_guid,
++	    "%6" PRIu64 "  %6" PRIu64 "\n", id, pool,
++	    (u_longlong_t)record->zi_guid,
+ 	    (u_longlong_t)NSEC2MSEC(record->zi_timer),
+ 	    (u_longlong_t)record->zi_nlanes,
+ 	    freq, record->zi_match_count, record->zi_inject_count);
diff --git a/filesystems/openzfs/files/patch-tests_zfs-tests_cmd_clonefile.c b/filesystems/openzfs/files/patch-tests_zfs-tests_cmd_clonefile.c
new file mode 100644
index 000000000000..5448993d1e7f
--- /dev/null
+++ b/filesystems/openzfs/files/patch-tests_zfs-tests_cmd_clonefile.c
@@ -0,0 +1,39 @@
+--- tests/zfs-tests/cmd/clonefile.c.orig	2025-03-10 22:42:59 UTC
++++ tests/zfs-tests/cmd/clonefile.c
+@@ -205,6 +205,7 @@ main(int argc, char **argv)
+ 
+ 	loff_t soff = 0, doff = 0;
+ 	size_t len = SSIZE_MAX;
++	unsigned long long len2;
+ 	if ((argc-optind) == 5) {
+ 		soff = strtoull(argv[optind+2], NULL, 10);
+ 		if (soff == ULLONG_MAX) {
+@@ -220,8 +221,8 @@ main(int argc, char **argv)
+ 		    strcmp(argv[optind+4], "all") == 0) {
+ 			len = SSIZE_MAX;
+ 		} else {
+-			len = strtoull(argv[optind+4], NULL, 10);
+-			if (len == ULLONG_MAX) {
++			len2 = strtoull(argv[optind+4], NULL, 10);
++			if (len2 == ULLONG_MAX) {
+ 				fprintf(stderr, "invalid length");
+ 				return (1);
+ 			}
+@@ -268,7 +269,7 @@ main(int argc, char **argv)
+ 		off_t dpos = lseek(dfd, 0, SEEK_CUR);
+ 		off_t dlen = lseek(dfd, 0, SEEK_END);
+ 
+-		fprintf(stderr, "file offsets: src=%lu/%lu; dst=%lu/%lu\n",
++		fprintf(stderr, "file offsets: src=%jd/%jd; dst=%jd/%jd\n",
+ 		    spos, slen, dpos, dlen);
+ 	}
+ 
+@@ -331,7 +332,7 @@ do_copyfilerange(int sfd, int dfd, loff_t soff, loff_t
+ 	}
+ 	if (copied != len) {
+ 		fprintf(stderr, "copy_file_range: copied less than requested: "
+-		    "requested=%lu; copied=%lu\n", len, copied);
++		    "requested=%zu; copied=%zd\n", len, copied);
+ 		return (1);
+ 	}
+ 	return (0);
diff --git a/filesystems/openzfs/files/patch-tests_zfs-tests_tests_functional_vdev__disk_page__alignment.c b/filesystems/openzfs/files/patch-tests_zfs-tests_tests_functional_vdev__disk_page__alignment.c
new file mode 100644
index 000000000000..3a78abbb89d2
--- /dev/null
+++ b/filesystems/openzfs/files/patch-tests_zfs-tests_tests_functional_vdev__disk_page__alignment.c
@@ -0,0 +1,29 @@
+--- tests/zfs-tests/tests/functional/vdev_disk/page_alignment.c.orig	2025-03-30 00:02:54 UTC
++++ tests/zfs-tests/tests/functional/vdev_disk/page_alignment.c
+@@ -420,14 +420,14 @@ run_test(const page_test_t *test, bool verbose)
+ 		size_t take = MIN(rem, len);
+ 
+ 		if (verbose)
+-			printf("  page %d [off %lx len %lx], "
+-			    "rem %lx, take %lx\n",
++			printf("  page %d [off %zx len %zx], "
++			    "rem %zx, take %zx\n",
+ 			    i, off, len, rem, take);
+ 
+ 		if (vdev_disk_check_alignment_cb(NULL, off, take, &s)) {
+ 			if (verbose)
+ 				printf("  ABORT: misalignment detected, "
+-				    "rem %lx\n", rem);
++				    "rem %zx\n", rem);
+ 			return (false);
+ 		}
+ 
+@@ -438,7 +438,7 @@ run_test(const page_test_t *test, bool verbose)
+ 
+ 	if (rem > 0) {
+ 		if (verbose)
+-			printf("  ABORT: ran out of pages, rem %lx\n", rem);
++			printf("  ABORT: ran out of pages, rem %zx\n", rem);
+ 		return (false);
+ 	}
+