@@ -170,7 +170,7 @@ AC_DEFUN([OPAL_SETUP_CC],[
170
170
AC_REQUIRE([_OPAL_PROG_CC])
171
171
AC_REQUIRE([AM_PROG_CC_C_O])
172
172
173
- OPAL_VAR_SCOPE_PUSH([opal_prog_cc_c11_helper__Thread_local_available opal_prog_cc_c11_helper_atomic_var_available opal_prog_cc_c11_helper__Atomic_available opal_prog_cc_c11_helper__static_assert_available opal_prog_cc_c11_helper__Generic_available opal_prog_cc__thread_available opal_prog_cc_c11_helper_atomic_fetch_xor_explicit_available opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics])
173
+ OPAL_VAR_SCOPE_PUSH([opal_prog_cc_c11_helper__Thread_local_available opal_prog_cc_c11_helper_atomic_var_available opal_prog_cc_c11_helper__Atomic_available opal_prog_cc_c11_helper__static_assert_available opal_prog_cc_c11_helper__Generic_available opal_prog_cc_c11_helper_atomic_fetch_xor_explicit_available opal_prog_cc_c11_helper_proper__Atomic_support_in_atomics])
174
174
175
175
OPAL_PROG_CC_C11
176
176
@@ -179,33 +179,24 @@ AC_DEFUN([OPAL_SETUP_CC],[
179
179
OPAL_C_COMPILER_VENDOR([opal_c_vendor])
180
180
181
181
if test $opal_cv_c11_supported = no ; then
182
- # It is not currently an error if C11 support is not available. Uncomment the
183
- # following lines and update the warning when we require a C11 compiler.
184
- # AC_MSG_WARNING([Open MPI requires a C11 (or newer) compiler])
185
- # AC_MSG_ERROR([Aborting.])
186
- # From Open MPI 1.7 on we require a C99 compliant compiler
187
- dnl with autoconf 2.70 AC_PROG_CC makes AC_PROG_CC_C99 obsolete
188
- m4_version_prereq([2.70],
189
- [],
190
- [AC_PROG_CC_C99])
191
- # The result of AC_PROG_CC_C99 is stored in ac_cv_prog_cc_c99
192
- if test " x$ac_cv_prog_cc_c99 " = xno ; then
193
- AC_MSG_WARN([Open MPI requires a C99 (or newer) compiler. C11 is recommended.])
194
- AC_MSG_ERROR([Aborting.])
195
- fi
196
-
197
- # Get the correct result for C11 support flags now that the compiler flags have
198
- # changed
199
- OPAL_PROG_CC_C11_HELPER([], [], [])
182
+ # C11 is required
183
+ AC_MSG_WARN([Open MPI requires a C11 (or newer) compiler. C11 is required.])
184
+ AC_MSG_ERROR([Aborting.])
185
+ elif test $opal_cv_c11_flag_required = no ; then
186
+ # Check if the compiler accepts -std=c11
187
+ # this helps avoid accidentally using newer features
188
+ opal_prog_cc_c11_flags=" -std=c11 -c11"
189
+ AC_MSG_NOTICE([checking if $CC supports C11 standard flag])
190
+ for flag in $( echo $opal_prog_cc_c11_flags | tr ' ' ' \n' ) ; do
191
+ _OPAL_CHECK_SPECIFIC_CFLAGS($flag , std_c11)
192
+ if test " x$opal_cv_cc_std_c11 " == " x1" ; then
193
+ OPAL_FLAGS_APPEND_UNIQ([CFLAGS], [" $flag " ])
194
+ AC_MSG_NOTICE([using $flag to ensure C11 support])
195
+ break
196
+ fi
197
+ done
200
198
fi
201
199
202
- # Check if compiler support __thread
203
- OPAL_CC_HELPER([if $CC $1 supports __thread], [opal_prog_cc__thread_available],
204
- [],[[static __thread int foo = 1; ++foo; ]])
205
-
206
- OPAL_CC_HELPER([if $CC $1 supports C11 _Thread_local], [opal_prog_cc_c11_helper__Thread_local_available],
207
- [],[[static _Thread_local int foo = 1; ++foo; ]])
208
-
209
200
dnl At this time Open MPI only needs thread local and the atomic convenience types for C11 support. These
210
201
dnl will likely be required in the future.
211
202
AC_DEFINE_UNQUOTED([OPAL_C_HAVE__THREAD_LOCAL], [$opal_prog_cc_c11_helper__Thread_local_available ],
@@ -223,9 +214,6 @@ AC_DEFUN([OPAL_SETUP_CC],[
223
214
AC_DEFINE_UNQUOTED([OPAL_C_HAVE__STATIC_ASSERT], [$opal_prog_cc_c11_helper__static_assert_available ],
224
215
[Whether C compiler support _Static_assert keyword])
225
216
226
- AC_DEFINE_UNQUOTED([OPAL_C_HAVE___THREAD], [$opal_prog_cc__thread_available ],
227
- [Whether C compiler supports __thread])
228
-
229
217
# Check for standard headers, needed here because needed before
230
218
# the types checks. This is only necessary for Autoconf < v2.70.
231
219
m4_version_prereq([2.70],
0 commit comments