Skip to content

Commit a6212fe

Browse files
hjelmnjsquyres
authored andcommitted
configure: use -iquote for non-system include paths
This fixes a bug in the configuration system identified by a change in the C++ standard. C++20 adds a new mandatory header named version. This (and any system) header will always be included with <> and not "". On case-insensitive filesystems this new header conflicts with the VERSION file at the top level of the build tree. To fix this issue Open MPI needs to use -iquote instead of -I for non-system include paths to ensure that these include are only searched for the quote form of include. This commit also adds a check to ensure that if the compiler does not support -iquote that it falls back to -I until support can be added. References #7155 Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 69bc2e8 commit a6212fe

File tree

3 files changed

+281
-2
lines changed

3 files changed

+281
-2
lines changed

config/opal_setup_cc.m4

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,26 @@ AC_DEFUN([OPAL_PROG_CC_C11],[
117117
OPAL_VAR_SCOPE_POP
118118
])
119119

120+
# OPAL_CHECK_CC_IQUOTE()
121+
# ----------------------
122+
# Check if the compiler supports the -iquote option. This options
123+
# removes the specified directory from the search path when using
124+
# #include <>. This check works around an issue caused by C++20
125+
# which added a <version> header. This conflicts with the
126+
# VERSION file at the base of our source directory on case-
127+
# insensitive filesystems.
128+
AC_DEFUN([OPAL_CHECK_CC_IQUOTE],[
129+
OPAL_VAR_SCOPE_PUSH([opal_check_cc_iquote_CFLAGS_save])
130+
opal_check_cc_iquote_CFLAGS_save=${CFLAGS}
131+
CFLAGS="${CFLAGS} -iquote ."
132+
AC_MSG_CHECKING([for $CC option to add a directory only to the search path for the quote form of include])
133+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[])],
134+
[opal_cc_iquote="-iquote"],
135+
[opal_cc_iquote="-I"])
136+
CFLAGS=${opal_check_cc_iquote_CFLAGS_save}
137+
OPAL_VAR_SCOPE_POP
138+
AC_MSG_RESULT([$opal_cc_iquote])
139+
])
120140

