Skip to content

Commit c0faf34

Browse files
jsquyresggouaillardet
authored andcommitted
ompi_ext.m4: ensure ext name <= 26 characters
Ensure that MPI extensions with mpif.h bindings have names that are <=26 characters long. 26 is the magic number that still allows us to have an "include ..." line in the user-facing mpif-ext.h header file that includes this extension's header file without going over 72 characters. Signed-off-by: Jeff Squyres <jsquyres@cisco.com> Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent 975e3cd commit c0faf34

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

config/ompi_ext.m4

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,33 @@ EOF
513513
EXT_MPIFH_HEADERS="$EXT_MPIFH_HEADERS mpiext/mpiext_${component}_mpifh.h"
514514
$4="$$4 $component"
515515

516+
# Per https://github.com/open-mpi/ompi/pull/6030, we will end
517+
# up putting a user-visible Fortran "include" statement in the
518+
# installed mpif-ext.h file, and we therefore have to ensure
519+
# that the total length of the line is <=72 characters. Doing
520+
# a little math here:
521+
#
522+
# leading indent spaces: 6 chars
523+
# "include '": 9 chars
524+
# "openmpi/mpiext/mpiext_NAME_mpifh.h": without NAME, 30 chars
525+
# trailing "'": 1 char
526+
#
527+
# 6+9+30+1 = 46 chars overhead.
528+
# 72-46 = 26 characters left for NAME.
529+
#
530+
# It would be exceedingly unusual to have an MPI extension
531+
# name > 26 characters. But just in case, put a check here
532+
# to make sure: error out if the MPI extension name is > 26
533+
# characters (because otherwise it'll just be a really weird /
534+
# hard to diagnose compile error when a user tries to compile
535+
# a Fortran MPI application that includes `mpif-ext.h`).
536+
len=`echo $component | wc -c`
537+
result=`expr $len \> 26`
538+
AS_IF([test $result -eq 1],
539+
[AC_MSG_WARN([MPI extension name too long: $component])
540+
AC_MSG_WARN([For esoteric reasons, MPI Extensions with mpif.h bindings must have a name that is <= 26 characters])
541+
AC_MSG_ERROR([Cannot continue])])
542+
516543
component_header="mpiext_${component}_mpifh.h"
517544

518545
cat >> $mpif_ext_h <<EOF

0 commit comments

Comments
 (0)