git: 29cdc0e4fa59 - main - misc/mxnet: fix build with clang 19

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Fri, 15 Nov 2024 12:59:40 UTC
The branch main has been updated by dim:

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

commit 29cdc0e4fa5913e651735fcbcb2bfaa663d2515b
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-11-09 19:56:14 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-11-15 12:58:59 +0000

    misc/mxnet: fix build with clang 19
    
    Clang 19 now implements CWG 96 [1], which requires a template argument
    list after a 'template' keyword, resulting in errors similar to:
    
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
        358 |         template LaunchEx(s, new_oshape.Size(), req[0], lstride, rstride, oshape,
            |                  ^
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:358:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:389:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
        389 |         template LaunchEx(s, new_oshape.Size(), req[0], lstride, rstride, oshape,
            |                  ^
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:389:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:389:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
      /wrkdirs/usr/ports/misc/mxnet/work/incubator-mxnet-1.9.1/src/api/operator/numpy/../../../operator/numpy/../tensor/./elemwise_binary_broadcast_op.h:389:18: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
    
    In all these cases, appending "<>" is enough to satisfy the constraint.
    This can be done with a REINPLACE_CMD in the post-patch phase.
    
    [1] https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#96
    
    PR:             282654
    Approved by:    yuri (maintainer)
    MFH:            2024Q4
---
 misc/mxnet/Makefile | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/misc/mxnet/Makefile b/misc/mxnet/Makefile
index 22f8a44aba21..649f78ccb0f2 100644
--- a/misc/mxnet/Makefile
+++ b/misc/mxnet/Makefile
@@ -10,7 +10,6 @@ WWW=		https://mxnet.apache.org/ \
 
 LICENSE=	APACHE20
 
-BROKEN_FreeBSD_15=	compilation fails with clang-19, but the MXNet project has been retired by Apache and the port should probably be removed soon
 BROKEN_i386=	https://github.com/apache/incubator-mxnet/issues/20832
 .if !exists(/usr/include/omp.h)
 BROKEN=		requires OpenMP support that is missing on this architecture
@@ -57,11 +56,10 @@ OPENCV_LIB_DEPENDS=	libopencv_core.so:graphics/opencv \
 CMAKE_OFF+=	USE_SSE
 .endif
 
-xpost-patch:
-	@${RM} ${WRKSRC}/include/mkldnn/*
-.for h in dnnl.h dnnl.hpp mkldnn.h mkldnn.hpp mkldnn_dnnl_mangling.h mkldnn_types.h mkldnn_version.h
-	@${LN} -s ${LOCALBASE}/include/${h} ${WRKSRC}/include/mkldnn/${h}
-.endfor
+post-patch:
+	@${FIND} ${WRKSRC} -type f -name '*.h' | \
+	    ${XARGS} ${GREP} -l 'template LaunchEx' | \
+	    ${XARGS} ${REINPLACE_CMD} -E -e 's/(template LaunchEx)/\1<>/'
 
 post-install-CPP-on: # https://github.com/apache/incubator-mxnet/issues/17080
 	@cd ${STAGEDIR}${PREFIX} && ${RM} include/mxnet-cpp/.gitignore include/mxnet-cpp/CPPLINT.cfg