From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94613 invoked by alias); 20 Jan 2016 20:40:22 -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 94584 invoked by uid 89); 20 Jan 2016 20:40:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=crossed, H*f:sk:1453288, Hx-languages-length:5599, 160120 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 20 Jan 2016 20:40:20 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 6BB1F558D6; Wed, 20 Jan 2016 20:40:19 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0KKeIV6022589; Wed, 20 Jan 2016 15:40:18 -0500 Message-ID: <569FF0B2.7070300@redhat.com> Date: Wed, 20 Jan 2016 20:40:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: Respect CXXFLAGS when building with C++ compiler References: <1453288024-19890-1-git-send-email-palves@redhat.com> <569FE883.7050706@ericsson.com> In-Reply-To: <569FE883.7050706@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-01/txt/msg00494.txt.bz2 On 01/20/2016 08:05 PM, Simon Marchi wrote: > On 16-01-20 06:07 AM, Pedro Alves wrote: >> Currently, even when built with --enable-build-with-cxx, gdb uses >> CFLAGS instead of CXXFLAGS. This commit fixes it. >> >> CXXFLAGS set in the environment when configure was run is now honored >> in the generated gdb/Makefile, and you can also override CXXFLAGS in >> the command like at make time, with the usual 'make CXXFLAGS="..."' >> >> Objects built with a C compiler (e.g., gnulib) still honor CFLAGS >> instead. >> >> gdb/ChangeLog: >> 2016-01-20 Pedro Alves >> >> * Makefile.in (COMPILER_CFLAGS): New. >> (CXXFLAGS): Get it from configure. >> (INTERNAL_CFLAGS_BASE, INTERNAL_LDFLAGS): Use COMPILER_CFLAGS >> instead of CFLAGS. >> * build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Set and AC_SUBST >> COMPILER_CFLAGS. >> * configure: Regenerate. >> >> gdb/gdbserver/ChangeLog: >> 2016-01-20 Pedro Alves >> >> * Makefile.in (COMPILER_CFLAGS, CXXFLAGS): New. >> (INTERNAL_CFLAGS_BASE, INTERNAL_LDFLAGS): Use COMPILER_CFLAGS >> instead of CFLAGS. >> * configure: Regenerate. >> --- >> gdb/Makefile.in | 18 +++++++++--------- >> gdb/build-with-cxx.m4 | 3 +++ >> gdb/configure | 4 ++++ >> gdb/gdbserver/Makefile.in | 7 +++++-- >> gdb/gdbserver/configure | 4 ++++ >> 5 files changed, 25 insertions(+), 11 deletions(-) >> >> diff --git a/gdb/Makefile.in b/gdb/Makefile.in >> index 895ece6..5e8eb9a 100644 >> --- a/gdb/Makefile.in >> +++ b/gdb/Makefile.in >> @@ -81,6 +81,8 @@ CATALOGS = @CATALOGS@ >> >> # The name of the compiler to use. >> COMPILER = @COMPILER@ >> +# Set to CFLAGS or CXXFLAGS, depending on compiler/language. >> +COMPILER_CFLAGS = @COMPILER_CFLAGS@ >> >> # If you are compiling with GCC, make sure that either 1) You have the >> # fixed include files where GCC can reach them, or 2) You use the >> @@ -551,9 +553,10 @@ GLOBAL_CFLAGS = $(MH_CFLAGS) >> >> PROFILE_CFLAGS = @PROFILE_CFLAGS@ >> >> -# CFLAGS is specifically reserved for setting from the command line >> -# when running make. I.E. "make CFLAGS=-Wmissing-prototypes". >> +# These are specifically reserved for setting from the command line >> +# when running make. I.E.: "make CFLAGS=-Wmissing-prototypes". >> CFLAGS = @CFLAGS@ >> +CXXFLAGS = @CXXFLAGS@ >> >> # Set by configure, for e.g. expat. Python installations are such that >> # C headers are included using their basename (for example, we #include >> @@ -563,14 +566,9 @@ CFLAGS = @CFLAGS@ >> # a bit the consequences by putting the Python includes last in the list. >> INTERNAL_CPPFLAGS = @CPPFLAGS@ @GUILE_CPPFLAGS@ @PYTHON_CPPFLAGS@ >> >> -# Need to pass this to testsuite for "make check". Probably should be >> -# consistent with top-level Makefile.in and gdb/testsuite/Makefile.in >> -# so "make check" has the same result no matter where it is run. >> -CXXFLAGS = -g -O >> - >> # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros. >> INTERNAL_CFLAGS_BASE = \ >> - $(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \ >> + $(COMPILER_CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \ >> $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) $(ZLIBINC) \ >> $(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \ >> $(INTL_CFLAGS) $(INCGNU) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS) >> @@ -585,7 +583,9 @@ LDFLAGS = @LDFLAGS@ >> # I think it's perfectly reasonable for a user to set -pg in CFLAGS >> # and have it work; that's why CFLAGS is here. >> # PROFILE_CFLAGS is _not_ included, however, because we use monstartup. >> -INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) $(LDFLAGS) $(CONFIG_LDFLAGS) >> +INTERNAL_LDFLAGS = \ >> + $(COMPILER_CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) \ >> + $(LDFLAGS) $(CONFIG_LDFLAGS) >> >> # If your system is missing alloca(), or, more likely, it's there but >> # it doesn't work, then refer to libiberty. >> diff --git a/gdb/build-with-cxx.m4 b/gdb/build-with-cxx.m4 >> index d282092..6eb9143 100644 >> --- a/gdb/build-with-cxx.m4 >> +++ b/gdb/build-with-cxx.m4 >> @@ -33,8 +33,11 @@ AC_DEFUN([GDB_AC_BUILD_WITH_CXX], >> >> if test "$enable_build_with_cxx" = "yes"; then >> COMPILER='$(CXX)' >> + COMPILER_CFLAGS='$(CXXFLAGS)' >> else >> COMPILER='$(CC)' >> + COMPILER_CFLAGS='$(CFLAGS)' >> fi >> AC_SUBST(COMPILER) >> + AC_SUBST(COMPILER_CFLAGS) >> ]) >> diff --git a/gdb/configure b/gdb/configure >> index 56deb9c..34d6539 100755 >> --- a/gdb/configure >> +++ b/gdb/configure >> @@ -731,6 +731,7 @@ MAKE >> CCDEPMODE >> DEPDIR >> am__leading_dot >> +COMPILER_CFLAGS >> COMPILER >> INSTALL_STRIP_PROGRAM >> STRIP >> @@ -5015,12 +5016,15 @@ fi >> >> if test "$enable_build_with_cxx" = "yes"; then >> COMPILER='$(CXX)' >> + COMPILER_CFLAGS='$(CXXFLAGS)' >> else >> COMPILER='$(CC)' >> + COMPILER_CFLAGS='$(CFLAGS)' >> fi >> >> >> >> + >> # Dependency checking. >> rm -rf .tst 2>/dev/null >> mkdir .tst 2>/dev/null >> diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in >> index 4719e48..f9b9dbe 100644 >> --- a/gdb/gdbserver/Makefile.in >> +++ b/gdb/gdbserver/Makefile.in >> @@ -51,6 +51,8 @@ RANLIB = @RANLIB@ >> >> # The name of the compiler to use. >> COMPILER = @COMPILER@ >> +# Set to CFLAGS or CXXFLAGS, depending on compiler/language. >> +COMPILER_CFLAGS = @COMPILER_CFLAGS@ > > Maybe call this COMPILER_FLAGS? Yeah, it crossed my mind too, but then all others end up _CFLAGS, like INTERNAL_CFLAGS, GLOBAL_CFLAGS, GDB_WERROR_CFLAGS, INTERNAL_WARN_CFLAGS, etc., which are used in c++ too, that I thought it ended up looking the odd one out. WDYT? > > Otherwise, LGTM. > Thanks, Pedro Alves