aboutsummaryrefslogtreecommitdiff
path: root/gdb/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/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/configure.ac')
-rw-r--r--gdb/configure.ac39
1 files changed, 35 insertions, 4 deletions
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$, [