121141
# OPAL_SETUP_CC()
122142
# ---------------
@@ -140,6 +160,8 @@ AC_DEFUN([OPAL_SETUP_CC],[
140160

141161
OPAL_PROG_CC_C11
142162

163+
OPAL_CHECK_CC_IQUOTE
164+
143165
if test $opal_cv_c11_supported = no ; then
144166
# It is not currently an error if C11 support is not available. Uncomment the
145167
# following lines and update the warning when we require a C11 compiler.

config/opal_setup_cxx.m4

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
dnl -*- shell-script -*-
2+
dnl
3+
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4+
dnl University Research and Technology
5+
dnl Corporation. All rights reserved.
6+
dnl Copyright (c) 2004-2006 The University of Tennessee and The University
7+
dnl of Tennessee Research Foundation. All rights
8+
dnl reserved.
9+
dnl Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
10+
dnl University of Stuttgart. All rights reserved.
11+
dnl Copyright (c) 2004-2006 The Regents of the University of California.
12+
dnl All rights reserved.
13+
dnl Copyright (c) 2006 Los Alamos National Security, LLC. All rights
14+
dnl reserved.
15+
dnl Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved.
16+
dnl Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
17+
dnl Copyright (c) 2015-2016 Research Organization for Information Science
18+
dnl and Technology (RIST). All rights reserved.
19+
dnl $COPYRIGHT$
20+
dnl
21+
dnl Additional copyrights may follow
22+
dnl
23+
dnl $HEADER$
24+
dnl
25+
26+
# This macro is necessary to get the title to be displayed first. :-)
27+
AC_DEFUN([OPAL_SETUP_CXX_BANNER],[
28+
opal_show_subtitle "C++ compiler and preprocessor"
29+
])
30+
31+
# This macro is necessary because PROG_CXX* is REQUIREd by multiple
32+
# places in SETUP_CXX.
33+
AC_DEFUN([OPAL_PROG_CXX],[
34+
OPAL_VAR_SCOPE_PUSH([opal_cxxflags_save])
35+
opal_cxxflags_save="$CXXFLAGS"
36+
AC_PROG_CXX
37+
AC_PROG_CXXCPP
38+
CXXFLAGS="$opal_cxxflags_save"
39+
OPAL_VAR_SCOPE_POP
40+
])
41+
42+
# OPAL_SETUP_CXX()
43+
# ----------------
44+
# Do everything required to setup the C++ compiler. Safe to AC_REQUIRE
45+
# this macro.
46+
AC_DEFUN([OPAL_SETUP_CXX],[
47+
AC_REQUIRE([OPAL_SETUP_CXX_BANNER])
48+
49+
_OPAL_SETUP_CXX_COMPILER
50+
51+
OPAL_CXX_COMPILER_VENDOR([opal_cxx_vendor])
52+
53+
_OPAL_SETUP_CXX_COMPILER_BACKEND
54+
])
55+
56+
# _OPAL_SETUP_CXX_COMPILER()
57+
# --------------------------
58+
# Setup the CXX compiler
59+
AC_DEFUN([_OPAL_SETUP_CXX_COMPILER],[
60+
OPAL_VAR_SCOPE_PUSH(opal_cxx_compiler_works)
61+
62+
# Must REQUIRE the PROG_CXX macro and not call it directly here for
63+
# reasons well-described in the AC2.64 (and beyond) docs.
64+
AC_REQUIRE([OPAL_PROG_CXX])
65+
BASECXX="`basename $CXX`"
66+
67+
AS_IF([test "x$CXX" = "x"], [CXX=none])
68+
set dummy $CXX
69+
opal_cxx_argv0=[$]2
70+
OPAL_WHICH([$opal_cxx_argv0], [OPAL_CXX_ABSOLUTE])
71+
AS_IF([test "x$OPAL_CXX_ABSOLUTE" = "x"], [OPAL_CXX_ABSOLUTE=none])
72+
73+
AC_DEFINE_UNQUOTED(OPAL_CXX, "$CXX", [OPAL underlying C++ compiler])
74+
AC_SUBST(OPAL_CXX_ABSOLUTE)
75+
76+
OPAL_VAR_SCOPE_POP
77+
])
78+
79+
# OPAL_CHECK_CXX_IQUOTE()
80+
# ----------------------
81+
# Check if the compiler supports the -iquote option. This options
82+
# removes the specified directory from the search path when using
83+
# #include <>. This check works around an issue caused by C++20
84+
# which added a <version> header. This conflicts with the
85+
# VERSION file at the base of our source directory on case-
86+
# insensitive filesystems.
87+
AC_DEFUN([OPAL_CHECK_CXX_IQUOTE],[
88+
OPAL_VAR_SCOPE_PUSH([opal_check_cxx_iquote_CFLAGS_save])
89+
opal_check_cxx_iquote_CFLAGS_save=${CFLAGS}
90+
CXXFLAGS="${CFLAGS} -iquote ."
91+
AC_MSG_CHECKING([for $CXX option to add a directory only to the search path for the quote form of include])
92+
AC_LANG_PUSH(C++)
93+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[])],
94+
[opal_cxx_iquote="-iquote"],
95+
[opal_cxx_iquote="-I"])
96+
CXXFLAGS=${opal_check_cxx_iquote_CFLAGS_save}
97+
AC_LANG_POP(C++)
98+
OPAL_VAR_SCOPE_POP
99+
AC_MSG_RESULT([$opal_cxx_iquote])
100+
])
101+
102+
# _OPAL_SETUP_CXX_COMPILER_BACKEND()
103+
# ----------------------------------
104+
# Back end of _OPAL_SETUP_CXX_COMPILER_BACKEND()
105+
AC_DEFUN([_OPAL_SETUP_CXX_COMPILER_BACKEND],[
106+
# Do we want code coverage
107+
if test "$WANT_COVERAGE" = "1"; then
108+
if test "$opal_cxx_vendor" = "gnu" ; then
109+
AC_MSG_WARN([$OPAL_COVERAGE_FLAGS has been added to CFLAGS (--enable-coverage)])
110+
WANT_DEBUG=1
111+
CXXFLAGS="${CXXFLAGS} $OPAL_COVERAGE_FLAGS"
112+
OPAL_WRAPPER_FLAGS_ADD([CXXFLAGS], [$OPAL_COVERAGE_FLAGS])
113+
else
114+
AC_MSG_WARN([Code coverage functionality is currently available only with GCC suite])
115+
AC_MSG_ERROR([Configure: cannot continue])
116+
fi
117+
fi
118+
119+
# Do we want debugging?
120+
if test "$WANT_DEBUG" = "1" && test "$enable_debug_symbols" != "no" ; then
121+
CXXFLAGS="$CXXFLAGS -g"
122+
OPAL_FLAGS_UNIQ(CXXFLAGS)
123+
AC_MSG_WARN([-g has been added to CXXFLAGS (--enable-debug)])
124+
fi
125+
126+
# These flags are generally g++-specific; even the g++-impersonating
127+
# compilers won't accept them.
128+
OPAL_CXXFLAGS_BEFORE_PICKY="$CXXFLAGS"
129+
if test "$WANT_PICKY_COMPILER" = 1 && test "$opal_cxx_vendor" = "gnu"; then
130+
add="-Wall -Wundef -Wno-long-long"
131+
132+
# see if -Wno-long-double works...
133+
AC_LANG_PUSH(C++)
134+
CXXFLAGS_orig="$CXXFLAGS"
135+
CXXFLAGS="$CXXFLAGS $add -Wno-long-double -fstrict-prototype"
136+
AC_CACHE_CHECK([if $CXX supports -Wno-long-double],
137+
[opal_cv_cxx_wno_long_double],
138+
[AC_TRY_COMPILE([], [],
139+
[
140+
dnl So -Wno-long-double did not produce any errors...
141+
dnl We will try to extract a warning regarding
142+
dnl unrecognized or ignored options
143+
AC_TRY_COMPILE([], [long double test;],
144+
[
145+
opal_cv_cxx_wno_long_double="yes"
146+
if test -s conftest.err ; then
147+
dnl Yes, it should be "ignor", in order to catch ignoring and ignore
148+
for i in unknown invalid ignor unrecognized ; do
149+
$GREP -iq $i conftest.err
150+
if test "$?" = "0" ; then
151+
opal_cv_cxx_wno_long_double="no"
152+
break;
153+
fi
154+
done
155+
fi
156+
],
157+
[opal_cv_cxx_wno_long_double="no"])],
158+
[opal_cv_cxx_wno_long_double="no"])
159+
])
160+
161+
CXXFLAGS="$CXXFLAGS_orig"
162+
AC_LANG_POP(C++)
163+
if test "$opal_cv_cxx_wno_long_double" = "yes" ; then
164+
add="$add -Wno-long-double"
165+
fi
166+
167+
CXXFLAGS="$CXXFLAGS $add"
168+
OPAL_FLAGS_UNIQ(CXXFLAGS)
169+
if test "$add" != "" ; then
170+
AC_MSG_WARN([$add has been added to CXXFLAGS (--enable-picky)])
171+
fi
172+
unset add
173+
fi
174+
175+
# See if this version of g++ allows -finline-functions
176+
if test "$GXX" = "yes"; then
177+
CXXFLAGS_orig="$CXXFLAGS"
178+
CXXFLAGS="$CXXFLAGS -finline-functions"
179+
add=
180+
AC_LANG_PUSH(C++)
181+
AC_CACHE_CHECK([if $CXX supports -finline-functions],
182+
[opal_cv_cxx_finline_functions],
183+
[AC_TRY_COMPILE([], [],
184+
[opal_cv_cxx_finline_functions="yes"],
185+
[opal_cv_cxx_finline_functions="no"])])
186+
AC_LANG_POP(C++)
187+
if test "$opal_cv_cxx_finline_functions" = "yes" ; then
188+
add=" -finline-functions"
189+
fi
190+
CXXFLAGS="$CXXFLAGS_orig$add"
191+
OPAL_FLAGS_UNIQ(CXXFLAGS)
192+
if test "$add" != "" ; then
193+
AC_MSG_WARN([$add has been added to CXXFLAGS])
194+
fi
195+
unset add
196+
fi
197+
198+
# Make sure we can link with the C compiler
199+
if test "$opal_cv_cxx_compiler_vendor" != "microsoft"; then
200+
OPAL_LANG_LINK_WITH_C([C++], [],
201+
[cat <<EOF >&2
202+
**********************************************************************
203+
* It appears that your C++ compiler is unable to link against object
204+
* files created by your C compiler. This generally indicates either
205+
* a conflict between the options specified in CFLAGS and CXXFLAGS
206+
* or a problem with the local compiler installation. More
207+
* information (including exactly what command was given to the
208+
* compilers and what error resulted when the commands were executed) is
209+
* available in the config.log file in this directory.
210+
**********************************************************************
211+
EOF
212+
AC_MSG_ERROR([C and C++ compilers are not link compatible. Can not continue.])])
213+
fi
214+
215+
# If we are on HP-UX, ensure that we're using aCC
216+
case "$host" in
217+
*hpux*)
218+
if test "$BASECXX" = "CC"; then
219+
AC_MSG_WARN([*** You will probably have problems compiling the MPI 2])
220+
AC_MSG_WARN([*** C++ bindings with the HP-UX CC compiler. You should])
221+
AC_MSG_WARN([*** probably be using the aCC compiler. Re-run configure])
222+
AC_MSG_WARN([*** with the environment variable "CXX=aCC".])
223+
fi
224+
;;
225+
esac
226+
227+
# Note: gcc-imperonating compilers accept -O3
228+
if test "$WANT_DEBUG" = "1"; then
229+
OPTFLAGS=
230+
else
231+
if test "$GXX" = yes; then
232+
OPTFLAGS="-O3"
233+
else
234+
OPTFLAGS="-O"
235+
fi
236+
fi
237+
238+
# config/opal_ensure_contains_optflags.m4
239+
OPAL_ENSURE_CONTAINS_OPTFLAGS(["$CXXFLAGS"])
240+
AC_MSG_CHECKING([for C++ optimization flags])
241+
AC_MSG_RESULT([$co_result])
242+
CXXFLAGS="$co_result"
243+
244+
# bool type size and alignment
245+
AC_LANG_PUSH(C++)
246+
AC_CHECK_SIZEOF(bool)
247+
OPAL_C_GET_ALIGNMENT(bool, OPAL_ALIGNMENT_CXX_BOOL)
248+
AC_LANG_POP(C++)
249+
250+
OPAL_CHECK_CXX_IQUOTE
251+
])

