Changeset 4844

Show
Ignore:
Timestamp:
06/28/09 21:43:17 (5 months ago)
Author:
balaji
Message:

Cleaned up --enable-strict options added some additional options that
were previously missing. This patch seems to break the MPICH2 build,
but as far as I can tell, that's because of the MPICH2 code itself,
and not an error in the compiler arguments.

A slightly older version of this was reviewed by buntinas and
goodell. Changes since include combining --enable-strict=yes and
--enable-strict=all, as well as adding some more options to
--enable-strict=posix.

Now --enable-strict=posix is a superset of --enable-strict=all, so we
should consider renaming them.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • mpich2/trunk/confdb/aclocal_cc.m4

    r4777 r4844  
    10581058])dnl 
    10591059 
    1060 dnl 
    10611060dnl Use the value of enable-strict to update CFLAGS 
    10621061dnl pac_cc_strict_flags contains the strict flags. 
     
    10641063dnl -std=c89 is used to select the C89 version of the ANSI/ISO C standard. 
    10651064dnl As of this writing, many C compilers still accepted only this version, 
    1066 dnl not the later C99 version.  When all compilers accept C99, this  
     1065dnl not the later C99 version. When all compilers accept C99, this  
    10671066dnl should be changed to the appropriate standard level.  Note that we've 
    10681067dnl had trouble with gcc 2.95.3 accepting -std=c89 but then trying to  
    10691068dnl compile program with a invalid set of options  
    10701069dnl (-D __STRICT_ANSI__-trigraphs) 
    1071 dnl 
    1072 dnl  
    10731070AC_DEFUN([PAC_CC_STRICT],[ 
    10741071export enable_strict_done 
    10751072if test "$enable_strict_done" != "yes" ; then 
    1076     # We must know the compiler type 
    1077     if test -z "$GCC_OPTFLAG" ; then GCC_OPTFLAG="-O2" ; fi 
    1078     if test -z "CC" ; then 
    1079         AC_CHECK_PROGS(CC,gcc) 
    1080     fi 
    10811073    pac_cc_strict_flags="" 
    10821074    case "$1" in  
    1083         yes) 
    1084         enable_strict_done="yes" 
    1085         if test "$ac_cv_prog_gcc" = "yes" ; then  
    1086             pac_cc_strict_flags="-Wall $GCC_OPTFLAG -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wpointer-arith -Wbad-function-cast -ansi -DGCC_WALL" 
    1087             CFLAGS="$CFLAGS $pac_cc_strict_flags" 
    1088             AC_MSG_RESULT([Adding strict check arguments to CFLAGS]) 
    1089             AC_MSG_CHECKING([whether we can add -std=c89]) 
    1090             # See if we can add -std=c89 
    1091             savCFLAGS=$CFLAGS 
    1092             CFLAGS="$CFLAGS -std=c89" 
    1093             AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[int a;])], 
    1094                   stdc_ok=yes, 
    1095                   stdc_ok=no) 
    1096             AC_MSG_RESULT($stdc_ok) 
    1097             if test "$stdc_ok" != yes ; then 
    1098                 CFLAGS="$savCFLAGS" 
    1099             else 
    1100                 pac_cc_strict_flags="$pac_cc_strict_flags -std=c89" 
    1101             fi 
    1102         else  
    1103             AC_MSG_WARN([enable strict supported only for gcc]) 
    1104         fi 
     1075        yes|all) 
     1076                enable_strict_done="yes" 
     1077                pac_cc_strict_flags="-O2 -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -DGCC_WALL -Wunused -Wshadow -Wmissing-declarations -Werror-implicit-function-declaration -Wno-long-long -Wunused-parameter -Wunused-value  -Wfloat-equal -Wdeclaration-after-statement -Wundef -Wno-endif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare -Waggregate-return -Wold-style-definition -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-format-attribute -Wno-multichar -Wno-deprecated-declarations -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wno-pointer-sign -Wvariadic-macros -std=c89" 
    11051078        ;; 
    11061079 
    1107         all) 
    1108         enable_strict_done="yes" 
    1109         if test "$ac_cv_prog_gcc" = "yes" ; then  
    1110             # -Wsystem-headers removed because of too many warning messages 
    1111             # that are unfixable by the user of this option (the warnings 
    1112             # often show benign but real problems) 
    1113             # -Wunreachable-code has a serious bug and falsely reports  
    1114             # labels as unreachable code.  This makes that option useless 
    1115             # for the MPICH2 code, for example 
    1116             # The next line was the original set of options; this  
    1117             # worked with gcc version 2.x 
    1118 #            pac_cc_strict_flags="-Wall -Wextra $GCC_OPTFLAG -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wpointer-arith -Wbad-function-cast -ansi -DGCC_WALL -Wunused -Wshadow -Wmissing-declarations -Wunused-parameter -Wunused-value -Wno-long-long -Werror-implicit-function-declaration" 
    1119             pac_cc_strict_flags="-Wall -Wextra $GCC_OPTFLAG -Wstrict-prototypes -Wmissing-prototypes -DGCC_WALL -Wunused -Wshadow -Wmissing-declarations -Werror-implicit-function-declaration -Wno-long-long -Wunused-parameter -Wunused-value  -Wfloat-equal -Wdeclaration-after-statement -Wundef -Wno-endif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare -Waggregate-return -Wold-style-definition -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-format-attribute -Wno-multichar -Wno-deprecated-declarations -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wno-pointer-sign -Wvariadic-macros" 
    1120             CFLAGS="$CFLAGS $pac_cc_strict_flags" 
    1121             AC_MSG_CHECKING([whether we can add -std=c89]) 
    1122             # See if we can add -std=c89 
    1123             savCFLAGS=$CFLAGS 
    1124             CFLAGS="$CFLAGS -std=c89" 
    1125             AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[int a;])], 
    1126                   stdc_ok=yes, 
    1127                   stdc_ok=no) 
    1128             AC_MSG_RESULT($stdc_ok) 
    1129             if test "$stdc_ok" != yes ; then 
    1130                 CFLAGS="$savCFLAGS" 
    1131             else 
    1132                 pac_cc_strict_flags="$pac_cc_strict_flags -std=c89" 
    1133             fi 
    1134         else  
    1135             AC_MSG_WARN([enable strict supported only for gcc]) 
    1136         fi 
    1137         ;; 
    1138  
    1139         # The MPICH2 code has several modules that have duplicate  
    1140         # function declarations.  The resulting list of warnings is 
    1141         # swamped by those duplicates, rendering the output nearly 
    1142         # useless.  This temporary option choice is the same as 
    1143         # --enable-strict=all, but without that one option 
    1144         allbutdupdefs) 
    1145         enable_strict_done="yes" 
    1146         if test "$ac_cv_prog_gcc" = "yes" ; then  
    1147             # -Wsystem-headers removed because of too many warning messages 
    1148             # that are unfixable by the user of this option (the warnings 
    1149             # often show benign but real problems) 
    1150             # -Wunreachable-code has a serious bug and falsely reports  
    1151             # labels as unreachable code.  This makes that option useless 
    1152             # for the MPICH2 code, for example 
    1153             # This next line contains the options used with gcc version 2.x 
    1154 #            pac_cc_strict_flags="-Wall -Wextra $GCC_OPTFLAG -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wpointer-arith -Wbad-function-cast -ansi -DGCC_WALL -Wunused -Wshadow -Wmissing-declarations -Wunused-parameter -Wunused-value -Wno-long-long -Werror-implicit-function-declaration" 
    1155             pac_cc_strict_flags="-Wall -Wextra $GCC_OPTFLAG -Wstrict-prototypes -Wmissing-prototypes -DGCC_WALL -Wunused -Wshadow -Wmissing-declarations -Werror-implicit-function-declaration -Wno-long-long -Wunused-parameter -Wunused-value  -Wfloat-equal -Wdeclaration-after-statement -Wundef -Wno-endif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare -Waggregate-return -Wold-style-definition -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-format-attribute -Wno-multichar -Wno-deprecated-declarations -Wpacked -Wpadded -Wnested-externs -Winline -Winvalid-pch -Wno-pointer-sign -Wvariadic-macros -std=c89" 
    1156             CFLAGS="$CFLAGS $pac_cc_strict_flags" 
    1157             AC_MSG_CHECKING([whether we can add -std=c89]) 
    1158             # See if we can add -std=c89 
    1159             savCFLAGS=$CFLAGS 
    1160             CFLAGS="$CFLAGS -std=c89" 
    1161             AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[int a;])], 
    1162                   stdc_ok=yes, 
    1163                   stdc_ok=no) 
    1164             AC_MSG_RESULT($stdc_ok) 
    1165             if test "$stdc_ok" != yes ; then 
    1166                 CFLAGS="$savCFLAGS" 
    1167             else 
    1168                 pac_cc_strict_flags="$pac_cc_strict_flags -std=c89" 
    1169             fi 
    1170         else  
    1171             AC_MSG_WARN([enable strict supported only for gcc]) 
    1172         fi 
    1173         ;; 
    1174  
    11751080        posix) 
    1176         # fsync is a part of POSIX only in the real-time extensions,  
    1177         # apparently, so code that used include <unistd.h> and POSIX 
    1178         # and expects fsync to be defined is in trouble.  Because of that 
    1179         # we're not including the -W option to error if a function is 
    1180         # not prototyped. 
    1181         enable_strict_done="yes" 
    1182         if test "$ac_cv_prog_gcc" = "yes" ; then  
    1183             pac_cc_strict_flags="-Wall $GCC_OPTFLAG -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wpointer-arith -Wbad-function-cast -ansi -DGCC_WALL -D_POSIX_C_SOURCE=199506L" 
    1184             CFLAGS="$CFLAGS $pac_cc_strict_flags" 
    1185             AC_MSG_RESULT([Adding strict check arguments (POSIX flavor) to CFLAGS]) 
    1186             AC_MSG_CHECKING([whether we can add -std=c89]) 
    1187             # See if we can add -std=c89 
    1188             savCFLAGS=$CFLAGS 
    1189             CFLAGS="$CFLAGS -std=c89" 
    1190             AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[int a;])], 
    1191                   stdc_ok=yes, 
    1192                   stdc_ok=no) 
    1193             AC_MSG_RESULT($stdc_ok) 
    1194             if test "$stdc_ok" != yes ; then 
    1195                 CFLAGS="$savCFLAGS" 
    1196             else 
    1197                 pac_cc_strict_flags="$pac_cc_strict_flags -std=c89" 
    1198             fi 
    1199         else  
    1200             AC_MSG_WARN([enable strict supported only for gcc]) 
    1201         fi 
     1081                # fsync is a part of POSIX only in the real-time 
     1082                # extensions, apparently, so code that used include 
     1083                # <unistd.h> and POSIX and expects fsync to be defined 
     1084                # is in trouble.  Because of that we're not including 
     1085                # the -W option to error if a function is not 
     1086                # prototyped. 
     1087                enable_strict_done="yes" 
     1088                pac_cc_strict_flags="-O2 -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -DGCC_WALL -Wunused -Wshadow -Wmissing-declarations -Werror-implicit-function-declaration -Wno-long-long -Wunused-parameter -Wunused-value  -Wfloat-equal -Wdeclaration-after-statement -Wundef -Wno-endif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare -Waggregate-return -Wold-style-definition -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-format-attribute -Wno-multichar -Wno-deprecated-declarations -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wno-pointer-sign -Wvariadic-macros -std=c89 -D_POSIX_C_SOURCE=199506L" 
    12021089        ;; 
    12031090         
    1204         noopt) 
    1205         enable_strict_done="yes" 
    1206         if test "$ac_cv_prog_gcc" = "yes" ; then  
    1207             pac_cc_strict_flags="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wpointer-arith -Wbad-function-cast -ansi -DGCC_WALL" 
    1208             CFLAGS="$CFLAGS $pac_cc_strict_flags" 
    1209             AC_MSG_RESULT([Adding strict check arguments to CFLAGS]) 
    1210             AC_MSG_CHECKING([whether we can add -std=c89]) 
    1211             # See if we can add -std=c89 
    1212             savCFLAGS=$CFLAGS 
    1213             CFLAGS="$CFLAGS -std=c89" 
    1214             AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[int a;])], 
    1215                   stdc_ok=yes, 
    1216                   stdc_ok=no) 
    1217             AC_MSG_RESULT($stdc_ok) 
    1218             if test "$stdc_ok" != yes ; then 
    1219                 CFLAGS="$savCFLAGS" 
    1220             else 
    1221                 pac_cc_strict_flags="$pac_cc_strict_flags -std=c89" 
    1222             fi 
    1223         else  
    1224             AC_MSG_WARN([enable strict supported only for gcc]) 
    1225         fi 
     1091        no) 
     1092                # Accept and ignore this value 
     1093                : 
    12261094        ;; 
    1227         no) 
    1228         # Accept and ignore this value 
    1229         : 
     1095 
     1096        *) 
     1097                if test -n "$1" ; then 
     1098                   AC_MSG_WARN([Unrecognized value for enable-strict:$1]) 
     1099                fi 
    12301100        ;; 
    1231         *) 
    1232         if test -n "$1" ; then 
    1233             AC_MSG_WARN([Unrecognized value for enable-strict:$1]) 
    1234         fi 
    1235         ;; 
     1101 
    12361102    esac 
     1103 
     1104    # See if the above options work with the compiler 
     1105    accepted_flags="" 
     1106    for flag in $pac_cc_strict_flags ; do 
     1107        old_CFLAGS=$CFLAGS 
     1108        CFLAGS="$CFLAGS $accepted_flags $flag" 
     1109        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[int a;])],accepted_flags="$accepted_flags $flag",) 
     1110        CFLAGS="$old_CFLAGS" 
     1111    done 
     1112    pac_cc_strict_flags=$accepted_flags 
    12371113fi 
    12381114]) 
     
    12451121dnl  
    12461122dnl Output effects: 
    1247 dnl Adds '--enable-strict' to the command line.  If this is enabled, then 
    1248 dnl if no compiler has been set, set 'CC' to 'gcc'. 
    1249 dnl If the compiler is 'gcc', 'COPTIONS' is set to include 
    1250 dnl.vb 
    1251 dnl     -O -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Werror=pointer-arith -DGCC_WALL -std=c89 
    1252 dnl.ve 
    1253 dnl This makes using a void * with pointer arithmetic an error, not a warning. 
    1254 dnl We do this because pointer arithmetic with void * is not valid C but 
    1255 dnl gcc accepts this unless these particular optiones are used. 
    1256 dnl Grr. -Werror=name is a recent addition to gcc, so we can't require it yet. 
    1257 dnl 
    1258 dnl -std=c89 is used to select the C89 version of the ANSI/ISO C standard. 
    1259 dnl As of this writing, many C compilers still accepted only this version, 
    1260 dnl not the later C99 version.  When all compilers accept C99, this  
    1261 dnl should be changed to the appropriate standard level.  Note that we've 
    1262 dnl had trouble with gcc 2.95.3 accepting -std=c89 but then trying to  
    1263 dnl compile program with a invalid set of options  
    1264 dnl (-D __STRICT_ANSI__-trigraphs) 
    1265 dnl 
    1266 dnl If the value 'all' is given to '--enable-strict', additional warning 
    1267 dnl options are included.  These are 
    1268 dnl.vb 
    1269 dnl -Wunused -Wshadow -Wmissing-declarations -Wno-long-long 
    1270 dnl.ve 
    1271 dnl  
    1272 dnl If the value 'noopt' is given to '--enable-strict', no optimization 
    1273 dnl options are set.  For some compilers (including gcc), this may  
    1274 dnl cause some strict complication tests to be skipped (typically, these are 
    1275 dnl tests for unused variables or variables used before they are defined). 
    1276 dnl 
    1277 dnl If the value 'posix' is given to '--enable-strict', POSIX is selected 
    1278 dnl as the C dialect (including the definition for the POSIX level) 
    1279 dnl 
    1280 dnl If the value 'all' is given to '--enable-strict', use the "GNU" Unix 
    1281 dnl dialect.  This permits the use of stricter checking for declarations of 
    1282 dnl system functions (note that fsync is not defined in strict, non-real-time 
    1283 dnl POSIX).  This level includes 
    1284 dnl .vb 
    1285 dnl -Werror-implicit-function-declaration 
    1286 dnl .ve 
    1287 dnl  
    1288 dnl This only works where 'gcc' is available. 
    1289 dnl In addition, it exports the variable 'enable_strict_done'. This 
    1290 dnl ensures that subsidiary 'configure's do not add the above flags to 
    1291 dnl 'COPTIONS' once the top level 'configure' sees '--enable-strict'.  To ensure 
    1292 dnl this, 'COPTIONS' is also exported. 
    1293 dnl 
    1294 dnl Not yet available: options when using other compilers.  However,  
    1295 dnl here are some possible choices 
    1296 dnl Solaris cc 
    1297 dnl  -fd -v -Xc 
    1298 dnl -Xc is strict ANSI (some version) and does not allow "long long", for  
    1299 dnl example 
    1300 dnl IRIX 
    1301 dnl  -ansi -DEBUG:trap_uninitialized=ON:varargs_interface_check=ON:verbose_runtime=ON 
     1123dnl Adds '--enable-strict' to the command line. 
    13021124dnl 
    13031125dnl D*/ 
     
    13071129PAC_CC_STRICT($enable_strict) 
    13081130CFLAGS="$CFLAGS $pac_cc_strict_flags" 
     1131export CFLAGS 
    13091132]) 
    13101133