* build gdbserver with -Werror by default
@ 2010-08-26 18:18 Pedro Alves
2010-08-27 8:57 ` Pierre Muller
0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2010-08-26 18:18 UTC (permalink / raw)
To: gdb-patches
I've now applied this to build gdbserver with -Werror by default (on gcc),
and the usual --disable-werror/--enable-werror commands.
Tested on by building on x86_86-unknown-linux-gnu with
and without --disable-werror, and observing that -Werror
is included passed to gcc appropriately.
This is mostly copied from gdb/configure.ac, and I brought
the warning flags GDB uses, except for the -Wno-FOO settings,
since gdbserver was already building with -Wall (hence, doesn't
need to disable specific warnings -Wall implies).
This may break the build on some targets, which just means
that the target specific code should be fixed to be warning
free.
--
Pedro Alves
2010-08-26 Pedro Alves <pedro@codesourcery.com>
* Makefile.in (WARN_CFLAGS): Get it from configure.
(WERROR_CFLAGS): New.
(INTERNAL_CFLAGS): Add WERROR_CFLAGS.
* configure.ac: Introduce --enable-werror, which adds -Werror to
the compiler command line. Enabled by default. Disable with
--disable-werror. Add -Wdeclaration-after-statement
Wpointer-arith and -Wformat-nonliteral to warning flags.
* configure: Regenerate.
---
gdb/gdbserver/Makefile.in | 5 +--
gdb/gdbserver/configure | 69 +++++++++++++++++++++++++++++++++++++++++++++
gdb/gdbserver/configure.ac | 42 +++++++++++++++++++++++++++
3 files changed, 114 insertions(+), 2 deletions(-)
Index: src/gdb/gdbserver/Makefile.in
===================================================================
--- src.orig/gdb/gdbserver/Makefile.in 2010-07-31 08:53:16.000000000 +0100
+++ src/gdb/gdbserver/Makefile.in 2010-08-26 18:08:58.000000000 +0100
@@ -86,14 +86,15 @@ INCLUDE_CFLAGS = -I. -I${srcdir} -I$(src
GLOBAL_CFLAGS = ${MT_CFLAGS} ${MH_CFLAGS}
#PROFILE_CFLAGS = -pg
-WARN_CFLAGS = -Wall
+WARN_CFLAGS = @WARN_CFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
# CFLAGS is specifically reserved for setting from the command line
# when running make. I.E. "make CFLAGS=-Wmissing-prototypes".
CFLAGS = @CFLAGS@
# INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros.
-INTERNAL_CFLAGS = $(WARN_CFLAGS) ${CFLAGS} ${GLOBAL_CFLAGS} \
+INTERNAL_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) ${CFLAGS} ${GLOBAL_CFLAGS} \
${PROFILE_CFLAGS} ${INCLUDE_CFLAGS}
# LDFLAGS is specifically reserved for setting from the command line
Index: src/gdb/gdbserver/configure.ac
===================================================================
--- src.orig/gdb/gdbserver/configure.ac 2010-07-19 15:47:22.000000000 +0100
+++ src/gdb/gdbserver/configure.ac 2010-08-26 18:55:45.000000000 +0100
@@ -93,6 +93,48 @@ fi
AC_SUBST(ustlibs)
AC_SUBST(ustinc)
+AC_ARG_ENABLE(werror,
+ AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
+ [case "${enableval}" in
+ yes | y) ERROR_ON_WARNING="yes" ;;
+ no | n) ERROR_ON_WARNING="no" ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
+ esac])
+
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+ ERROR_ON_WARNING=yes
+fi
+
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+ WERROR_CFLAGS="-Werror"
+fi
+
+build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
+-Wformat-nonliteral "
+
+WARN_CFLAGS=""
+if test "x$GCC" = xyes
+then
+ AC_MSG_CHECKING(compiler warning flags)
+ # Separate out the -Werror flag as some files just cannot be
+ # compiled with it enabled.
+ for w in ${build_warnings}; do
+ case $w in
+ -Werr*) WERROR_CFLAGS=-Werror ;;
+ *) # Check that GCC accepts it
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $w"
+ AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
+ CFLAGS="$saved_CFLAGS"
+ esac
+ done
+ AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
+fi
+AC_SUBST(WARN_CFLAGS)
+AC_SUBST(WERROR_CFLAGS)
+
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
Index: src/gdb/gdbserver/configure
===================================================================
--- src.orig/gdb/gdbserver/configure 2010-07-19 15:47:22.000000000 +0100
+++ src/gdb/gdbserver/configure 2010-08-26 18:55:49.000000000 +0100
@@ -601,6 +601,8 @@ RDYNAMIC
REPORT_BUGS_TEXI
REPORT_BUGS_TO
PKGVERSION
+WERROR_CFLAGS
+WARN_CFLAGS
ustinc
ustlibs
LIBOBJS
@@ -673,6 +675,7 @@ enable_option_checking
with_ust
with_ust_include
with_ust_lib
+enable_werror
with_pkgversion
with_bugurl
with_libthread_db
@@ -1300,6 +1303,12 @@ if test -n "$ac_init_help"; then
cat <<\_ACEOF
+Optional Features:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-werror treat compile warnings as errors
+
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
@@ -3914,6 +3923,66 @@ fi
+# Check whether --enable-werror was given.
+if test "${enable_werror+set}" = set; then :
+ enableval=$enable_werror; case "${enableval}" in
+ yes | y) ERROR_ON_WARNING="yes" ;;
+ no | n) ERROR_ON_WARNING="no" ;;
+ *) as_fn_error "bad value ${enableval} for --enable-werror" "$LINENO" 5 ;;
+ esac
+fi
+
+
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+ ERROR_ON_WARNING=yes
+fi
+
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+ WERROR_CFLAGS="-Werror"
+fi
+
+build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
+-Wformat-nonliteral "
+
+WARN_CFLAGS=""
+if test "x$GCC" = xyes
+then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler warning flags" >&5
+$as_echo_n "checking compiler warning flags... " >&6; }
+ # Separate out the -Werror flag as some files just cannot be
+ # compiled with it enabled.
+ for w in ${build_warnings}; do
+ case $w in
+ -Werr*) WERROR_CFLAGS=-Werror ;;
+ *) # Check that GCC accepts it
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $w"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ WARN_CFLAGS="${WARN_CFLAGS} $w"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$saved_CFLAGS"
+ esac
+ done
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WARN_CFLAGS} ${WERROR_CFLAGS}" >&5
+$as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; }
+fi
+
+
+
old_LIBS="$LIBS"
LIBS="$LIBS -ldl"
for ac_func in dladdr
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: build gdbserver with -Werror by default
2010-08-26 18:18 build gdbserver with -Werror by default Pedro Alves
@ 2010-08-27 8:57 ` Pierre Muller
2010-08-27 10:29 ` Pedro Alves
0 siblings, 1 reply; 5+ messages in thread
From: Pierre Muller @ 2010-08-27 8:57 UTC (permalink / raw)
To: 'Pedro Alves', gdb-patches
Hi Pedro,
Cygwin 1.7 fails on gdbserver:
gcc -c -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -
Werror -gstabs+ -O0 -I. -I../../../src/gdb/gdbserver -I../../../src/gdb/gdbse
rver/../common -I../../../src/gdb/gdbserver/../regformats -I../../../src/gdb/gdb
server/../../include ../../../src/gdb/gdbserver/tracepoint.c
cc1: warnings being treated as errors
../../../src/gdb/gdbserver/tracepoint.c: In function `add_tracepoint_action':
../../../src/gdb/gdbserver/tracepoint.c:1870: error: array subscript has type `c
har'
make[3]: *** [tracepoint.o] Error 1
isxdigit argument type is int, not char according to man page...
Adding an explicit typecast to int at that line
allows to go to compilation of win32-low.c, but there you
end up with warnings about deprecated functions...
To fix that, you would need to use the same kind of macros
as in gdb/windows-nat.c
Pierre Muller
Pascal language support maintainer for GDB
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: build gdbserver with -Werror by default
2010-08-27 8:57 ` Pierre Muller
@ 2010-08-27 10:29 ` Pedro Alves
2010-08-27 14:50 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2010-08-27 10:29 UTC (permalink / raw)
To: gdb-patches; +Cc: Pierre Muller
On Friday 27 August 2010 09:55:11, Pierre Muller wrote:
> Hi Pedro,
>
> Cygwin 1.7 fails on gdbserver:
> gcc -c -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -
> Werror -gstabs+ -O0 -I. -I../../../src/gdb/gdbserver -I../../../src/gdb/gdbse
> rver/../common -I../../../src/gdb/gdbserver/../regformats -I../../../src/gdb/gdb
> server/../../include ../../../src/gdb/gdbserver/tracepoint.c
> cc1: warnings being treated as errors
> ../../../src/gdb/gdbserver/tracepoint.c: In function `add_tracepoint_action':
> ../../../src/gdb/gdbserver/tracepoint.c:1870: error: array subscript has type `c
> har'
> make[3]: *** [tracepoint.o] Error 1
>
> isxdigit argument type is int, not char according to man page...
> Adding an explicit typecast to int at that line
> allows to go to compilation of win32-low.c,
and it'd fail elsewhere if it kept going, most probably. GDB has
a bunch of suspicious code like this as well (e.g., in remote.c), so it
ended up with -Wno-char-subscripts. I didn't bring that warning over to
gdbserver, as I didn't see any warning when building for linux and
mingw32, so I thought it was unnecessary (it is probably gcc version
dependent whether that's part of -Wall). Since this is certainly
not a new warning (it's the fact that it causes an error that it's new)
I've now added -Wno-char-subscripts to gdbserver as well...
> but there you
> end up with warnings about deprecated functions...
> To fix that, you would need to use the same kind of macros
> as in gdb/windows-nat.c
Hmm, I have no clue about what deprecated warnings are these,
and what macros you're talking about. Are these new warnings, or
it is just that they've been there before, but ignored?
--
Pedro Alves
2010-08-27 Pedro Alves <pedro@codesourcery.com>
* configure.ac (build_warnings): Add -Wno-char-subscripts.
* configure: Regenerate.
---
gdb/gdbserver/configure | 2 +-
gdb/gdbserver/configure.ac | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Index: src/gdb/gdbserver/configure.ac
===================================================================
--- src.orig/gdb/gdbserver/configure.ac 2010-08-26 19:32:03.000000000 +0100
+++ src/gdb/gdbserver/configure.ac 2010-08-27 11:02:56.000000000 +0100
@@ -112,7 +112,7 @@ if test "${ERROR_ON_WARNING}" = yes ; th
fi
build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
--Wformat-nonliteral "
+-Wformat-nonliteral -Wno-char-subscripts"
WARN_CFLAGS=""
if test "x$GCC" = xyes
Index: src/gdb/gdbserver/configure
===================================================================
--- src.orig/gdb/gdbserver/configure 2010-08-26 19:32:03.000000000 +0100
+++ src/gdb/gdbserver/configure 2010-08-27 11:03:45.000000000 +0100
@@ -3944,7 +3944,7 @@ if test "${ERROR_ON_WARNING}" = yes ; th
fi
build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
--Wformat-nonliteral "
+-Wformat-nonliteral -Wno-char-subscripts"
WARN_CFLAGS=""
if test "x$GCC" = xyes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: build gdbserver with -Werror by default
2010-08-27 10:29 ` Pedro Alves
@ 2010-08-27 14:50 ` Daniel Jacobowitz
2010-08-27 14:54 ` Pedro Alves
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2010-08-27 14:50 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Pierre Muller
On Fri, Aug 27, 2010 at 11:29:08AM +0100, Pedro Alves wrote:
> and it'd fail elsewhere if it kept going, most probably. GDB has
> a bunch of suspicious code like this as well (e.g., in remote.c), so it
> ended up with -Wno-char-subscripts. I didn't bring that warning over to
> gdbserver, as I didn't see any warning when building for linux and
> mingw32, so I thought it was unnecessary (it is probably gcc version
> dependent whether that's part of -Wall). Since this is certainly
> not a new warning (it's the fact that it causes an error that it's new)
> I've now added -Wno-char-subscripts to gdbserver as well...
Having just run into this, not all implementations of the C library
arrange for isdigit et al to report a char-subscript error. The GLIBC
version casts the argument to int; just recently, newlib started
deliberately issuing the error.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: build gdbserver with -Werror by default
2010-08-27 14:50 ` Daniel Jacobowitz
@ 2010-08-27 14:54 ` Pedro Alves
0 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2010-08-27 14:54 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, Pierre Muller
On Friday 27 August 2010 15:50:05, Daniel Jacobowitz wrote:
>
> On Fri, Aug 27, 2010 at 11:29:08AM +0100, Pedro Alves wrote:
> > and it'd fail elsewhere if it kept going, most probably. GDB has
> > a bunch of suspicious code like this as well (e.g., in remote.c), so it
> > ended up with -Wno-char-subscripts. I didn't bring that warning over to
> > gdbserver, as I didn't see any warning when building for linux and
> > mingw32, so I thought it was unnecessary (it is probably gcc version
> > dependent whether that's part of -Wall). Since this is certainly
> > not a new warning (it's the fact that it causes an error that it's new)
> > I've now added -Wno-char-subscripts to gdbserver as well...
>
> Having just run into this, not all implementations of the C library
> arrange for isdigit et al to report a char-subscript error. The GLIBC
> version casts the argument to int; just recently, newlib started
> deliberately issuing the error.
Ah, right, I followed that newlib discussion, but didn't connect
the dots in cygwin-uses-newlib.
--
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-08-27 14:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-26 18:18 build gdbserver with -Werror by default Pedro Alves
2010-08-27 8:57 ` Pierre Muller
2010-08-27 10:29 ` Pedro Alves
2010-08-27 14:50 ` Daniel Jacobowitz
2010-08-27 14:54 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).