aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/configure.ac
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-02-27 13:11:25 +0000
committerPedro Alves <palves@redhat.com>2015-02-27 16:24:02 +0000
commit3bc3d82a005466a66fa22f704c90f4486ca71344 (patch)
treebe4bdb2e820e02b2b229e0fbb8bc384f01b9476e /gdb/gdbserver/configure.ac
parentf0673d2040a49ecebfc0d3a03993d09fb4dd3e17 (diff)
downloadgdb-3bc3d82a005466a66fa22f704c90f4486ca71344.zip
gdb-3bc3d82a005466a66fa22f704c90f4486ca71344.tar.gz
gdb-3bc3d82a005466a66fa22f704c90f4486ca71344.tar.bz2
Add --enable-build-with-cxx configure switch
This new option, disabled by default for now, allows specifying whether to build GDB, GDBserver, and friends with a C++ (98/03) compiler. The name of the switch should be familiar to those who followed GCC's own C++ conversion process. . Adding -fpermissive to COMPILER in C++ mode (see the new build-with-cxx.m4 file) makes errors like these be warnings instead: gdb/infrun.c:6597:1: error: initializing argument 1 of ‘void sig_print_info(gdb_signal)’ [-fpermissive] sig_print_info (enum gdb_signal oursig) ^ gdb/infrun.c: In function ‘void do_restore_infcall_suspend_state_cleanup(void*)’: gdb/infrun.c:7164:39: error: invalid conversion from ‘void*’ to ‘infcall_suspend_state*’ [-fpermissive] restore_infcall_suspend_state (state); ^ so that the compiler carries on compiling the file. -Werror still catches the warnings, so nothing is lost, only our lifes are made easier by concentrating on getting other more important things out of the way first. There's no way to quiet those warnings. Until they're all fixed, when building in C++ mode, -Werror is disabled by default. . Adding -Wno-narrowing suppresses thousands of instances of this warning: gdb/arm-linux-tdep.c:439:1: error: narrowing conversion of ‘-1’ from ‘int’ to ‘ULONGEST {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Werror=narrowing] gdb/arm-linux-tdep.c:439:1: error: narrowing conversion of ‘-1l’ from ‘LONGEST {aka long int}’ to ‘ULONGEST {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Werror=narrowing] gdb/arm-linux-tdep.c:450:1: error: narrowing conversion of ‘-1’ from ‘int’ to ‘ULONGEST {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Werror=narrowing] We can defer handling those until we target C++11. . Adding -Wno-sign-compare suppresses thousands of instances of this warning: gdb/linux-record.c:1763:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (tmpulongest == tdep->fcntl_F_GETLK64) ^ . Adding -Wno-write-strings suppresses thousands of instances of this warning: gdb/mi/mi-cmd-var.c: In function ‘void mi_cmd_var_show_attributes(char*, char**, int)’: gdb/mi/mi-cmd-var.c:514:12: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] attstr = "editable"; ^ gdb/mi/mi-cmd-var.c:516:12: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] attstr = "noneditable"; ^ For now, it's best to hide these warnings from view until we're '-fpermissive'-clean, and can thus start building with -Werror. The C compiler has always managed to build working GDBs with these issues in the code, so a C++ compiler should too. gdb/ChangeLog: 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. gdb/gdbserver/ChangeLog: 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.
Diffstat (limited to 'gdb/gdbserver/configure.ac')
-rw-r--r--gdb/gdbserver/configure.ac33
1 files changed, 30 insertions, 3 deletions
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