git: 73f0aa653a34 - 2022Q2 - misc/mbuffer: Fix build on 12.3-RELEASE aarch64

From: Fukang Chen <loader_at_FreeBSD.org>
Date: Sun, 15 May 2022 04:58:36 UTC
The branch 2022Q2 has been updated by loader:

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

commit 73f0aa653a348b4301e10e352c6aca7aed4853ee
Author:     Fukang Chen <loader@FreeBSD.org>
AuthorDate: 2022-05-15 03:03:24 +0000
Commit:     Fukang Chen <loader@FreeBSD.org>
CommitDate: 2022-05-15 04:57:17 +0000

    misc/mbuffer: Fix build on 12.3-RELEASE aarch64
    
    https://lists.freebsd.org/archives/freebsd-pkg-fallout/2022-May/240425.html
    
    MFH:            2022Q2 (build fix)
    (cherry picked from commit 766053a588ce4c29fb8d59cddcede448e5e60812)
---
 misc/mbuffer/Makefile               |  8 ++++-
 misc/mbuffer/files/extra-patch-12.3 | 61 +++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/misc/mbuffer/Makefile b/misc/mbuffer/Makefile
index 00fcb87f9c37..bd2650e2575b 100644
--- a/misc/mbuffer/Makefile
+++ b/misc/mbuffer/Makefile
@@ -32,6 +32,12 @@ GCRYPT_RUN_DEPENDS=	libgcrypt>=1.8.4_1:security/libgcrypt
 MHASH_RUN_DEPENDS=	mhash>=0.9.9.9_5:security/mhash
 RHASH_RUN_DEPENDS=	rhash>=1.3.5:security/rhash
 
+.include <bsd.port.pre.mk>
+
+.if ${ARCH} == aarch64 && ${OSVERSION} < 1300000
+EXTRA_PATCHES=	${PATCHDIR}/extra-patch-12.3
+.endif
+
 post-patch:
 	${REINPLACE_CMD} \
 		-e 's@bash@sh@' ${WRKSRC}/Makefile.in
@@ -41,4 +47,4 @@ post-install:
 	${MV} ${STAGEDIR}${PREFIX}/etc/mbuffer.rc \
 		${STAGEDIR}${PREFIX}/etc/mbuffer.rc.sample
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff --git a/misc/mbuffer/files/extra-patch-12.3 b/misc/mbuffer/files/extra-patch-12.3
new file mode 100644
index 000000000000..c60d49818579
--- /dev/null
+++ b/misc/mbuffer/files/extra-patch-12.3
@@ -0,0 +1,61 @@
+- cc(1) crashes with "-g" on FreeBSD 12.3-RELEASE aarch64
+
+  cc: error: unable to execute command: Abort trap (core dumped)
+  cc: error: clang frontend command failed due to signal (use -v to see invocation)
+  FreeBSD clang version 10.0.1 (git@github.com:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2)
+  Target: aarch64-unknown-freebsd12.3
+  Thread model: posix
+  InstalledDir: /usr/bin
+  cc: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
+  cc: note: diagnostic msg:
+  ********************
+
+  PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
+  Preprocessed source(s) and associated run script(s) are located at:
+  cc: note: diagnostic msg: /tmp/idev-47a323.c
+  cc: note: diagnostic msg: /tmp/idev-47a323.sh
+  cc: note: diagnostic msg:
+
+  ********************
+  gmake[1]: *** [Makefile:197: idev.so] Error 254
+  gmake[1]: Leaving directory '/usr/ports/misc/mbuffer/work/mbuffer-20211018'
+
+- llvm-objdump(1) does not support "-T" on FreeBSD 12.3-RELEASE aarch64
+
+--- Makefile.in.orig	2022-05-14 11:38:27 UTC
++++ Makefile.in
+@@ -194,7 +194,7 @@ tapetest.so: tapetest.c config.h
+ 	$(CC) $(CFLAGS) -shared -fPIC tapetest.c -o $@ $(LIBS)
+ 
+ idev.so: idev.c config.h
+-	$(CC) $(CFLAGS) -shared -g -fPIC idev.c -o $@ $(LIBS)
++	$(CC) $(CFLAGS) -shared -fPIC idev.c -o $@ $(LIBS)
+ 
+ $(DEPS): | build
+ 
+--- configure.in.orig	2022-05-14 11:37:04 UTC
++++ configure.in
+@@ -173,19 +173,19 @@ else
+ 	]])],[
+ 	AC_MSG_RESULT([OK])
+ 	AC_MSG_CHECKING([name of open() in C library])
+-	libc_open=`$OBJDUMP -T conftest | $AWK '/\*UND\*/ && $NF ~ /^open/ { print $NF }'`
++	libc_open=`$OBJDUMP -t conftest | $AWK '/\*UND\*/ && $NF ~ /^open/ { print $NF }'`
+ 	AC_DEFINE_UNQUOTED([LIBC_OPEN], $libc_open, [name of open() in libc])
+ 	AC_MSG_RESULT($libc_open)
+ 	AC_MSG_CHECKING([name of read() in C library])
+-	libc_read=`$OBJDUMP -T conftest | $AWK '/\*UND\*/ && $NF ~ /^read/ { print $NF }'`
++	libc_read=`$OBJDUMP -t conftest | $AWK '/\*UND\*/ && $NF ~ /^read/ { print $NF }'`
+ 	AC_DEFINE_UNQUOTED([LIBC_READ], $libc_read, [name of write() in libc])
+ 	AC_MSG_RESULT($libc_read)
+ 	AC_MSG_CHECKING([name of write() in C library])
+-	libc_write=`$OBJDUMP -T conftest | $AWK '/\*UND\*/ && $NF ~ /^write/ { print $NF }'`
++	libc_write=`$OBJDUMP -t conftest | $AWK '/\*UND\*/ && $NF ~ /^write/ { print $NF }'`
+ 	AC_DEFINE_UNQUOTED([LIBC_WRITE], $libc_write, [name of write() in libc])
+ 	AC_MSG_RESULT($libc_write)
+ 	AC_MSG_CHECKING([name of fstat() in C library])
+-	libc_fstat=`$OBJDUMP -T conftest | $AWK '/\*UND\*/ && $NF ~ /^_*fstat/ { print $NF }'`
++	libc_fstat=`$OBJDUMP -t conftest | $AWK '/\*UND\*/ && $NF ~ /^_*fstat/ { print $NF }'`
+ 	AC_DEFINE_UNQUOTED([LIBC_FSTAT], $libc_fstat, [name of fstat() in libc])
+ 	AC_MSG_RESULT($libc_fstat)
+ 	],