Skip to content

Commit 4f3729c

Browse files
committed
Fix iquote check for different C and Fotran preprocessors
* Some C and Fortran compilers use different preprocessors. If one preprocessor accepts `-iquote` and the other does not then a compiler error will occur when Open MPI tries to use it. - Nvidia/PGI v22.1-0 is one such. The C compiler supports `-iquote` while the Fortran compiler does not. * Strengthen the `-iquote` check to check both compilers before deciding to use `-iquote`. If one or both does not support it then fallback to `-I`. Signed-off-by: Joshua Hursey <[email protected]>
1 parent 60e82dd commit 4f3729c

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

config/opal_setup_cc.m4

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dnl Copyright (c) 2015-2019 Research Organization for Information Science
1818
dnl and Technology (RIST). All rights reserved.
1919
dnl Copyright (c) 2020 Triad National Security, LLC. All rights
2020
dnl reserved.
21-
dnl Copyright (c) 2021 IBM Corporation. All rights reserved.
21+
dnl Copyright (c) 2021-2022 IBM Corporation. All rights reserved.
2222
dnl
2323
dnl $COPYRIGHT$
2424
dnl
@@ -129,17 +129,41 @@ AC_DEFUN([OPAL_PROG_CC_C11],[
129129
# which added a <version> header. This conflicts with the
130130
# VERSION file at the base of our source directory on case-
131131
# insensitive filesystems.
132+
#
133+
# Note that some C and Fortran use different preprocessors (nvidia/pgi 22.1-0,
134+
# for example). So it is not sufficient to check just a C program, but also
135+
# a Fortran program in this routine. Since '-I' is the most widely supported
136+
# that is our default if one or both of the preprocessors does not support
137+
# '-iquote'.
132138
AC_DEFUN([OPAL_CHECK_CC_IQUOTE],[
133139
OPAL_VAR_SCOPE_PUSH([opal_check_cc_iquote_CFLAGS_save])
134140
opal_check_cc_iquote_CFLAGS_save=${CFLAGS}
135-
CFLAGS="${CFLAGS} -iquote ."
141+
136142
AC_MSG_CHECKING([for $CC option to add a directory only to the search path for the quote form of include])
143+
CFLAGS="${CFLAGS} -iquote."
144+
AC_LANG_PUSH(C)
137145
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[])],
138146
[opal_cc_iquote="-iquote"],
139147
[opal_cc_iquote="-I"])
148+
AC_MSG_RESULT([\"$opal_cc_iquote\"])
149+
AC_LANG_POP(C)
140150
CFLAGS=${opal_check_cc_iquote_CFLAGS_save}
151+
152+
# Double check against Fortran preprocessor (unless Fortran support is disabled)
153+
AS_IF([test "$opal_cc_iquote" != "-I" -a $OMPI_TRY_FORTRAN_BINDINGS != $OMPI_FORTRAN_NO_BINDINGS],
154+
[AC_MSG_CHECKING([for $FC option to see if it also supports -iquote form of include])
155+
AC_LANG_PUSH(Fortran)
156+
opal_check_cc_iquote_FCFLAGS_save=${FCFLAGS}
157+
FCFLAGS="${FCFLAGS} -iquote."
158+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
159+
[AC_MSG_RESULT([Yes. \"$opal_cc_iquote\" accepted]) ],
160+
[opal_cc_iquote="-I"
161+
AC_MSG_RESULT([No. \"$opal_cc_iquote\" will be used instead]) ])
162+
AC_LANG_POP(Fortran)
163+
FCFLAGS=${opal_check_cc_iquote_FCFLAGS_save}
164+
])
165+
141166
OPAL_VAR_SCOPE_POP
142-
AC_MSG_RESULT([$opal_cc_iquote])
143167
])
144168

145169
# OPAL_SETUP_CC()

0 commit comments

Comments
 (0)