@@ -161,6 +161,8 @@ AC_DEFUN([OPAL_SETUP_CC],[
161
161
162
162
OPAL_CHECK_CC_IQUOTE
163
163
164
+ OPAL_C_COMPILER_VENDOR([opal_c_vendor])
165
+
164
166
if test $opal_cv_c11_supported = no ; then
165
167
# It is not currently an error if C11 support is not available. Uncomment the
166
168
# following lines and update the warning when we require a C11 compiler.
@@ -206,7 +208,6 @@ AC_DEFUN([OPAL_SETUP_CC],[
206
208
AC_DEFINE_UNQUOTED([OPAL_C_HAVE___THREAD], [$opal_prog_cc__thread_available ],
207
209
[Whether C compiler supports __thread])
208
210
209
- OPAL_C_COMPILER_VENDOR([opal_c_vendor])
210
211
211
212
# Check for standard headers, needed here because needed before
212
213
# the types checks.
@@ -244,47 +245,34 @@ AC_DEFUN([OPAL_SETUP_CC],[
244
245
245
246
# Do we want code coverage
246
247
if test " $WANT_COVERAGE " = " 1" ; then
247
- if test " $opal_c_vendor " = " gnu" ; then
248
- # For compilers > gcc-4.x, use --coverage for
249
- # compiling and linking to circumvent trouble with
250
- # libgcov.
251
- CFLAGS_orig=" $CFLAGS "
252
- LDFLAGS_orig=" $LDFLAGS "
253
-
254
- CFLAGS=" $CFLAGS_orig --coverage"
255
- LDFLAGS=" $LDFLAGS_orig --coverage"
256
- OPAL_COVERAGE_FLAGS=
257
-
258
- AC_CACHE_CHECK([if $CC supports --coverage],
259
- [opal_cv_cc_coverage],
260
- [AC_TRY_COMPILE([], [],
261
- [opal_cv_cc_coverage= " yes" ],
262
- [opal_cv_cc_coverage= " no" ])])
263
-
264
- if test " $opal_cv_cc_coverage " = " yes" ; then
265
- OPAL_COVERAGE_FLAGS=" --coverage"
266
- CLEANFILES=" *.gcno ${CLEANFILES} "
267
- CONFIG_CLEAN_FILES=" *.gcda *.gcov ${CONFIG_CLEAN_FILES} "
268
- else
269
- OPAL_COVERAGE_FLAGS=" -ftest-coverage -fprofile-arcs"
270
- CLEANFILES=" *.bb *.bbg ${CLEANFILES} "
271
- CONFIG_CLEAN_FILES=" *.da *.*.gcov ${CONFIG_CLEAN_FILES} "
272
- fi
273
- CFLAGS=" $CFLAGS_orig $OPAL_COVERAGE_FLAGS "
274
- LDFLAGS=" $LDFLAGS_orig $OPAL_COVERAGE_FLAGS "
275
- OPAL_WRAPPER_FLAGS_ADD([CFLAGS], [$OPAL_COVERAGE_FLAGS ])
276
- OPAL_WRAPPER_FLAGS_ADD([LDFLAGS], [$OPAL_COVERAGE_FLAGS ])
277
-
278
- OPAL_FLAGS_UNIQ(CFLAGS)
279
- OPAL_FLAGS_UNIQ(LDFLAGS)
248
+ # For compilers > gcc-4.x, use --coverage for
249
+ # compiling and linking to circumvent trouble with
250
+ # libgcov.
251
+ LDFLAGS_orig=" $LDFLAGS "
252
+ LDFLAGS=" $LDFLAGS_orig --coverage"
253
+ OPAL_COVERAGE_FLAGS=
254
+
255
+ _OPAL_CHECK_SPECIFIC_CFLAGS(--coverage, coverage)
256
+ if test " $opal_cv_cc_coverage " = " 1" ; then
257
+ OPAL_COVERAGE_FLAGS=" --coverage"
258
+ CLEANFILES=" *.gcno ${CLEANFILES} "
259
+ CONFIG_CLEAN_FILES=" *.gcda *.gcov ${CONFIG_CLEAN_FILES} "
280
260
AC_MSG_WARN([$OPAL_COVERAGE_FLAGS has been added to CFLAGS (--enable-coverage)])
281
-
282
- WANT_DEBUG=1
283
261
else
284
- AC_MSG_WARN([Code coverage functionality is currently available only with GCC])
285
- AC_MSG_ERROR([Configure: Cannot continue])
286
- fi
287
- fi
262
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-ftest-coverage, ftest_coverage)
263
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-fprofile-arcs, fprofile_arcs)
264
+ if test " $opal_cv_cc_ftest_coverage " = " 0" || test " opal_cv_cc_fprofile_arcs" = " 0" ; then
265
+ AC_MSG_WARN([Code coverage functionality is not currently available with $CC ])
266
+ AC_MSG_ERROR([Configure: Cannot continue])
267
+ fi
268
+ CLEANFILES=" *.bb *.bbg ${CLEANFILES} "
269
+ OPAL_COVERAGE_FLAGS=" -ftest-coverage -fprofile-arcs"
270
+ fi
271
+ OPAL_FLAGS_UNIQ(CFLAGS)
272
+ OPAL_FLAGS_UNIQ(LDFLAGS)
273
+ WANT_DEBUG=1
274
+ fi
275
+
288
276
289
277
# Do we want debugging?
290
278
if test " $WANT_DEBUG " = " 1" && test " $enable_debug_symbols " ! = " no" ; then
@@ -299,120 +287,29 @@ AC_DEFUN([OPAL_SETUP_CC],[
299
287
OPAL_CFLAGS_BEFORE_PICKY= " $CFLAGS "
300
288
301
289
if test $WANT_PICKY_COMPILER -eq 1; then
302
- CFLAGS_orig=$CFLAGS
303
- add=
304
-
305
- # These flags are likely GCC-specific (or, more specifically,
306
- # we don't have general tests for each one, and we know they
307
- # work with all versions of GCC that we have used throughout
308
- # the years, so we'll keep them limited just to GCC).
309
- if test " $opal_c_vendor " = " gnu" ; then
310
- add=" $add -Wall -Wundef -Wno-long-long -Wsign-compare"
311
- add=" $add -Wmissing-prototypes -Wstrict-prototypes"
312
- add=" $add -Wcomment -pedantic"
313
- fi
314
-
315
- # see if -Wno-long-double works...
316
- # Starting with GCC-4.4, the compiler complains about not
317
- # knowing -Wno-long-double, only if -Wstrict-prototypes is set, too.
318
- #
319
- # Actually, this is not real fix, as GCC will pass on any -Wno- flag,
320
- # have fun with the warning: -Wno-britney
321
- CFLAGS=" $CFLAGS_orig $add -Wno-long-double -Wstrict-prototypes"
322
-
323
- AC_CACHE_CHECK([if $CC supports -Wno-long-double],
324
- [opal_cv_cc_wno_long_double],
325
- [AC_TRY_COMPILE([], [],
326
- [
327
- dnl So -Wno-long-double did not produce any errors...
328
- dnl We will try to extract a warning regarding
329
- dnl unrecognized or ignored options
330
- AC_TRY_COMPILE([], [long double test ; ],
331
- [
332
- opal_cv_cc_wno_long_double= " yes"
333
- if test -s conftest.err ; then
334
- dnl Yes, it should be " ignor" , in order to catch ignoring and ignore
335
- for i in unknown invalid ignor unrecognized ' not supported' ; do
336
- $GREP -iq $i conftest.err
337
- if test " $? " = " 0" ; then
338
- opal_cv_cc_wno_long_double=" no"
339
- break ;
340
- fi
341
- done
342
- fi
343
- ],
344
- [opal_cv_cc_wno_long_double= " no" ])],
345
- [opal_cv_cc_wno_long_double= " no" ])
346
- ])
347
-
348
- if test " $opal_cv_cc_wno_long_double " = " yes" ; then
349
- add=" $add -Wno-long-double"
350
- fi
351
-
352
- # Per above, we know that this flag works with GCC / haven't
353
- # really tested it elsewhere.
354
- if test " $opal_c_vendor " = " gnu" ; then
355
- add=" $add -Werror-implicit-function-declaration "
356
- fi
357
-
358
- CFLAGS=" $CFLAGS_orig $add "
359
- OPAL_FLAGS_UNIQ(CFLAGS)
360
- AC_MSG_WARN([$add has been added to CFLAGS (--enable-picky)])
361
- unset add
290
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-Wundef, Wundef)
291
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-Wno-long-long, Wno_long_long, int main () { long long x; })
292
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-Wsign-compare, Wsign_compare)
293
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-Wmissing-prototypes, Wmissing_prototypes)
294
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-Wstrict-prototypes, Wstrict_prototypes)
295
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-Wcomment, Wcomment)
296
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-Werror-implicit-function-declaration, Werror_implicit_function_declaration)
297
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-Wno-long-double, Wno_long_double, int main () { long double x; })
298
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-fno-strict-aliasing, fno_strict_aliasing, int main () { long double x; })
299
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-pedantic, pedantic)
300
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-Wall, Wall)
362
301
fi
363
302
364
- # See if this version of gcc allows -finline-functions and/or
365
- # -fno-strict-aliasing. Even check the gcc-impersonating compilers.
366
- if test " $GCC " = " yes" ; then
367
- CFLAGS_orig=" $CFLAGS "
368
-
369
- # Note: Some versions of clang (at least >= 3.5 -- perhaps
370
- # older versions, too?) and xlc with -g (v16.1, perhaps older)
371
- # will *warn* about -finline-functions, but still allow it.
372
- # This is very annoying, so check for that warning, too.
373
- # The clang warning looks like this:
374
- # clang: warning: optimization flag '-finline-functions' is not supported
375
- # clang: warning: argument unused during compilation: '-finline-functions'
376
- # the xlc warning looks like this:
377
- # warning: "-qinline" is not compatible with "-g". "-qnoinline" is being set.
378
- CFLAGS=" $CFLAGS_orig -finline-functions"
379
- add=
380
- AC_CACHE_CHECK([if $CC supports -f inline-functions],
381
- [opal_cv_cc_finline_functions],
382
- [AC_TRY_COMPILE([], [],
383
- [opal_cv_cc_finline_functions= " yes"
384
- if test -s conftest.err ; then
385
- for i in unused ' not supported\|not compatible' ; do
386
- if $GREP -iq " $i " conftest.err; then
387
- opal_cv_cc_finline_functions=" no"
388
- break ;
389
- fi
390
- done
391
- fi
392
- ],
393
- [opal_cv_cc_finline_functions= " no" ])])
394
- if test " $opal_cv_cc_finline_functions " = " yes" ; then
395
- add=" -finline-functions"
396
- fi
397
- CFLAGS=" $CFLAGS_orig$add "
398
-
399
- CFLAGS_orig=" $CFLAGS "
400
- CFLAGS=" $CFLAGS_orig -fno-strict-aliasing"
401
- add=
402
- AC_CACHE_CHECK([if $CC supports -f no-strict-aliasing],
403
- [opal_cv_cc_fno_strict_aliasing],
404
- [AC_TRY_COMPILE([], [],
405
- [opal_cv_cc_fno_strict_aliasing= " yes" ],
406
- [opal_cv_cc_fno_strict_aliasing= " no" ])])
407
- if test " $opal_cv_cc_fno_strict_aliasing " = " yes" ; then
408
- add=" -fno-strict-aliasing"
409
- fi
410
- CFLAGS=" $CFLAGS_orig$add "
411
-
412
- OPAL_FLAGS_UNIQ(CFLAGS)
413
- AC_MSG_WARN([$add has been added to CFLAGS])
414
- unset add
415
- fi
303
+ # Note: Some versions of clang (at least >= 3.5 -- perhaps
304
+ # older versions, too?) and xlc with -g (v16.1, perhaps older)
305
+ # will *warn* about -finline-functions, but still allow it.
306
+ # This is very annoying, so check for that warning, too.
307
+ # The clang warning looks like this:
308
+ # clang: warning: optimization flag '-finline-functions' is not supported
309
+ # clang: warning: argument unused during compilation: '-finline-functions'
310
+ # the xlc warning looks like this:
311
+ # warning: "-qinline" is not compatible with "-g". "-qnoinline" is being set.
312
+ _OPAL_CHECK_SPECIFIC_CFLAGS(-finline-functions, finline_functions)
416
313
417
314
# Try to enable restrict keyword
418
315
RESTRICT_CFLAGS=
@@ -425,24 +322,7 @@ AC_DEFUN([OPAL_SETUP_CC],[
425
322
;;
426
323
esac
427
324
if test ! -z " $RESTRICT_CFLAGS " ; then
428
- CFLAGS_orig=" $CFLAGS "
429
- CFLAGS=" $CFLAGS_orig $RESTRICT_CFLAGS "
430
- add=
431
- AC_CACHE_CHECK([if $CC supports $RESTRICT_CFLAGS ],
432
- [opal_cv_cc_restrict_cflags],
433
- [AC_TRY_COMPILE([], [],
434
- [opal_cv_cc_restrict_cflags= " yes" ],
435
- [opal_cv_cc_restrict_cflags= " no" ])])
436
- if test " $opal_cv_cc_restrict_cflags " = " yes" ; then
437
- add=" $RESTRICT_CFLAGS "
438
- fi
439
-
440
- CFLAGS=" ${CFLAGS_orig}${add} "
441
- OPAL_FLAGS_UNIQ([CFLAGS])
442
- if test " $add " ! = " " ; then
443
- AC_MSG_WARN([$add has been added to CFLAGS])
444
- fi
445
- unset add
325
+ _OPAL_CHECK_SPECIFIC_CFLAGS($RESTRICT_CFLAGS , restrict)
446
326
fi
447
327
448
328
# see if the C compiler supports __builtin_expect
@@ -518,6 +398,8 @@ AC_DEFUN([OPAL_SETUP_CC],[
518
398
OPAL_ENSURE_CONTAINS_OPTFLAGS([" $CFLAGS " ])
519
399
AC_MSG_RESULT([$co_result ])
520
400
CFLAGS=" $co_result "
401
+ OPAL_FLAGS_UNIQ([CFLAGS])
402
+ AC_MSG_RESULT(CFLAGS result: $CFLAGS )
521
403
OPAL_VAR_SCOPE_POP
522
404
])
523
405
0 commit comments