git: ee627f94d287 - 2024Q4 - misc/mxnet: fix build with clang 19

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Fri, 15 Nov 2024 13:01:22 UTC
The branch 2024Q4 has been updated by dim:

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

commit ee627f94d287e900666c1ef31a81a01242c2b507
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-11-09 19:56:14 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-11-15 13:00:47 +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
    
    (cherry picked from commit 29cdc0e4fa5913e651735fcbcb2bfaa663d2515b)
---
 misc/mxnet/Makefile | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/misc/mxnet/Makefile b/misc/mxnet/Makefile
index ee952c7fc9b0..4a2071d5b1a4 100644
--- a/misc/mxnet/Makefile
+++ b/misc/mxnet/Makefile
@@ -52,11 +52,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