From patchwork Wed Apr 8 22:47:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1268372 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=mNtBIsH5; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48yKFW6CQDz9sRN for ; Thu, 9 Apr 2020 08:48:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 20422385BF81; Wed, 8 Apr 2020 22:48:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20422385BF81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586386120; bh=tYUJlqptap9AcIbQ4I37lYGm9A9x631XJPWOrwJIvj8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mNtBIsH5MnoZZJcSKK21F4qh7H1NbzFnMXCn0qqe99V9hsjpYX1uOuWHQwSFyzPpe Foi1lsbS1EcLR6nL6q6XRO00wN4S14xYOxK93EemDJucLUK+3CMPAKE5hiVScrksv3 w7pUTvLkpJ+SNxRWgi6aes0fg3SKaALUvn1brPVA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050::465:201]) by sourceware.org (Postfix) with ESMTPS id 59411385B835 for ; Wed, 8 Apr 2020 22:48:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 59411385B835 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 48yKFG0HdhzQl8s; Thu, 9 Apr 2020 00:48:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id DTcnZBNai4Ez; Thu, 9 Apr 2020 00:48:29 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] libphobos: Add --enable-libphobos-checking configure option (PR94305) Date: Thu, 9 Apr 2020 00:47:53 +0200 Message-Id: <20200408224753.5764-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1B8F2176B X-Rspamd-Score: 1.42 / 15.00 / 15.00 X-Spam-Status: No, score=-27.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "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 a/libphobos/configure.ac b/libphobos/configure.ac index e6148f07519..ffd12981d0b 100644 --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -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) diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am index 41ccfaa339c..c7b03a5967d 100644 --- a/libphobos/libdruntime/Makefile.am +++ b/libphobos/libdruntime/Makefile.am @@ -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) \ diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index 9277e0a1665..e0688e25c81 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -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 diff --git a/libphobos/src/Makefile.am b/libphobos/src/Makefile.am index 5c17538613a..d2418a8ca83 100644 --- a/libphobos/src/Makefile.am +++ b/libphobos/src/Makefile.am @@ -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) diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in index e58dafb5e7c..45651672e1e 100644 --- a/libphobos/src/Makefile.in +++ b/libphobos/src/Makefile.in @@ -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 diff --git a/libphobos/testsuite/Makefile.in b/libphobos/testsuite/Makefile.in index b70a996d95d..6f0eaf83405 100644 --- a/libphobos/testsuite/Makefile.in +++ b/libphobos/testsuite/Makefile.in @@ -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@ diff --git a/libphobos/testsuite/testsuite_flags.in b/libphobos/testsuite/testsuite_flags.in index 990221a3d0f..808dde30993 100755 --- a/libphobos/testsuite/testsuite_flags.in +++ b/libphobos/testsuite/testsuite_flags.in @@ -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)