configure.ac

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,11 +1266,17 @@ if test "$OMPI_TOP_BUILDDIR" != "$OMPI_TOP_SRCDIR"; then
12661266
# rather than have successive assignments to these shell
12671267
# variables, lest the $(foo) names try to get evaluated here.
12681268
# Yuck!
1269-
CPPFLAGS='-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/opal/include m4_ifdef([project_ompi], [-I$(top_srcdir)/ompi/include]) m4_ifdef([project_oshmem], [-I$(top_srcdir)/oshmem/include])'" $CPPFLAGS"
1269+
cpp_includes='$(top_srcdir) $(top_builddir) $(top_srcdir)/opal/include m4_ifdef([project_ompi], [$(top_srcdir)/ompi/include]) m4_ifdef([project_oshmem], [$(top_srcdir)/oshmem/include])'
12701270
else
1271-
CPPFLAGS='-I$(top_srcdir)'" $CPPFLAGS"
1271+
cpp_includes='$(top_srcdir)'
12721272
fi
12731273

1274+
CPP_INCLUDES="$(echo $cpp_includes | $SED 's/[[^ \]]* */'"$opal_cc_iquote"'&/g')"
1275+
CXX_INCLUDES="$(echo $cpp_includes | $SED 's/[[^ \]]* */'"$opal_cxx_iquote"'&/g')"
1276+
CPPFLAGS="$CPP_INCLUDES $CPPFLAGS"
1277+
# C++ is only relevant if we're building OMPI
1278+
m4_ifdef([project_ompi],[CXXCPPFLAGS="$CXX_INCLUDES $CXXCPPFLAGS"])
1279+
12741280
# OMPI needs some additional processing of the flags (e.g., get
12751281
# versions without optimization for debugger modules).
12761282

0 commit comments

Comments
 (0)