aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/Makefile.in17
-rw-r--r--gdb/acinclude.m43
-rw-r--r--gdb/build-with-cxx.m441
-rwxr-xr-xgdb/configure380
-rw-r--r--gdb/configure.ac39
-rw-r--r--gdb/gdbserver/ChangeLog17
-rw-r--r--gdb/gdbserver/Makefile.in16
-rw-r--r--gdb/gdbserver/acinclude.m43
-rwxr-xr-xgdb/gdbserver/configure374
-rw-r--r--gdb/gdbserver/configure.ac33
11 files changed, 908 insertions, 31 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dfaad27..d897031 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,21 @@
2015-02-27 Pedro Alves <palves@redhat.com>
+ * Makefile.in (COMPILER): New, get it from autoconf.
+ (COMPILE.pre, CC_LD): Use COMPILER.
+ (CXX): Get from autoconf instead.
+ (CXX_FOR_TARGET): Default to g++ instead of gcc.
+ * acinclude.m4: Include build-with-cxx.m4.
+ * build-with-cxx.m4: New file.
+ * configure.ac: Call AC_PROG_CXX and GDB_AC_BUILD_WITH_CXX.
+ Disable -Werror by default if building in C++ mode.
+ (build_warnings): Add -Wno-sign-compare, -Wno-write-strings and
+ -Wno-narrowing in C++ mode. Only enable -Wpointer-sign in C mode.
+ Run supported-warning-flags tests with the C++ compiler.
+ Save/restore CXXFLAGS too.
+ * configure: Regenerate.
+
+2015-02-27 Pedro Alves <palves@redhat.com>
+
* libiberty.m4: New file.
* acinclude.m4: Include libiberty.m4.
* configure.ac: Call libiberty_INIT.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index e9f22d6..e837c6f 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -79,12 +79,16 @@ MSGMERGE = msgmerge
PACKAGE = @PACKAGE@
CATALOGS = @CATALOGS@
+# The name of the compiler to use.
+COMPILER = @COMPILER@
+
# 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
# -traditional flag. Otherwise the ioctl calls in inflow.c
# will be incorrectly compiled. The "fixincludes" script in the gcc
# distribution will fix your include files up.
CC=@CC@
+CXX=@CXX@
# Dependency tracking information.
DEPMODE = @CCDEPMODE@
@@ -93,7 +97,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 = $(CC)
+COMPILE.pre = $(COMPILER)
COMPILE.post = -c -o $@
COMPILE = $(COMPILE.pre) $(INTERNAL_CFLAGS) $(COMPILE.post)
POSTCOMPILE = @true
@@ -123,7 +127,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=gcc -static
-CC_LD=$(CC)
+CC_LD=$(COMPILER)
# Where is our "include" directory? Typically $(srcdir)/../include.
# This is essentially the header file directory for the library
@@ -762,19 +766,18 @@ CC_FOR_TARGET = ` \
fi; \
fi`
-CXX = gcc
CXX_FOR_TARGET = ` \
- if [ -f $${rootme}/../gcc/xgcc ] ; then \
+ if [ -f $${rootme}/../gcc/xg++ ] ; then \
if [ -f $${rootme}/../$(target_subdir)newlib/Makefile ] ; then \
- echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/ -idirafter $${rootme}/$(target_subdir)newlib/targ-include -idirafter $${rootsrc}/../$(target_subdir)newlib/libc/include -nostdinc -B$${rootme}/../$(target_subdir)newlib/; \
+ echo $${rootme}/../gcc/xg++ -B$${rootme}/../gcc/ -idirafter $${rootme}/$(target_subdir)newlib/targ-include -idirafter $${rootsrc}/../$(target_subdir)newlib/libc/include -nostdinc -B$${rootme}/../$(target_subdir)newlib/; \
else \
- echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/; \
+ echo $${rootme}/../gcc/xg++ -B$${rootme}/../gcc/; \
fi; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo $(CXX); \
else \
- t='$(program_transform_name)'; echo gcc | sed -e '' $$t; \
+ t='$(program_transform_name)'; echo g++ | sed -e '' $$t; \
fi; \
fi`
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 0ad90e7..da22fc2 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -60,6 +60,9 @@ m4_include([common/common.m4])
dnl For libiberty_INIT.
m4_include(libiberty.m4)
+dnl For --enable-build-with-cxx and COMPILER.
+m4_include(build-with-cxx.m4)
+
## ----------------------------------------- ##
## ANSIfy the C compiler whenever possible. ##
## From Franc,ois Pinard ##
diff --git a/gdb/build-with-cxx.m4 b/gdb/build-with-cxx.m4
new file mode 100644
index 0000000..8802f4d
--- /dev/null
+++ b/gdb/build-with-cxx.m4
@@ -0,0 +1,41 @@
+dnl Copyright (C) 2014-2015 Free Software Foundation, Inc.
+dnl
+dnl This file is part of GDB.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+dnl GDB_AC_BUILD_WITH_CXX()
+dnl Provide an --enable-build-with-cxx/--disable-build-with-cxx set of options
+dnl allowing a user to build with a C++ compiler.
+
+AC_DEFUN([GDB_AC_BUILD_WITH_CXX],
+[
+ AC_ARG_ENABLE(build-with-cxx,
+ AS_HELP_STRING([--enable-build-with-cxx], [build with C++ compiler instead of C compiler]),
+ [case $enableval in
+ yes | no)
+ ;;
+ *)
+ AC_MSG_ERROR([bad value $enableval for --enable-build-with-cxx]) ;;
+ esac],
+ [enable_build_with_cxx=no])
+
+ if test "$enable_build_with_cxx" = "yes"; then
+ # We're using -fpermissive as shortcut for now.
+ COMPILER='$(CXX) -fpermissive'
+ else
+ COMPILER='$(CC)'
+ fi
+ AC_SUBST(COMPILER)
+])
diff --git a/gdb/configure b/gdb/configure
index b1a7665..3297d37 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -724,6 +724,7 @@ MAKE
CCDEPMODE
DEPDIR
am__leading_dot
+COMPILER
INSTALL_STRIP_PROGRAM
STRIP
install_sh
@@ -742,6 +743,9 @@ build
EGREP
GREP
CPP
+ac_ct_CXX
+CXXFLAGS
+CXX
OBJEXT
EXEEXT
ac_ct_CC
@@ -796,6 +800,7 @@ enable_option_checking
enable_maintainer_mode
enable_plugins
enable_largefile
+enable_build_with_cxx
with_separate_debug_dir
with_gdb_datadir
with_relocated_sources
@@ -849,6 +854,9 @@ CFLAGS
LDFLAGS
LIBS
CPPFLAGS
+CXX
+CXXFLAGS
+CCC
CPP
MAKEINFO
MAKEINFOFLAGS
@@ -1484,6 +1492,7 @@ Optional Features:
(and sometimes confusing) to the casual installer
--enable-plugins Enable support for plugins
--disable-largefile omit support for large files
+ --enable-build-with-cxx build with C++ compiler instead of C compiler
--enable-targets=TARGETS
alternative target configurations
--enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)
@@ -1567,6 +1576,8 @@ Some influential environment variables:
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
+ CXX C++ compiler command
+ CXXFLAGS C++ compiler flags
CPP C preprocessor
MAKEINFO Parent configure detects if it is of sufficient version.
MAKEINFOFLAGS
@@ -1696,6 +1707,44 @@ fi
} # ac_fn_c_try_compile
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ return $ac_retval
+
+} # ac_fn_cxx_try_compile
+
# ac_fn_c_try_cpp LINENO
# ----------------------
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -3487,6 +3536,264 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+ if test -n "$CCC"; then
+ CXX=$CCC
+ else
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CXX+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CXX"; then
+ ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CXX" && break
+ done
+fi
+if test -z "$CXX"; then
+ ac_ct_CXX=$CXX
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CXX"; then
+ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_CXX="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CXX" && break
+done
+
+ if test "x$ac_ct_CXX" = x; then
+ CXX="g++"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CXX=$ac_ct_CXX
+ fi
+fi
+
+ fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ rm -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GXX=yes
+else
+ GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+ ac_cxx_werror_flag=yes
+ ac_cv_prog_cxx_g=no
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+else
+ CXXFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+ if test "$GXX" = yes; then
+ CXXFLAGS="-g -O2"
+ else
+ CXXFLAGS="-g"
+ fi
+else
+ if test "$GXX" = yes; then
+ CXXFLAGS="-O2"
+ else
+ CXXFLAGS=
+ fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
@@ -4634,6 +4941,30 @@ ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+# See if we are building with C++, and substitute COMPILER.
+
+ # Check whether --enable-build-with-cxx was given.
+if test "${enable_build_with_cxx+set}" = set; then :
+ enableval=$enable_build_with_cxx; case $enableval in
+ yes | no)
+ ;;
+ *)
+ as_fn_error "bad value $enableval for --enable-build-with-cxx" "$LINENO" 5 ;;
+ esac
+else
+ enable_build_with_cxx=no
+fi
+
+
+ if test "$enable_build_with_cxx" = "yes"; then
+ # We're using -fpermissive as shortcut for now.
+ COMPILER='$(CXX) -fpermissive'
+ else
+ COMPILER='$(CC)'
+ fi
+
+
+
# Dependency checking.
rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
@@ -13038,8 +13369,11 @@ if test "${enable_werror+set}" = set; then :
fi
-# Enable -Werror by default when using gcc. Turn it off for releases.
-if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then
+# Enable -Werror by default when using gcc in C mode. Leave it off
+# for C++ until we're warning clean. Turn it off for releases.
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" \
+ && test x"$enable_build_with_cxx" != x"yes" \
+ && $development; then
ERROR_ON_WARNING=yes
fi
@@ -13048,13 +13382,21 @@ if test "${ERROR_ON_WARNING}" = yes ; then
WERROR_CFLAGS="-Werror"
fi
+# These options work in either C or C++ modes.
build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
--Wpointer-sign \
-Wno-unused -Wunused-value -Wunused-function \
-Wno-switch -Wno-char-subscripts -Wmissing-prototypes \
-Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
-Wold-style-declaration -Wold-style-definition"
+# Now add in C and C++ specific options, depending on mode.
+if test "$enable_build_with_cxx" = "yes"; then
+ build_warnings="$build_warnings -Wno-sign-compare -Wno-write-strings \
+-Wno-narrowing"
+else
+ build_warnings="$build_warnings -Wpointer-sign"
+fi
+
# Enable -Wno-format by default when using gcc on mingw since many
# GCC versions complain about %I64.
case "${host}" in
@@ -13092,6 +13434,18 @@ if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
fi
fi
+
+# The set of warnings supported by a C++ compiler is not the same as
+# of the C compiler.
+if test "$enable_build_with_cxx" = "yes"; then
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+fi
+
WARN_CFLAGS=""
if test "x${build_warnings}" != x -a "x$GCC" = xyes
then
@@ -13102,10 +13456,14 @@ $as_echo_n "checking compiler warning flags... " >&6; }
for w in ${build_warnings}; do
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
- *) # Check that GCC accepts it
+ *)
+ # Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $w"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ saved_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $w"
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
@@ -13116,11 +13474,12 @@ main ()
return 0;
}
_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
WARN_CFLAGS="${WARN_CFLAGS} $w"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS="$saved_CFLAGS"
+ CXXFLAGS="$saved_CXXFLAGS"
esac
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WARN_CFLAGS} ${WERROR_CFLAGS}" >&5
@@ -13129,6 +13488,15 @@ fi
+if test "$enable_build_with_cxx" = "yes"; then
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+
# In the Cygwin environment, we need some additional flags.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cygwin" >&5
$as_echo_n "checking for cygwin... " >&6; }
diff --git a/gdb/configure.ac b/gdb/configure.ac
index e72dfba..0898d0e 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -27,6 +27,8 @@ AM_MAINTAINER_MODE
. $srcdir/../bfd/development.sh
AC_PROG_CC
+AC_PROG_CXX
+
AC_USE_SYSTEM_EXTENSIONS
ACX_LARGEFILE
AM_PROG_CC_STDC
@@ -36,6 +38,9 @@ AC_CONFIG_AUX_DIR(..)
AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM
+# See if we are building with C++, and substitute COMPILER.
+GDB_AC_BUILD_WITH_CXX
+
# Dependency checking.
ZW_CREATE_DEPDIR
ZW_PROG_COMPILER_DEPENDENCIES([CC])
@@ -1959,8 +1964,11 @@ AC_ARG_ENABLE(werror,
*) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
esac])
-# Enable -Werror by default when using gcc. Turn it off for releases.
-if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then
+# Enable -Werror by default when using gcc in C mode. Leave it off
+# for C++ until we're warning clean. Turn it off for releases.
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" \
+ && test x"$enable_build_with_cxx" != x"yes" \
+ && $development; then
ERROR_ON_WARNING=yes
fi
@@ -1969,13 +1977,21 @@ if test "${ERROR_ON_WARNING}" = yes ; then
WERROR_CFLAGS="-Werror"
fi
+# These options work in either C or C++ modes.
build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
--Wpointer-sign \
-Wno-unused -Wunused-value -Wunused-function \
-Wno-switch -Wno-char-subscripts -Wmissing-prototypes \
-Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
-Wold-style-declaration -Wold-style-definition"
+# Now add in C and C++ specific options, depending on mode.
+if test "$enable_build_with_cxx" = "yes"; then
+ build_warnings="$build_warnings -Wno-sign-compare -Wno-write-strings \
+-Wno-narrowing"
+else
+ build_warnings="$build_warnings -Wpointer-sign"
+fi
+
# Enable -Wno-format by default when using gcc on mingw since many
# GCC versions complain about %I64.
case "${host}" in
@@ -2011,6 +2027,13 @@ esac
if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
fi])dnl
+
+# The set of warnings supported by a C++ compiler is not the same as
+# of the C compiler.
+if test "$enable_build_with_cxx" = "yes"; then
+ AC_LANG_PUSH([C++])
+fi
+
WARN_CFLAGS=""
if test "x${build_warnings}" != x -a "x$GCC" = xyes
then
@@ -2020,11 +2043,15 @@ then
for w in ${build_warnings}; do
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
- *) # Check that GCC accepts it
+ *)
+ # Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $w"
+ saved_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $w"
AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
CFLAGS="$saved_CFLAGS"
+ CXXFLAGS="$saved_CXXFLAGS"
esac
done
AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
@@ -2032,6 +2059,10 @@ fi
AC_SUBST(WARN_CFLAGS)
AC_SUBST(WERROR_CFLAGS)
+if test "$enable_build_with_cxx" = "yes"; then
+ AC_LANG_POP([C++])
+fi
+
# In the Cygwin environment, we need some additional flags.
AC_CACHE_CHECK([for cygwin], gdb_cv_os_cygwin,
[AC_EGREP_CPP(^lose$, [
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 28b582f..111ed5b 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,22 @@
2015-02-27 Pedro Alves <palves@redhat.com>
+ * Makefile.in (COMPILER): New, get it from autoconf.
+ (CXX): Get from autoconf instead.
+ (COMPILE.pre): Use COMPILER.
+ (CC-LD): Rename to ...
+ (CC_LD): ... this. Use COMPILER.
+ (gdbserver$(EXEEXT), gdbreplay$(EXEEXT), $(IPA_LIB)): Adjust.
+ (CXX_FOR_TARGET): Default to g++ instead of gcc.
+ * acinclude.m4: Include build-with-cxx.m4.
+ * configure.ac: Call AC_PROG_CXX and GDB_AC_BUILD_WITH_CXX.
+ Disable -Werror by default if building in C++ mode.
+ (build_warnings): Add -Wno-sign-compare, -Wno-write-strings and
+ -Wno-narrowing in C++ mode. Run supported-warning-flags tests with
+ the C++ compiler. Save/restore CXXFLAGS too.
+ * configure: Regenerate.
+
+2015-02-27 Pedro Alves <palves@redhat.com>
+
* acinclude.m4: Include libiberty.m4.
* configure.ac: Call libiberty_INIT.
* config.in, configure: Regenerate.
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index e479c7c..cb35470 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -49,7 +49,11 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
RANLIB = @RANLIB@
+# The name of the compiler to use.
+COMPILER = @COMPILER@
+
CC = @CC@
+CXX = @CXX@
AR = @AR@
AR_FLAGS = rc
@@ -60,7 +64,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 = $(CC)
+COMPILE.pre = $(COMPILER)
COMPILE.post = -c -o $@
COMPILE = $(COMPILE.pre) $(INTERNAL_CFLAGS) $(COMPILE.post)
POSTCOMPILE = @true
@@ -78,8 +82,8 @@ 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=gcc -static
-CC-LD=${CC}
+#CC_LD=gcc -static
+CC_LD=$(COMPILER)
# Where is the "include" directory? Traditionally ../include or ./include
INCLUDE_DIR = ${srcdir}/../../include
@@ -294,7 +298,7 @@ clean-info: force
gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(LIBGNU) $(LIBIBERTY)
rm -f gdbserver$(EXEEXT)
- ${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \
+ $(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \
$(LIBGNU) $(LIBIBERTY) $(GDBSERVER_LIBS) $(XM_CLIBS)
$(LIBGNU) $(LIBIBERTY) $(GNULIB_H): all-lib
@@ -304,7 +308,7 @@ all-lib: $(GNULIB_BUILDDIR)/Makefile $(LIBIBERTY_BUILDDIR)/Makefile
gdbreplay$(EXEEXT): $(GDBREPLAY_OBS) $(LIBGNU) $(LIBIBERTY)
rm -f gdbreplay$(EXEEXT)
- ${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \
+ $(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \
$(XM_CLIBS) $(LIBGNU) $(LIBIBERTY)
IPA_OBJS=ax-ipa.o tracepoint-ipa.o format-ipa.o utils-ipa.o \
@@ -316,7 +320,7 @@ IPA_LIB=libinproctrace.so
$(IPA_LIB): $(IPA_OBJS) ${ADD_DEPS} ${CDEPS}
rm -f $(IPA_LIB)
- ${CC-LD} -shared -fPIC -Wl,--no-undefined $(INTERNAL_CFLAGS) \
+ $(CC_LD) -shared -fPIC -Wl,--no-undefined $(INTERNAL_CFLAGS) \
$(INTERNAL_LDFLAGS) -o $(IPA_LIB) ${IPA_OBJS} -ldl -pthread
# Put the proper machine-specific files first, so M-. on a machine
diff --git a/gdb/gdbserver/acinclude.m4 b/gdb/gdbserver/acinclude.m4
index e5f4b76..0b86c04 100644
--- a/gdb/gdbserver/acinclude.m4
+++ b/gdb/gdbserver/acinclude.m4
@@ -23,6 +23,9 @@ m4_include(../common/common.m4)
dnl For libiberty_INIT.
m4_include(../libiberty.m4)
+dnl For --enable-build-with-cxx and COMPILER.
+m4_include(../build-with-cxx.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 b/gdb/gdbserver/configure
index 7c39130..a14def9 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -615,6 +615,7 @@ DEPDIR
am__leading_dot
host_noncanonical
target_noncanonical
+COMPILER
RANLIB
AR
INSTALL_DATA
@@ -635,6 +636,9 @@ build
EGREP
GREP
CPP
+ac_ct_CXX
+CXXFLAGS
+CXX
OBJEXT
EXEEXT
ac_ct_CC
@@ -688,6 +692,7 @@ ac_user_opts='
enable_option_checking
enable_maintainer_mode
enable_largefile
+enable_build_with_cxx
enable_libmcheck
with_ust
with_ust_include
@@ -706,6 +711,9 @@ CFLAGS
LDFLAGS
LIBS
CPPFLAGS
+CXX
+CXXFLAGS
+CCC
CPP'
@@ -1328,6 +1336,7 @@ Optional Features:
--enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer
--disable-largefile omit support for large files
+ --enable-build-with-cxx build with C++ compiler instead of C compiler
--enable-libmcheck Try linking with -lmcheck if available
--enable-werror treat compile warnings as errors
--enable-inprocess-agent
@@ -1354,6 +1363,8 @@ Some influential environment variables:
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
+ CXX C++ compiler command
+ CXXFLAGS C++ compiler flags
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
@@ -1474,6 +1485,44 @@ fi
} # ac_fn_c_try_compile
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ return $ac_retval
+
+} # ac_fn_cxx_try_compile
+
# ac_fn_c_try_cpp LINENO
# ----------------------
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -3206,6 +3255,263 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+ if test -n "$CCC"; then
+ CXX=$CCC
+ else
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CXX+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CXX"; then
+ ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CXX" && break
+ done
+fi
+if test -z "$CXX"; then
+ ac_ct_CXX=$CXX
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CXX"; then
+ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_CXX="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CXX" && break
+done
+
+ if test "x$ac_ct_CXX" = x; then
+ CXX="g++"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CXX=$ac_ct_CXX
+ fi
+fi
+
+ fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ rm -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GXX=yes
+else
+ GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+ ac_cxx_werror_flag=yes
+ ac_cv_prog_cxx_g=no
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+else
+ CXXFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+ if test "$GXX" = yes; then
+ CXXFLAGS="-g -O2"
+ else
+ CXXFLAGS="-g"
+ fi
+else
+ if test "$GXX" = yes; then
+ CXXFLAGS="-O2"
+ else
+ CXXFLAGS=
+ fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
@@ -4403,6 +4709,30 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h
fi
+# See if we are building with C++, and substitute COMPILER.
+
+ # Check whether --enable-build-with-cxx was given.
+if test "${enable_build_with_cxx+set}" = set; then :
+ enableval=$enable_build_with_cxx; case $enableval in
+ yes | no)
+ ;;
+ *)
+ as_fn_error "bad value $enableval for --enable-build-with-cxx" "$LINENO" 5 ;;
+ esac
+else
+ enable_build_with_cxx=no
+fi
+
+
+ if test "$enable_build_with_cxx" = "yes"; then
+ # We're using -fpermissive as shortcut for now.
+ COMPILER='$(CXX) -fpermissive'
+ else
+ COMPILER='$(CC)'
+ fi
+
+
+
# Set the 'development' global.
. $srcdir/../../bfd/development.sh
@@ -5451,8 +5781,11 @@ if test "${enable_werror+set}" = set; then :
fi
-# Enable -Werror by default when using gcc. Turn it off for releases.
-if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then
+# Enable -Werror by default when using gcc in C mode. Leave it off
+# for C++ until we're warning clean. Turn it off for releases.
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" \
+ && test x"$enable_build_with_cxx" != x"yes" \
+ && $development; then
ERROR_ON_WARNING=yes
fi
@@ -5464,6 +5797,23 @@ fi
build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
-Wformat-nonliteral -Wno-char-subscripts -Wempty-body"
+# Now add in C and C++ specific options, depending on mode.
+if test "$enable_build_with_cxx" = "yes"; then
+ build_warnings="$build_warnings -Wno-sign-compare -Wno-write-strings \
+-Wno-narrowing"
+fi
+
+# The set of warnings supported by a C++ compiler is not the same as
+# of the C compiler.
+if test "$enable_build_with_cxx" = "yes"; then
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+fi
+
WARN_CFLAGS=""
if test "x$GCC" = xyes
then
@@ -5474,10 +5824,14 @@ $as_echo_n "checking compiler warning flags... " >&6; }
for w in ${build_warnings}; do
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
- *) # Check that GCC accepts it
+ *)
+ # Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $w"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ saved_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $w"
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
@@ -5488,11 +5842,12 @@ main ()
return 0;
}
_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
WARN_CFLAGS="${WARN_CFLAGS} $w"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS="$saved_CFLAGS"
+ CXXFLAGS="$saved_CXXFLAGS"
esac
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WARN_CFLAGS} ${WERROR_CFLAGS}" >&5
@@ -5501,6 +5856,15 @@ fi
+if test "$enable_build_with_cxx" = "yes"; then
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+
old_LIBS="$LIBS"
LIBS="$LIBS -ldl"
for ac_func in dladdr
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 60636f7..cefc69e 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -26,6 +26,7 @@ AC_CONFIG_HEADER(config.h:config.in)
AM_MAINTAINER_MODE
AC_PROG_CC
+AC_PROG_CXX
AC_GNU_SOURCE
AC_SYS_LARGEFILE
@@ -39,6 +40,9 @@ AC_ARG_PROGRAM
AC_HEADER_STDC
+# See if we are building with C++, and substitute COMPILER.
+GDB_AC_BUILD_WITH_CXX
+
# Set the 'development' global.
. $srcdir/../../bfd/development.sh
@@ -150,8 +154,11 @@ AC_ARG_ENABLE(werror,
*) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
esac])
-# Enable -Werror by default when using gcc. Turn it off for releases.
-if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then
+# Enable -Werror by default when using gcc in C mode. Leave it off
+# for C++ until we're warning clean. Turn it off for releases.
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" \
+ && test x"$enable_build_with_cxx" != x"yes" \
+ && $development; then
ERROR_ON_WARNING=yes
fi
@@ -163,6 +170,18 @@ fi
build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
-Wformat-nonliteral -Wno-char-subscripts -Wempty-body"
+# Now add in C and C++ specific options, depending on mode.
+if test "$enable_build_with_cxx" = "yes"; then
+ build_warnings="$build_warnings -Wno-sign-compare -Wno-write-strings \
+-Wno-narrowing"
+fi
+
+# The set of warnings supported by a C++ compiler is not the same as
+# of the C compiler.
+if test "$enable_build_with_cxx" = "yes"; then
+ AC_LANG_PUSH([C++])
+fi
+
WARN_CFLAGS=""
if test "x$GCC" = xyes
then
@@ -172,11 +191,15 @@ then
for w in ${build_warnings}; do
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
- *) # Check that GCC accepts it
+ *)
+ # Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $w"
+ saved_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $w"
AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
CFLAGS="$saved_CFLAGS"
+ CXXFLAGS="$saved_CXXFLAGS"
esac
done
AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
@@ -184,6 +207,10 @@ fi
AC_SUBST(WARN_CFLAGS)
AC_SUBST(WERROR_CFLAGS)
+if test "$enable_build_with_cxx" = "yes"; then
+ AC_LANG_POP([C++])
+fi
+
dnl dladdr is glibc-specific. It is used by thread-db.c but only for
dnl debugging messages. It lives in -ldl which is handled below so we don't
dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily