From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49529 invoked by alias); 28 Oct 2016 10:44:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 49414 invoked by uid 89); 28 Oct 2016 10:44:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Oct 2016 10:44:46 +0000 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9SAhZ3E055191 for ; Fri, 28 Oct 2016 06:44:43 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 26c3eu51h5-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 28 Oct 2016 06:44:43 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Oct 2016 11:44:40 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 28 Oct 2016 11:44:39 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 517341B08069 for ; Fri, 28 Oct 2016 11:46:46 +0100 (BST) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9SAicYo15663374 for ; Fri, 28 Oct 2016 10:44:38 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u9SAicFE002851 for ; Fri, 28 Oct 2016 04:44:38 -0600 Received: from ThinkPad (dyn-9-152-212-68.boeblingen.de.ibm.com [9.152.212.68]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u9SAicrO002843; Fri, 28 Oct 2016 04:44:38 -0600 Date: Fri, 28 Oct 2016 10:44:00 -0000 From: Philipp Rudo To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] gdb: Require C++11 In-Reply-To: <62202286-b8c3-df2f-0744-fc4d6ebc4b45@redhat.com> References: <1477596094-3244-1-git-send-email-palves@redhat.com> <1477596094-3244-3-git-send-email-palves@redhat.com> <20161028104718.540c10ed@ThinkPad> <62202286-b8c3-df2f-0744-fc4d6ebc4b45@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16102810-0040-0000-0000-0000024F5A9D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16102810-0041-0000-0000-00002259E076 Message-Id: <20161028124437.02361f81@ThinkPad> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-28_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=29 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610280190 X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00784.txt.bz2 Hi Pedro sorry, my bad. Should have seen its generated code... Without it your patch looks much nicer ;) Phil On Fri, 28 Oct 2016 10:03:13 +0100 Pedro Alves wrote: > On 10/28/2016 09:47 AM, Philipp Rudo wrote: > > > Without knowing much about autoconf. But you are repeating those > > exact 280 lines a total of 6 times in this patch. Isn't there a > > nicer way? Like moving it to a function? It would make the path > > significantly shorter. > > Oh, you're looking at "configure", but that's a generated file that > autoconf spits out. The source for that repeated code is > ax_cxx_compile_stdcxx.m4 (the file added by patch #1), and that one > does contain a single copy of that code. autoconf decides to > expand the same code more than once because the > ax_cxx_compile_stdcxx.m4 file has support for testing c++14 too, and > that inlines the C++11 standards tests too: > > dnl Test body for checking C++11 support > > m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], > _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 > ) > > > dnl Test body for checking C++14 support > > m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], > _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 > _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 > ) > > Becasily, those AX_CXX_COMPILE_STDCXX_foo calls mean > "inline body of test code" here. So the duplicated > code is already factored out and maintained in a single place. > > (I didn't strip out the support for C++14 from that > script, to minimize changes compared to the upstream > copy.) > > Below's the same patch but without the autogenerated bits. > > From ffb94ceac7fc12d6147bc3280bd8cd7d30dda4e1 Mon Sep 17 00:00:00 2001 > From: Pedro Alves > Date: Thu, 13 Oct 2016 00:27:45 +0100 > Subject: [PATCH] gdb: Require C++11 > > Use AX_CXX_COMPILE_STDCXX to detect if the compiler supports C++11, > and if -std=xxx switches are necessary to enable C++11. > > We need to tweak AX_CXX_COMPILE_STDCXX a bit though. Pristine > upstream AX_CXX_COMPILE_STDCXX appends -std=gnu++11 to CXX directly. > That doesn't work for us, because the top level Makefile passes CXX > down to subdirs, and that overrides whatever gdb/Makefile may set CXX > to. The result would be that a make invocation from the build/gdb/ > directory would use "g++ -std=gnu++11" as expected, while a make > invocation at the top level would not. > > So instead of having AX_CXX_COMPILE_STDCXX set CXX directly, tweak it > to AC_SUBST a separate variable -- CXX_DIALECT -- and use '$(CXX) > (CXX_DIALECT)' to compile/link. > > Confirmed that this enables C++11 starting with gcc 4.8, the first gcc > release with full C++11 support. > > Also confirmed that configure errors out gracefully with older GCC > releases: > > checking whether /opt/gcc-4.7/bin/g++ supports C++11 features by > default... no checking whether /opt/gcc-4.7/bin/g++ supports C++11 > features with -std=gnu++11... no checking > whether /opt/gcc-4.7/bin/g++ supports C++11 features with > -std=gnu++0x... no checking whether /opt/gcc-4.7/bin/g++ supports > C++11 features with -std=c++11... no checking > whether /opt/gcc-4.7/bin/g++ supports C++11 features with > -std=c++0x... no checking whether /opt/gcc-4.7/bin/g++ supports C++11 > features with +std=c++11... no checking whether /opt/gcc-4.7/bin/g++ > supports C++11 features with -h std=c++11... no configure: error: *** > A compiler with support for C++11 language features is required. > Makefile:9451: recipe for target 'configure-gdb' failed make[1]: *** > [configure-gdb] Error 1 make[1]: Leaving directory > '/home/pedro/brno/pedro/gdb/mygit/cxx-convertion/build-gcc-4.7' > > If we need to revert back to making C++03 optional, all that's > necessary is to change the "mandatory" to "optional" in configure.ac > and regenerate configure (both gdb and gdbserver). > > gdb/ChangeLog: > yyyy-mm-dd Pedro Alves > > * Makefile.in (CXX_DIALECT): Get from configure. > (COMPILE.pre, CC_LD): Append $(CXX_DIALECT). > (FLAGS_TO_PASS): Pass CXX_DIALECT. > * acinclude.m4: Include ax_cxx_compile_stdcxx.m4. > * ax_cxx_compile_stdcxx.m4: Add FSF copyright header. Set and > AC_SUBST CXX_DIALECT instead of changing CXX/CXXCPP. > * configure.ac: Call AX_CXX_COMPILE_STDCXX. > * config.in: Regenerate. > * configure: Regenerate. > > gdb/gdbserver/ChangeLog: > yyyy-mm-dd Pedro Alves > > * Makefile.in (CXX_DIALECT): Get from configure. > (COMPILE.pre, CC_LD): Append $(CXX_DIALECT). > * acinclude.m4: Include ../ax_cxx_compile_stdcxx.m4. > * configure.ac: Call AX_CXX_COMPILE_STDCXX. > * config.in: Regenerate. > * configure: Regenerate. > --- > gdb/Makefile.in | 6 +- > gdb/acinclude.m4 | 2 + > gdb/ax_cxx_compile_stdcxx.m4 | 21 +- > gdb/config.in | 3 + > gdb/configure | 981 > ++++++++++++++++++++++++++++++++++++++++++- > gdb/configure.ac | 4 + gdb/gdbserver/Makefile.in | > 5 +- gdb/gdbserver/acinclude.m4 | 2 + > gdb/gdbserver/config.in | 3 + > gdb/gdbserver/configure | 981 > ++++++++++++++++++++++++++++++++++++++++++- > gdb/gdbserver/configure.ac | 4 + 11 files changed, 1998 > insertions(+), 14 deletions(-) > > diff --git a/gdb/Makefile.in b/gdb/Makefile.in > index 2c88434..d035d8e 100644 > --- a/gdb/Makefile.in > +++ b/gdb/Makefile.in > @@ -86,6 +86,7 @@ CATALOGS = @CATALOGS@ > # distribution will fix your include files up. > CC=@CC@ > CXX=@CXX@ > +CXX_DIALECT= @CXX_DIALECT@ > > # Dependency tracking information. > DEPMODE = @CCDEPMODE@ > @@ -94,7 +95,7 @@ depcomp = $(SHELL) $(srcdir)/../depcomp > > # Note that these are overridden by GNU make-specific code below if > # GNU make is used. The overrides implement dependency tracking. > -COMPILE.pre = $(CXX) > +COMPILE.pre = $(CXX) $(CXX_DIALECT) > COMPILE.post = -c -o $@ > COMPILE = $(COMPILE.pre) $(INTERNAL_CFLAGS) $(COMPILE.post) > POSTCOMPILE = @true > @@ -125,7 +126,7 @@ MAKEHTMLFLAGS = > # Set this up with gcc if you have gnu ld and the loader will print > out # line numbers for undefined references. > #CC_LD=g++ -static > -CC_LD=$(CXX) > +CC_LD=$(CXX) $(CXX_DIALECT) > > # Where is our "include" directory? Typically $(srcdir)/../include. > # This is essentially the header file directory for the library > @@ -742,6 +743,7 @@ FLAGS_TO_PASS = \ > "CC=$(CC)" \ > "CFLAGS=$(CFLAGS)" \ > "CXX=$(CXX)" \ > + "CXX_DIALECT=$(CXX_DIALECT)" \ > "CXXFLAGS=$(CXXFLAGS)" \ > "DLLTOOL=$(DLLTOOL)" \ > "LDFLAGS=$(LDFLAGS)" \ > diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 > index 4b3f7fc..daf4a91 100644 > --- a/gdb/acinclude.m4 > +++ b/gdb/acinclude.m4 > @@ -68,6 +68,8 @@ m4_include(libiberty.m4) > dnl For GDB_AC_PTRACE. > m4_include(ptrace.m4) > > +m4_include(ax_cxx_compile_stdcxx.m4) > + > ## ----------------------------------------- ## > ## ANSIfy the C compiler whenever possible. ## > ## From Franc,ois Pinard ## > diff --git a/gdb/ax_cxx_compile_stdcxx.m4 > b/gdb/ax_cxx_compile_stdcxx.m4 index 2c18e49..ffaeb6e 100644 > --- a/gdb/ax_cxx_compile_stdcxx.m4 > +++ b/gdb/ax_cxx_compile_stdcxx.m4 > @@ -1,3 +1,12 @@ > +# Copyright (c) 2016 Free Software Foundation, Inc. > +# > +# Originally based on the AX_CXX_COMPILE_STDCXX macro found at the > url +# below. > +# > +# Local GDB customizations: > +# > +# - AC_SUBST CXX_DIALECT instead of changing CXX/CXXCPP. > +# > # > =========================================================================== > # > http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html > # > =========================================================================== > @@ -58,6 +67,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [$3], > [optional], [ax_cxx_compile_cxx$1_required=false], [m4_fatal([invalid > third argument `$3' to AX_CXX_COMPILE_STDCXX])]) > AC_LANG_PUSH([C++])dnl > + CXX_DIALECT="" > ac_success=no > AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, > ax_cv_cxx_compile_cxx$1, > @@ -81,10 +91,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl > [eval $cachevar=no]) > CXX="$ac_save_CXX"]) > if eval test x\$$cachevar = xyes; then > - CXX="$CXX $switch" > - if test -n "$CXXCPP" ; then > - CXXCPP="$CXXCPP $switch" > - fi > + CXX_DIALECT="$switch" > ac_success=yes > break > fi > @@ -107,10 +114,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl > [eval $cachevar=no]) > CXX="$ac_save_CXX"]) > if eval test x\$$cachevar = xyes; then > - CXX="$CXX $switch" > - if test -n "$CXXCPP" ; then > - CXXCPP="$CXXCPP $switch" > - fi > + CXX_DIALECT="$switch" > ac_success=yes > break > fi > @@ -131,6 +135,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl > [define if the compiler supports basic C++$1 syntax]) > fi > AC_SUBST(HAVE_CXX$1) > + AC_SUBST(CXX_DIALECT) > ]) > > > diff --git a/gdb/configure.ac b/gdb/configure.ac > index e451e60..83c2707 100644 > --- a/gdb/configure.ac > +++ b/gdb/configure.ac > @@ -38,6 +38,10 @@ AC_CONFIG_AUX_DIR(..) > AC_CANONICAL_SYSTEM > AC_ARG_PROGRAM > > +# We require a C++11 compiler. Check if one is available, and if > +# necessary, set CXX_DIALECT to some -std=xxx switch. > +AX_CXX_COMPILE_STDCXX(11, , mandatory) > + > # Dependency checking. > ZW_CREATE_DEPDIR > ZW_PROG_COMPILER_DEPENDENCIES([CC]) > diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in > index 0db5287..5ba559c 100644 > --- a/gdb/gdbserver/Makefile.in > +++ b/gdb/gdbserver/Makefile.in > @@ -51,6 +51,7 @@ RANLIB = @RANLIB@ > > CC = @CC@ > CXX = @CXX@ > +CXX_DIALECT= @CXX_DIALECT@ > AR = @AR@ > AR_FLAGS = rc > > @@ -61,7 +62,7 @@ depcomp = $(SHELL) $(srcdir)/../depcomp > > # Note that these are overridden by GNU make-specific code below if > # GNU make is used. The overrides implement dependency tracking. > -COMPILE.pre = $(CXX) > +COMPILE.pre = $(CXX) $(CXX_DIALECT) > COMPILE.post = -c -o $@ > COMPILE = $(COMPILE.pre) $(INTERNAL_CFLAGS) $(COMPILE.post) > POSTCOMPILE = @true > @@ -80,7 +81,7 @@ VPATH = @srcdir@ > # Set this up with gcc if you have gnu ld and the loader will print > out # line numbers for undefinded refs. > #CC_LD=g++ -static > -CC_LD=$(CXX) > +CC_LD=$(CXX) $(CXX_DIALECT) > > # Where is the "include" directory? Traditionally ../include > or ./include INCLUDE_DIR = ${srcdir}/../../include > diff --git a/gdb/gdbserver/acinclude.m4 b/gdb/gdbserver/acinclude.m4 > index 8ec9188..c75d783 100644 > --- a/gdb/gdbserver/acinclude.m4 > +++ b/gdb/gdbserver/acinclude.m4 > @@ -29,6 +29,8 @@ m4_include(../libiberty.m4) > dnl For GDB_AC_PTRACE. > m4_include(../ptrace.m4) > > +m4_include(../ax_cxx_compile_stdcxx.m4) > + > dnl Check for existence of a type $1 in libthread_db.h > dnl Based on BFD_HAVE_SYS_PROCFS_TYPE in bfd/bfd.m4. > > diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac > index 6d5907b..11d8c79 100644 > --- a/gdb/gdbserver/configure.ac > +++ b/gdb/gdbserver/configure.ac > @@ -38,6 +38,10 @@ AC_PROG_RANLIB > > AC_ARG_PROGRAM > > +# We require a C++11 compiler. Check if one is available, and if > +# necessary, set CXX_DIALECT to some -std=xxx switch. > +AX_CXX_COMPILE_STDCXX(11, , mandatory) > + > AC_HEADER_STDC > > # Set the 'development' global.