gdb: Respect CXXFLAGS when building with C++ compiler
authorPedro Alves <palves@redhat.com>
Thu, 21 Jan 2016 11:18:45 +0000 (11:18 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 21 Jan 2016 11:18:45 +0000 (11:18 +0000)
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-21  Pedro Alves  <palves@redhat.com>

* 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-21  Pedro Alves  <palves@redhat.com>

* Makefile.in (COMPILER_CFLAGS, CXXFLAGS): New.
(INTERNAL_CFLAGS_BASE): Use COMPILER_CFLAGS instead of CFLAGS.
* configure: Regenerate.

gdb/ChangeLog
gdb/Makefile.in
gdb/build-with-cxx.m4
gdb/configure
gdb/gdbserver/ChangeLog
gdb/gdbserver/Makefile.in
gdb/gdbserver/configure

index a377a3229848ee2a98cdd6bd4ce3c49976a90a8a..68d10ad0acbf61b62926003127ee6fe727c4b1b1 100644 (file)
@@ -1,3 +1,13 @@
+2016-01-21  Pedro Alves  <palves@redhat.com>
+
+       * 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.
+
 2016-01-21  Joel Brobecker  <brobecker@adacore.com>
 
        * location.h (new_address_location): Add new parameters
index 895ece686610409126ed588e63d63d2ebcd0b516..5e8eb9aa0392a4c716813795efaefdc6ea70e01f 100644 (file)
@@ -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.
index d282092b1272e73b725f8d79d4cf9bc3dcae4b5b..6eb9143479179b4c80eb5e304f866f164e0817a6 100644 (file)
@@ -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)
 ])
index 701cfcb02399fb3243d6711c25bb7fd6c3a6f952..26a00d8f224b428362aabe76e7d4a67f487cd036 100755 (executable)
@@ -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
index c33c5d33d25819258d335b244d54a932f791f172..9c42fcf97ff751bd4bbe1259af286dc062a3b8f1 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-21  Pedro Alves  <palves@redhat.com>
+
+       * Makefile.in (COMPILER_CFLAGS, CXXFLAGS): New.
+       (INTERNAL_CFLAGS_BASE): Use COMPILER_CFLAGS instead of CFLAGS.
+       * configure: Regenerate.
+
 2016-01-21  Yao Qi  <yao.qi@linaro.org>
 
        * linux-arm-low.c (arm_sigreturn_next_pc): Add parameter
index 4719e48576a31e4ce4ed92f97c4194fa11b1e804..f9b9dbe79a32373209f85517eeeb37968850482e 100644 (file)
@@ -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@
 
 CC = @CC@
 CXX = @CXX@
@@ -129,13 +131,14 @@ WERROR_CFLAGS = @WERROR_CFLAGS@
 WARN_CFLAGS_NO_FORMAT = `echo " $(WARN_CFLAGS) " \
                   | sed "s/ -Wformat-nonliteral / -Wno-format-nonliteral /g"`
 
-# CFLAGS is specifically reserved for setting from the command line
+# These are specifically reserved for setting from the command line
 # when running make.  I.E.  "make CFLAGS=-Wmissing-prototypes".
 CFLAGS = @CFLAGS@
+CXXFLAGS = @CXXFLAGS@
 CPPFLAGS = @CPPFLAGS@
 
 # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros.
-INTERNAL_CFLAGS_BASE =  ${CFLAGS} ${GLOBAL_CFLAGS} \
+INTERNAL_CFLAGS_BASE =  ${COMPILER_CFLAGS} ${GLOBAL_CFLAGS} \
        ${PROFILE_CFLAGS} ${INCLUDE_CFLAGS} ${CPPFLAGS}
 INTERNAL_WARN_CFLAGS =  ${INTERNAL_CFLAGS_BASE} $(WARN_CFLAGS)
 INTERNAL_CFLAGS =  ${INTERNAL_WARN_CFLAGS} $(WERROR_CFLAGS) -DGDBSERVER
index 763c77db069260eeb316a51b81a6aa68e9c3342e..4a6f26badf998b9da3f580769085e4e431ab1b2a 100755 (executable)
@@ -615,6 +615,7 @@ DEPDIR
 am__leading_dot
 host_noncanonical
 target_noncanonical
+COMPILER_CFLAGS
 COMPILER
 RANLIB
 AR
@@ -4834,12 +4835,15 @@ fi
 
   if test "$enable_build_with_cxx" = "yes"; then
     COMPILER='$(CXX)'
+    COMPILER_CFLAGS='$(CXXFLAGS)'
    else
     COMPILER='$(CC)'
+    COMPILER_CFLAGS='$(CFLAGS)'
   fi
 
 
 
+
 # Set the 'development' global.
 . $srcdir/../../bfd/development.sh
 
This page took 0.039724 seconds and 4 git commands to generate.