Re: [committed] libphobos: Add --enable-libphobos-checking configure option (PR94305)

2020-04-09 Thread Iain Buclaw via Gcc-patches
On 09/04/2020 12:02, Matthias Klose wrote:
> On 4/9/20 12:47 AM, Iain Buclaw via Gcc-patches wrote:
>> Hi,
>>
>> 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.
> 
> please could you document these in gcc/doc/install.texi, maybe together with
> other undocumented options?
> 
> Thanks, Matthias
> 

The thought did cross my mind, I wanted to remove all archaic/nonsense 
configure options first.

Iain.


Re: [committed] libphobos: Add --enable-libphobos-checking configure option (PR94305)

2020-04-09 Thread Matthias Klose
On 4/9/20 12:47 AM, Iain Buclaw via Gcc-patches wrote:
> Hi,
> 
> 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.

please could you document these in gcc/doc/install.texi, maybe together with
other undocumented options?

Thanks, Matthias


[committed] libphobos: Add --enable-libphobos-checking configure option (PR94305)

2020-04-08 Thread Iain Buclaw via Gcc-patches
Hi,

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.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

--
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/Makefile.in  |  1 +
 libphobos/configure| 40 +++---
 libphobos/configure.ac | 29 +--
 libphobos/libdruntime/Makefile.am  |  2 +-
 libphobos/libdruntime/Makefile.in  |  3 +-
 libphobos/src/Makefile.am  |  2 +-
 libphobos/src/Makefile.in  |  3 +-
 libphobos/testsuite/Makefile.in|  1 +
 libphobos/testsuite/testsuite_flags.in |  2 +-
 9 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/libphobos/Makefile.in b/libphobos/Makefile.in
index 98d35641a95..b464d605232 100644
--- a/libphobos/Makefile.in
+++ b/libphobos/Makefile.in
@@ -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@
diff --git a/libphobos/configure b/libphobos/configure
index f458ad3b086..af597b2525b 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -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
 
 
diff --git