libphobos: Add --enable-libphobos-checking configure option
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 8 Apr 2020 22:41:14 +0000 (00:41 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 8 Apr 2020 22:46:39 +0000 (00:46 +0200)
As GDCFLAGS is overriden by the top-level make file with '-O2 -g',
libphobos ends up always being built with all contracts, invariants, and
asserts compiled in.  This adds a new configurable that defaults to omit
compiling any run-time checks into the library using '-frelease'.

Other choices either set the flags '-fno-release', enabling all run-time
checks, or '-fassert', which only compiles in asserts.

The omission of compiling in contracts results in a smaller library
size, with faster build times.

libphobos/ChangeLog:

PR d/94305
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add --enable-libphobos-checking and substitute
CHECKING_DFLAGS.  Remove -frelease from GDCFLAGS.
* libdruntime/Makefile.am: Add CHECKING_DFLAGS to AM_DFLAGS.
* libdruntime/Makefile.in: Regenerate.
* src/Makefile.am: Add CHECKING_DFLAGS to AM_DFLAGS.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* testsuite/testsuite_flags.in: Add -fno-release -funittest to
--gdcflags.

libphobos/ChangeLog
libphobos/Makefile.in
libphobos/configure
libphobos/configure.ac
libphobos/libdruntime/Makefile.am
libphobos/libdruntime/Makefile.in
libphobos/src/Makefile.am
libphobos/src/Makefile.in
libphobos/testsuite/Makefile.in
libphobos/testsuite/testsuite_flags.in

index d8d37ef1c2b5b32456c196a0fdae615328379852..5b9fe432bb9e098be057b76c31a0eaf8214ac16d 100644 (file)
@@ -1,3 +1,18 @@
+2020-04-09  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+       PR d/94305
+       * Makefile.in: Regenerate.
+       * configure: Regenerate.
+       * configure.ac: Add --enable-libphobos-checking and substitute
+       CHECKING_DFLAGS.  Remove -frelease from GDCFLAGS.
+       * libdruntime/Makefile.am: Add CHECKING_DFLAGS to AM_DFLAGS.
+       * libdruntime/Makefile.in: Regenerate.
+       * src/Makefile.am: Add CHECKING_DFLAGS to AM_DFLAGS.
+       * src/Makefile.in: Regenerate.
+       * testsuite/Makefile.in: Regenerate.
+       * testsuite/testsuite_flags.in: Add -fno-release -funittest to
+       --gdcflags.
+
 2020-04-09  Iain Buclaw  <ibuclaw@gdcproject.org>
 
        * configure: Regenerate.
index 98d35641a95ab2460660a4d8d7a38b31e6739395..b464d605232919712b2cfb32561a5b8b77ebada1 100644 (file)
@@ -207,6 +207,7 @@ CCASFLAGS = @CCASFLAGS@
 CC_FOR_BUILD = @CC_FOR_BUILD@
 CFLAGS = @CFLAGS@
 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CHECKING_DFLAGS = @CHECKING_DFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
index f458ad3b086104aa011d8e3abb8197e1ee4c8472..af597b2525b787ff2ac96865c4649c0a620887b2 100755 (executable)
@@ -637,6 +637,7 @@ WARN_DFLAGS
 GDCFLAGSX
 libtool_VERSION
 SPEC_PHOBOS_DEPS
+CHECKING_DFLAGS
 ENABLE_LIBPHOBOS_FALSE
 ENABLE_LIBPHOBOS_TRUE
 gdc_include_dir
@@ -842,6 +843,7 @@ with_cross_host
 enable_version_specific_runtime_libs
 with_toolexeclibdir
 enable_libphobos
+enable_libphobos_checking
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1488,6 +1490,11 @@ Optional Features:
                           Specify that runtime libraries should be installed
                           in a compiler-specific directory
   --enable-libphobos      Enable libphobos
+  --enable-libphobos-checking[=LIST]
+                          enable expensive run-time checks. With LIST, enable
+                          only specific categories of checks. Categories are:
+                          yes,no,all,none,release. Flags are: assert or other
+                          strings
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -11642,7 +11649,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11645 "configure"
+#line 11652 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11748,7 +11755,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11751 "configure"
+#line 11758 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15288,6 +15295,31 @@ else
 fi
 
 
+# Enable expensive internal checks
+# Check whether --enable-libphobos-checking was given.
+if test "${enable_libphobos_checking+set}" = set; then :
+  enableval=$enable_libphobos_checking; ac_checking_flags="${enableval}"
+else
+  ac_checking_flags=release
+fi
+
+IFS="${IFS=    }"; ac_save_IFS="$IFS"; IFS="$IFS,"
+for check in release $ac_checking_flags
+do
+       case $check in
+       # These set all the flags to specific states
+       yes|all) RELEASE_FLAG="-fno-release" ; ASSERT_FLAG= ;;
+       no|none|release) RELEASE_FLAG="-frelease" ; ASSERT_FLAG= ;;
+       # These enable particular checks
+       assert) ASSERT_FLAG="-fassert" ;;
+       # Accept
+       *) ;;
+       esac
+done
+IFS="$ac_save_IFS"
+CHECKING_DFLAGS="$RELEASE_FLAG $ASSERT_FLAG"
+
+
 # Add drtbegin.o/drtend.o to startfile/endfile specs in libgphobos.spec
 if test "$DCFG_MINFO_BRACKETING" = "false"; then
     DRTSTUFF_SPEC=$srcdir/src/drtstuff.spec
