Commit 06c37c96 by Nathan Sidwell Committed by Nathan Sidwell

configure.ac: Add ENABLE_ASSERT_CHECKING control.

	* configure.ac: Add ENABLE_ASSERT_CHECKING control.
	Add is_release variable, use it for --enable-werror and
	--enable-checking defaults.
	* system.h (gcc_assert, gcc_unreachable): New.
	* doc/install.texi (--enable-checking): Update.
	* configure, config.in: Rebuilt.

From-SVN: r86666
parent 9d64df18
2004-08-27 Nathan Sidwell <nathan@codesourcery.com>
* configure.ac: Add ENABLE_ASSERT_CHECKING control.
Add is_release variable, use it for --enable-werror and
--enable-checking defaults.
* system.h (gcc_assert, gcc_unreachable): New.
* doc/install.texi (--enable-checking): Update.
* configure, config.in: Rebuilt.
2004-08-26 Richard Sandiford <rsandifo@redhat.com> 2004-08-26 Richard Sandiford <rsandifo@redhat.com>
* rtl.h (read_rtx): Change prototype. * rtl.h (read_rtx): Change prototype.
......
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
__cxa_atexit in libc. */ __cxa_atexit in libc. */
#undef DEFAULT_USE_CXA_ATEXIT #undef DEFAULT_USE_CXA_ATEXIT
/* Define if you want assertions enabled. This is a cheap check. */
#undef ENABLE_ASSERT_CHECKING
/* Define if you want more run-time sanity checks. This one gets a grab bag of /* Define if you want more run-time sanity checks. This one gets a grab bag of
miscellaneous but relatively cheap checks. */ miscellaneous but relatively cheap checks. */
#undef ENABLE_CHECKING #undef ENABLE_CHECKING
......
...@@ -867,8 +867,9 @@ Optional Features: ...@@ -867,8 +867,9 @@ Optional Features:
--enable-checking=LIST --enable-checking=LIST
enable expensive run-time checks. With LIST, enable expensive run-time checks. With LIST,
enable only specific categories of checks. enable only specific categories of checks.
Categories are: fold,gc,gcac,misc,rtlflag,rtl, Categories are: none,assert,fold,gc,gcac,misc,
tree,valgrind; default is gc,misc,rtlflag,tree rtlflag,rtl,tree,valgrind;
default is assert,gc,misc,rtlflag,tree
--enable-mapped-location location_t is fileline integer cookie --enable-mapped-location location_t is fileline integer cookie
--enable-coverage=LEVEL --enable-coverage=LEVEL
enable compiler's code coverage collection. enable compiler's code coverage collection.
...@@ -1381,6 +1382,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ...@@ -1381,6 +1382,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_headers="$ac_config_headers auto-host.h:config.in" ac_config_headers="$ac_config_headers auto-host.h:config.in"
#Set to 1 on a release branch
is_release=
# Determine the host, build, and target systems # Determine the host, build, and target systems
ac_aux_dir= ac_aux_dir=
for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
...@@ -3902,13 +3906,18 @@ fi ...@@ -3902,13 +3906,18 @@ fi
# Enable -Werror in bootstrap stage2 and later. # Enable -Werror in bootstrap stage2 and later.
# Change the default to "no" on release branches.
# Check whether --enable-werror or --disable-werror was given. # Check whether --enable-werror or --disable-werror was given.
if test "${enable_werror+set}" = set; then if test "${enable_werror+set}" = set; then
enableval="$enable_werror" enableval="$enable_werror"
else else
if test x$is_release = x ; then
# Default to "yes" on development branches.
enable_werror=yes enable_werror=yes
else
# Default to "no" on release branches.
enable_werror=no
fi
fi; fi;
if test x$enable_werror = xyes ; then if test x$enable_werror = xyes ; then
WERROR=-Werror WERROR=-Werror
...@@ -3926,16 +3935,19 @@ ac_rtlflag_checking= ...@@ -3926,16 +3935,19 @@ ac_rtlflag_checking=
ac_gc_checking= ac_gc_checking=
ac_gc_always_collect= ac_gc_always_collect=
ac_fold_checking= ac_fold_checking=
ac_assert_checking=
case "${enableval}" in case "${enableval}" in
yes) ac_checking=1 ; ac_tree_checking=1 ; ac_gc_checking=1 ; yes) ac_checking=1 ; ac_tree_checking=1 ; ac_gc_checking=1 ;
ac_rtlflag_checking=1 ;; ac_rtlflag_checking=1 ; ac_assert_checking=1 ;;
no) ;; no) ;;
*) IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS," *) IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS,"
set fnord $enableval; shift set fnord $enableval; shift
IFS="$ac_save_IFS" IFS="$ac_save_IFS"
ac_assert_checking=1
for check for check
do do
case $check in case $check in
assert) ac_assert_checking=1 ;;
fold) ac_fold_checking=1 ;; fold) ac_fold_checking=1 ;;
gc) ac_gc_checking=1 ;; gc) ac_gc_checking=1 ;;
gcac) ac_gc_always_collect=1 ;; gcac) ac_gc_always_collect=1 ;;
...@@ -3953,8 +3965,16 @@ echo "$as_me: error: unknown check category $check" >&2;} ...@@ -3953,8 +3965,16 @@ echo "$as_me: error: unknown check category $check" >&2;}
esac esac
else else
# Enable some checks by default for development versions of GCC
ac_checking=1; ac_tree_checking=1; ac_gc_checking=1; ac_rtlflag_checking=1; # Determine the default checks.
if test x$is_release = x ; then
# Enable some checks for development versions of GCC
ac_assert_checking=1;
ac_checking=1; ac_tree_checking=1; ac_gc_checking=1; ac_rtlflag_checking=1;
else
# Disable all but assertions for release versions of GCC.
ac_assert_checking=1;
fi
fi; fi;
nocommon_flag="" nocommon_flag=""
if test x$ac_checking != x ; then if test x$ac_checking != x ; then
...@@ -3966,6 +3986,13 @@ _ACEOF ...@@ -3966,6 +3986,13 @@ _ACEOF
nocommon_flag=-fno-common nocommon_flag=-fno-common
fi fi
if test x$ac_assert_checking != x ; then
cat >>confdefs.h <<\_ACEOF
#define ENABLE_ASSERT_CHECKING 1
_ACEOF
fi
if test x$ac_tree_checking != x ; then if test x$ac_tree_checking != x ; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
...@@ -5263,7 +5290,7 @@ if test "${gcc_cv_prog_makeinfo_modern+set}" = set; then ...@@ -5263,7 +5290,7 @@ if test "${gcc_cv_prog_makeinfo_modern+set}" = set; then
else else
ac_prog_version=`$MAKEINFO --version 2>&1 | ac_prog_version=`$MAKEINFO --version 2>&1 |
sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'` sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'`
echo "configure:5266: version of makeinfo is $ac_prog_version" >&5 echo "configure:5293: version of makeinfo is $ac_prog_version" >&5
case $ac_prog_version in case $ac_prog_version in
'') gcc_cv_prog_makeinfo_modern=no;; '') gcc_cv_prog_makeinfo_modern=no;;
4.[2-9]*) 4.[2-9]*)
......
...@@ -30,6 +30,9 @@ AC_INIT ...@@ -30,6 +30,9 @@ AC_INIT
AC_CONFIG_SRCDIR(tree.c) AC_CONFIG_SRCDIR(tree.c)
AC_CONFIG_HEADER(auto-host.h:config.in) AC_CONFIG_HEADER(auto-host.h:config.in)
#Set to 1 on a release branch
is_release=
# Determine the host, build, and target systems # Determine the host, build, and target systems
AC_CANONICAL_BUILD AC_CANONICAL_BUILD
AC_CANONICAL_HOST AC_CANONICAL_HOST
...@@ -370,10 +373,15 @@ fi ...@@ -370,10 +373,15 @@ fi
AC_SUBST(warn_cflags) AC_SUBST(warn_cflags)
# Enable -Werror in bootstrap stage2 and later. # Enable -Werror in bootstrap stage2 and later.
# Change the default to "no" on release branches.
AC_ARG_ENABLE(werror, AC_ARG_ENABLE(werror,
[ --enable-werror enable -Werror in bootstrap stage2 and later], [], [ --enable-werror enable -Werror in bootstrap stage2 and later], [],
[enable_werror=yes]) [if test x$is_release = x ; then
# Default to "yes" on development branches.
enable_werror=yes
else
# Default to "no" on release branches.
enable_werror=no
fi])
if test x$enable_werror = xyes ; then if test x$enable_werror = xyes ; then
WERROR=-Werror WERROR=-Werror
fi fi
...@@ -384,8 +392,9 @@ AC_ARG_ENABLE(checking, ...@@ -384,8 +392,9 @@ AC_ARG_ENABLE(checking,
[ --enable-checking[=LIST] [ --enable-checking[=LIST]
enable expensive run-time checks. With LIST, enable expensive run-time checks. With LIST,
enable only specific categories of checks. enable only specific categories of checks.
Categories are: fold,gc,gcac,misc,rtlflag,rtl, Categories are: none,assert,fold,gc,gcac,misc,
tree,valgrind; default is gc,misc,rtlflag,tree], rtlflag,rtl,tree,valgrind;
default is assert,gc,misc,rtlflag,tree],
[ac_checking= [ac_checking=
ac_tree_checking= ac_tree_checking=
ac_rtl_checking= ac_rtl_checking=
...@@ -393,16 +402,19 @@ ac_rtlflag_checking= ...@@ -393,16 +402,19 @@ ac_rtlflag_checking=
ac_gc_checking= ac_gc_checking=
ac_gc_always_collect= ac_gc_always_collect=
ac_fold_checking= ac_fold_checking=
ac_assert_checking=
case "${enableval}" in case "${enableval}" in
yes) ac_checking=1 ; ac_tree_checking=1 ; ac_gc_checking=1 ; yes) ac_checking=1 ; ac_tree_checking=1 ; ac_gc_checking=1 ;
ac_rtlflag_checking=1 ;; ac_rtlflag_checking=1 ; ac_assert_checking=1 ;;
no) ;; no) ;;
*) IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS," *) IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS,"
set fnord $enableval; shift set fnord $enableval; shift
IFS="$ac_save_IFS" IFS="$ac_save_IFS"
ac_assert_checking=1
for check for check
do do
case $check in case $check in
assert) ac_assert_checking=1 ;;
fold) ac_fold_checking=1 ;; fold) ac_fold_checking=1 ;;
gc) ac_gc_checking=1 ;; gc) ac_gc_checking=1 ;;
gcac) ac_gc_always_collect=1 ;; gcac) ac_gc_always_collect=1 ;;
...@@ -416,9 +428,16 @@ no) ;; ...@@ -416,9 +428,16 @@ no) ;;
done done
;; ;;
esac esac
], ], [
# Enable some checks by default for development versions of GCC # Determine the default checks.
[ac_checking=1; ac_tree_checking=1; ac_gc_checking=1; ac_rtlflag_checking=1;]) if test x$is_release = x ; then
# Enable some checks for development versions of GCC
ac_assert_checking=1;
ac_checking=1; ac_tree_checking=1; ac_gc_checking=1; ac_rtlflag_checking=1;
else
# Disable all but assertions for release versions of GCC.
ac_assert_checking=1;
fi])
nocommon_flag="" nocommon_flag=""
if test x$ac_checking != x ; then if test x$ac_checking != x ; then
AC_DEFINE(ENABLE_CHECKING, 1, AC_DEFINE(ENABLE_CHECKING, 1,
...@@ -427,6 +446,10 @@ if test x$ac_checking != x ; then ...@@ -427,6 +446,10 @@ if test x$ac_checking != x ; then
nocommon_flag=-fno-common nocommon_flag=-fno-common
fi fi
AC_SUBST(nocommon_flag) AC_SUBST(nocommon_flag)
if test x$ac_assert_checking != x ; then
AC_DEFINE(ENABLE_ASSERT_CHECKING, 1,
[Define if you want assertions enabled. This is a cheap check.])
fi
if test x$ac_tree_checking != x ; then if test x$ac_tree_checking != x ; then
AC_DEFINE(ENABLE_TREE_CHECKING, 1, AC_DEFINE(ENABLE_TREE_CHECKING, 1,
[Define if you want all operations on trees (the basic data [Define if you want all operations on trees (the basic data
......
...@@ -1097,12 +1097,17 @@ compiler and may only work properly if you are building the compiler ...@@ -1097,12 +1097,17 @@ compiler and may only work properly if you are building the compiler
with GCC@. This is on by default when building from CVS or snapshots, with GCC@. This is on by default when building from CVS or snapshots,
but off for releases. More control over the checks may be had by but off for releases. More control over the checks may be had by
specifying @var{list}; the categories of checks available are specifying @var{list}; the categories of checks available are
@samp{misc}, @samp{tree}, @samp{gc}, @samp{rtl}, @samp{rtlflag}, @samp{assert}, @samp{misc}, @samp{tree}, @samp{gc}, @samp{rtl},
@samp{fold}, @samp{gcac} and @samp{valgrind}. The check @samp{valgrind} @samp{rtlflag}, @samp{fold}, @samp{gcac} and @samp{valgrind}. The check
requires the external @command{valgrind} simulator, available from @samp{valgrind} requires the external @command{valgrind} simulator,
@uref{http://valgrind.kde.org/}. The default when @var{list} is available from @uref{http://valgrind.kde.org/}. The default when
not specified is @samp{misc,tree,gc,rtlflag}; the checks @samp{rtl}, @var{list} is not specified is @samp{assert,misc,tree,gc,rtlflag}; the
@samp{gcac} and @samp{valgrind} are very expensive. checks @samp{rtl}, @samp{gcac} and @samp{valgrind} are very expensive.
When checking is neither explicitly enabled nor disabled, assertion
checks are still done. To disable all checking,
@samp{--disable-checking} must be explicitly requested. Disabling
assertions will make the compiler slightly faster but increase the risk
undetected internal errors causing wrong code to be generated.
@item --enable-coverage @item --enable-coverage
@itemx --enable-coverage=@var{level} @itemx --enable-coverage=@var{level}
......
...@@ -505,6 +505,19 @@ extern int snprintf (char *, size_t, const char *, ...); ...@@ -505,6 +505,19 @@ extern int snprintf (char *, size_t, const char *, ...);
extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__) #define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
/* Use gcc_assert(EXPR) to test invariants. */
#if ENABLE_ASSERT_CHECKING
#define gcc_assert(EXPR) \
((void)(__builtin_expect (!(EXPR), 0) \
? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
#else
#define gcc_assert(EXPR) ((void)0)
#endif
/* Use gcc_unreachable() to mark unreachable locations (like an
unreachable default case of a switch. Do not use gcc_assert(0). */
#define gcc_unreachable() (fancy_abort (__FILE__, __LINE__, __FUNCTION__))
/* Provide a fake boolean type. We make no attempt to use the /* Provide a fake boolean type. We make no attempt to use the
C99 _Bool, as it may not be available in the bootstrap compiler, C99 _Bool, as it may not be available in the bootstrap compiler,
and even if it is, it is liable to be buggy. and even if it is, it is liable to be buggy.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment