git: f041aca7adf2 - 2022Q2 - devel/libunwind: use base system unwind.h

From: Tijl Coosemans <tijl_at_FreeBSD.org>
Date: Wed, 27 Apr 2022 17:04:52 UTC
The branch 2022Q2 has been updated by tijl:

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

commit f041aca7adf2d5ee3742d2c3e98fdc4e7c045fe5
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2022-04-27 16:51:01 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2022-04-27 16:59:02 +0000

    devel/libunwind: use base system unwind.h
    
    - Add --disable-cxx-exceptions so libunwind does not implement the
      _Unwind_* API and does not use its internal unwind.h.  The base
      system libgcc_s provides this API.  This was already the upstream
      default for most architectures.
    - Add --disable-unwind-header to prevent installation of unwind.h.
      Instead, install an unwind.h that forwards to the base system
      unwind.h, but not on FreeBSD 14 where all implementations of
      unwind.h (base, lang/gcc*, and devel/llvm*) are compatible.
    
    PR:             263370
    Approved by:    sunpoet
    
    (cherry picked from commit 975a5c1057579603c4041c2b8e3ac0933ea0eb89)
---
 devel/libunwind/Makefile       | 11 ++++++++++-
 devel/libunwind/files/unwind.h | 26 ++++++++++++++++++++++++++
 devel/libunwind/pkg-plist      |  1 -
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/devel/libunwind/Makefile b/devel/libunwind/Makefile
index a404f9df3595..5ab156895129 100644
--- a/devel/libunwind/Makefile
+++ b/devel/libunwind/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	libunwind
 PORTVERSION=	20211201	# This is the release date on https://download.savannah.gnu.org/releases/libunwind/
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	SAVANNAH \
 		https://github.com/libunwind/libunwind/releases/download/v${PORTVERSION}/
@@ -17,7 +18,9 @@ ONLY_FOR_ARCHS=	aarch64 amd64 armv6 armv7 i386 powerpc64 powerpc64le
 
 USES=		compiler:c11 cpe libtool pathfix pkgconfig
 
-CONFIGURE_ARGS=	ac_cv_path_LATEX2MAN=${TRUE}
+CONFIGURE_ARGS=	--disable-cxx-exceptions \
+		--disable-unwind-header \
+		ac_cv_path_LATEX2MAN=${TRUE}
 GNU_CONFIGURE=	yes
 INSTALL_TARGET=	install-strip
 USE_LDCONFIG=	yes
@@ -34,4 +37,10 @@ PLIST_SUB+=	COREDUMP=""
 PLIST_SUB+=	COREDUMP="@comment "
 .endif
 
+.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1400052
+PLIST_FILES+=	include/unwind.h
+post-install:
+	${INSTALL_DATA} ${FILESDIR}/unwind.h ${STAGEDIR}${PREFIX}/include
+.endif
+
 .include <bsd.port.post.mk>
diff --git a/devel/libunwind/files/unwind.h b/devel/libunwind/files/unwind.h
new file mode 100644
index 000000000000..2d79ed4428de
--- /dev/null
+++ b/devel/libunwind/files/unwind.h
@@ -0,0 +1,26 @@
+#ifndef _LIBUNWIND_UNWIND_H
+#define _LIBUNWIND_UNWIND_H
+
+#if __has_include("/usr/include/unwind.h")
+#include "/usr/include/unwind.h"
+#elif __has_include("/usr/include/c++/v1/unwind.h")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#include "/usr/include/c++/v1/unwind-arm.h"
+#else
+#include "/usr/include/c++/v1/unwind-itanium.h"
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#else
+#include_next <unwind.h>
+#endif
+
+#endif
diff --git a/devel/libunwind/pkg-plist b/devel/libunwind/pkg-plist
index a776ec5d56b2..73e648228c4a 100644
--- a/devel/libunwind/pkg-plist
+++ b/devel/libunwind/pkg-plist
@@ -4,7 +4,6 @@ include/libunwind-dynamic.h
 include/libunwind-ptrace.h
 include/libunwind-%%ARCH%%.h
 include/libunwind.h
-include/unwind.h
 %%COREDUMP%%lib/libunwind-coredump.a
 %%COREDUMP%%lib/libunwind-coredump.so
 %%COREDUMP%%lib/libunwind-coredump.so.0