@@ -15306,12 +15338,12 @@ libtool_VERSION=1:0:0
 
 # Set default flags (after DRUNTIME_WERROR!)
 if test -z "$GDCFLAGS"; then
-    GDCFLAGS="-g -frelease -O2"
+    GDCFLAGS="-g -O2"
 fi
 
 
 if test -z "$GDCFLAGSX"; then
-    GDCFLAGSX="-g -fno-release -funittest"
+    GDCFLAGSX="-g"
 fi
 
 
index e6148f0751985f683b46b96dea5029989d46e751..ffd12981d0bd60bed7e5006198d7bf7ab36a4c67 100644 (file)
@@ -187,6 +187,31 @@ yes:*) use_libphobos=yes ;;
 esac
 AM_CONDITIONAL(ENABLE_LIBPHOBOS, test x$use_libphobos = xyes)
 
+# Enable expensive internal checks
+AC_ARG_ENABLE(libphobos-checking,
+[AS_HELP_STRING([[--enable-libphobos-checking[=LIST]]],
+               [enable expensive run-time checks.  With LIST,
+                enable only specific categories of checks.
+                Categories are: yes,no,all,none,release.
+                Flags are: assert or other strings])],
+[ac_checking_flags="${enableval}"],[ac_checking_flags=release])
+IFS="${IFS=    }"; ac_save_IFS="$IFS"; IFS="$IFS,"
+for check in release $ac_checking_flags
+do
+       case $check in
+       # These set all the flags to specific states
+       yes|all) RELEASE_FLAG="-fno-release" ; ASSERT_FLAG= ;;
+       no|none|release) RELEASE_FLAG="-frelease" ; ASSERT_FLAG= ;;
+       # These enable particular checks
+       assert) ASSERT_FLAG="-fassert" ;;
+       # Accept
+       *) ;;
+       esac
+done
+IFS="$ac_save_IFS"
+CHECKING_DFLAGS="$RELEASE_FLAG $ASSERT_FLAG"
+AC_SUBST(CHECKING_DFLAGS)
+
 # Add drtbegin.o/drtend.o to startfile/endfile specs in libgphobos.spec
 if test "$DCFG_MINFO_BRACKETING" = "false"; then
     DRTSTUFF_SPEC=$srcdir/src/drtstuff.spec
@@ -205,12 +230,12 @@ AC_SUBST(libtool_VERSION)
 
 # Set default flags (after DRUNTIME_WERROR!)
 if test -z "$GDCFLAGS"; then
-    GDCFLAGS="-g -frelease -O2"
+    GDCFLAGS="-g -O2"
 fi
 AC_SUBST(GDCFLAGS)
 
 if test -z "$GDCFLAGSX"; then
