From patchwork Fri Feb 27 13:24:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 5340 Received: (qmail 87796 invoked by alias); 27 Feb 2015 13:24:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 87783 invoked by uid 89); 27 Feb 2015 13:24:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_50, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 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; Fri, 27 Feb 2015 13:24:14 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1RDOCvh016777 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 27 Feb 2015 08:24:12 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1RDO9Rj028375; Fri, 27 Feb 2015 08:24:10 -0500 Message-ID: <54F06FF9.8010303@redhat.com> Date: Fri, 27 Feb 2015 13:24:09 +0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 02/36] Add --enable-build-with-cxx configure switch References: <1423524046-20605-1-git-send-email-palves@redhat.com> <1423524046-20605-3-git-send-email-palves@redhat.com> <54DA821E.4070608@gmail.com> In-Reply-To: <54DA821E.4070608@gmail.com> On 02/10/2015 10:11 PM, Yao Qi wrote: >> @@ -172,11 +186,17 @@ then >> for w in ${build_warnings}; do >> case $w in >> -Werr*) WERROR_CFLAGS=-Werror ;; >> - *) # Check that GCC accepts it >> + *) >> + # Check whether GCC accepts it. Append -Werror to CFLAGS > > s/CFLAGS/CXXFLAGS/ ? Since you want to catch cc1plus warnings, so > option should be append CXXFLAGS. The -Werror idea here was just so that we could put C or C++-specific warnings in build_warnings and have them automatically filtered out. I ended up explicitly splitting C vs C++ specific warnings now, so this -Werror is gone. I also moved "-fpermissive" to $COMPILER instead, as really that's a C++ mode, not a warning flag. We want to use it even if gdb is configured with --enable-build-warning=no. Here's the new version. Let me know what you think. ---- From 847cc322ca685432ea2962499e8fe3b8448e748f Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 27 Feb 2015 13:11:25 +0000 Subject: [PATCH] Add --enable-build-with-cxx configure switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 * 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 * 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. --- gdb/Makefile.in | 17 +- gdb/acinclude.m4 | 3 + gdb/build-with-cxx.m4 | 41 +++++ gdb/configure | 380 ++++++++++++++++++++++++++++++++++++++++++++- gdb/configure.ac | 39 ++++- gdb/gdbserver/Makefile.in | 16 +- gdb/gdbserver/acinclude.m4 | 3 + gdb/gdbserver/configure | 374 +++++++++++++++++++++++++++++++++++++++++++- gdb/gdbserver/configure.ac | 33 +++- 9 files changed, 875 insertions(+), 31 deletions(-) create mode 100644 gdb/build-with-cxx.m4 diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 16e2f1c..1921ebf 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 b0ff259..b3e8ac1 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/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 . + +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 cf7b81a..db6a93c 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 CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory + 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 56c0709..30fa2f5 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/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 ba4a21f..cbed321 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/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 CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory + 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