git: 01cc6a27117a - main - graphics/darktable: Build explicitly with GCC 12.x on FreeBSD 12.x

From: Jean-Sébastien Pédron <dumbbell_at_FreeBSD.org>
Date: Sun, 01 Oct 2023 20:40:29 UTC
The branch main has been updated by dumbbell:

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

commit 01cc6a27117a38079dd3b57e69455d7a191ca54a
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2023-10-01 20:30:13 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2023-10-01 20:37:57 +0000

    graphics/darktable: Build explicitly with GCC 12.x on FreeBSD 12.x
    
    On FreeBSD 12.x, it looks like GCC 13+ is incompatible with the version
    of libcxx. In the case of darktable, this leads to the following compile
    time error:
    
        In file included from /usr/include/c++/v1/__functional/weak_result_type.h:16,
                         from /usr/include/c++/v1/__functional/invoke.h:14,
                         from /usr/include/c++/v1/__functional_base:15,
                         from /usr/include/c++/v1/string:520,
                         from .../work/darktable-4.4.2/src/external/rawspeed/src/librawspeed/common/ChecksumFile.h:23,
                         from .../work/darktable-4.4.2/src/external/rawspeed/src/librawspeed/common/ChecksumFile.cpp:21:
        /usr/include/c++/v1/type_traits:1770:8: error: expected identifier before '__is_convertible'
         1770 | struct __is_convertible
              |        ^~~~~~~~~~~~~~~~
    
    I have no idea if it is possible to fix or work around this problem in
    darktable itself. Thus, on FreeBSD 12.x, we pin the version of GCC to
    12. This way, once GCC 13+ bescomes the default version, darktable can
    still be built on FreeBSD 12.x, even though the user may have to install
    two versions of GCC.
    
    For FreeBSD 13.x and onward, the version of GCC remains unpinned in the
    port and the default one will be used.
    
    This solution was discussed with salvadore@ in the following exp-run
    request:
    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273397
    
    PR:             273681
---
 graphics/darktable/Makefile | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/graphics/darktable/Makefile b/graphics/darktable/Makefile
index 02d5953cad65..1ee7fa64627a 100644
--- a/graphics/darktable/Makefile
+++ b/graphics/darktable/Makefile
@@ -53,8 +53,6 @@ USE_XORG=	ice sm x11 xext xrandr
 
 SHEBANG_FILES=	tools/*.sh
 
-USE_GCC=	yes
-
 CMAKE_ARGS+=	-DBINARY_PACKAGE_BUILD=1 -DUSE_PORTMIDI:BOOL=OFF
 
 CMAKE_BOOL+=	BUILD_CMSTEST USE_AVIF USE_CAMERA_SUPPORT USE_HEIF \
@@ -98,6 +96,32 @@ TOOLS_RUN_DEPENDS=	exiftool:graphics/p5-Image-ExifTool
 
 .include <bsd.port.options.mk>
 
+.if ${OPSYS}_${OSREL:R} == FreeBSD_12
+# Darktable fails to compile with GCC 13+ on FreeBSD 12.x with the following
+# error:
+#
+#   In file included from /usr/include/c++/v1/__functional/weak_result_type.h:16,
+#                    from /usr/include/c++/v1/__functional/invoke.h:14,
+#                    from /usr/include/c++/v1/__functional_base:15,
+#                    from /usr/include/c++/v1/string:520,
+#                    from .../work/darktable-4.4.2/src/external/rawspeed/src/librawspeed/common/ChecksumFile.h:23,
+#                    from .../work/darktable-4.4.2/src/external/rawspeed/src/librawspeed/common/ChecksumFile.cpp:21:
+#   /usr/include/c++/v1/type_traits:1770:8: error: expected identifier before '__is_convertible'
+#    1770 | struct __is_convertible
+#         |        ^~~~~~~~~~~~~~~~
+#
+# This seems to be an incompatibility between GCC 13+ and libcxx provided with
+# FreeBSD 12.x. The workarounbd is to force the use of GCC 12 on this version
+# of FreeBSD.
+#
+# See:
+#   https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273397
+#   https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273681
+USE_GCC=	12
+.else
+USE_GCC=	yes
+.endif
+
 .if ${ARCH} == aarch64 || ${ARCH} == powerpc64le
 CMAKE_ARGS+=	-DUSE_OPENCL:BOOL=OFF
 CXXFLAGS+=	-DGDK_DISABLE_DEPRECATED