-    GDCFLAGSX="-g -fno-release -funittest"
+    GDCFLAGSX="-g"
 fi
 AC_SUBST(GDCFLAGSX)
 
index 41ccfaa339c8c1206a5ac59922c78bad062e868f..c7b03a5967de8f08e0fd51361d5cfbc73873998b 100644 (file)
@@ -24,7 +24,7 @@ D_EXTRA_DFLAGS=-nostdinc -I $(srcdir) -I .
 # D flags for compilation
 AM_DFLAGS= \
        $(phobos_compiler_pic_flag) \
-       $(WARN_DFLAGS)
+       $(WARN_DFLAGS) $(CHECKING_DFLAGS)
 
 # Install all D and DI files
 ALL_DRUNTIME_INSTALL_DSOURCES = $(DRUNTIME_DSOURCES) \
index 9277e0a16655c14b3070822f3108c623b47bbfad..e0688e25c815e00f82d8fe9303452e5b8eccaf01 100644 (file)
@@ -555,6 +555,7 @@ CCASFLAGS = @CCASFLAGS@
 CC_FOR_BUILD = @CC_FOR_BUILD@
 CFLAGS = @CFLAGS@
 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CHECKING_DFLAGS = @CHECKING_DFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -715,7 +716,7 @@ D_EXTRA_DFLAGS = -nostdinc -I $(srcdir) -I .
 # D flags for compilation
 AM_DFLAGS = \
        $(phobos_compiler_pic_flag) \
-       $(WARN_DFLAGS)
+       $(WARN_DFLAGS) $(CHECKING_DFLAGS)
 
 
 # Install all D and DI files
index 5c17538613a095d881ee9b4cb65ece4536526c68..d2418a8ca83e0d6fc157a7ee2bc3427f02e80869 100644 (file)
@@ -25,7 +25,7 @@ D_EXTRA_DFLAGS=-nostdinc -I $(srcdir) \
 # D flags for compilation
 AM_DFLAGS= \
        $(phobos_compiler_pic_flag) \
-       $(WARN_DFLAGS)
+       $(WARN_DFLAGS) $(CHECKING_DFLAGS)
 
 # Install all D files
 ALL_PHOBOS_INSTALL_DSOURCES = $(PHOBOS_DSOURCES)
index e58dafb5e7c11070912001a20846b12b34dcf083..45651672e1eb0bd25ac0e58eea302cfad85c5048 100644 (file)
@@ -278,6 +278,7 @@ CCASFLAGS = @CCASFLAGS@
 CC_FOR_BUILD = @CC_FOR_BUILD@
 CFLAGS = @CFLAGS@
 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CHECKING_DFLAGS = @CHECKING_DFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -440,7 +441,7 @@ D_EXTRA_DFLAGS = -nostdinc -I $(srcdir) \
 # D flags for compilation
 AM_DFLAGS = \
        $(phobos_compiler_pic_flag) \
-       $(WARN_DFLAGS)
+       $(WARN_DFLAGS) $(CHECKING_DFLAGS)
 
 
 # Install all D files
index b70a996d95d3b4744de19f5d6c3fdff6c0d163a1..6f0eaf83405b3f9f1caa720120b53086e2f1fe2d 100644 (file)
@@ -151,6 +151,7 @@ CCASFLAGS = @CCASFLAGS@
 CC_FOR_BUILD = @CC_FOR_BUILD@
 CFLAGS = @CFLAGS@
 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CHECKING_DFLAGS = @CHECKING_DFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
index 990221a3d0f1ef34100178328bc978a7f626807d..808dde30993f74cb2d844b5a10b388088fbdf502 100755 (executable)
@@ -28,7 +28,7 @@ case ${query} in
       ;;
     --gdcflags)
       GDCFLAGS_default="-fmessage-length=0 -fno-show-column"
-      GDCFLAGS_config="@WARN_DFLAGS@ @GDCFLAGSX@"
+      GDCFLAGS_config="@WARN_DFLAGS@ @GDCFLAGSX@ -fno-release -funittest"
       echo ${GDCFLAGS_default} ${GDCFLAGS_config}
       ;;
     --gdcpaths)