This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] New "make check-headers" rule.
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Joel Brobecker <brobecker at adacore dot com>, gdb-patches at sourceware dot org
- Date: Mon, 13 Jan 2014 19:42:45 +0000
- Subject: Re: [PATCH] New "make check-headers" rule.
- Authentication-results: sourceware.org; auth=none
- References: <1384151855-12926-1-git-send-email-brobecker at adacore dot com> <5283CD04 dot 3080501 at redhat dot com> <87y54qvfw1 dot fsf at fleche dot redhat dot com>
On 11/14/2013 09:21 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>
> Pedro> New "make check-headers" rule.
>
> It seems like a good idea to me.
>
> Pedro> +check-headers:
> Pedro> + @echo Checking headers.
> Pedro> + for i in $(CHECK_HEADERS) ; do \
> Pedro> + $(NODEPS_COMPILE) -Wno-error $(PYTHON_CFLAGS) -include defs.h \
> Pedro> + $(srcdir)/$$i -o /dev/null ; \
> Pedro> + done
>
> I'm curious why -Wno-error.
No good reason, I'm afraid.
> Also why not -fsyntax-only?
It hadn't crossed my radar.
Looking at it, I wasn't sure it was the exact same -- e.g.,
whether it expanded C++ templates, but google convinced me it
does. I looked over gcc's codebase (grep for flag_syntax_only)
and I saw things like folding and optimization possibly behaving
differently when that flag in enabled. I was going to prefer
not using the flag on those grounds, but then I timed it:
make check-headers w/ -o /dev/null
real 1m35.383s
user 0m44.862s
sys 0m8.140s
make check-headers w/ -fsyntax-only:
real 0m42.648s
user 0m32.563s
sys 0m7.891s
That's a considerable difference, so that convinced me.
Nice one.
If that flag indeed causes a difference of visible
behavior wrt to errors detected, I guess I'll call it
a gcc bug.
One extra thing we discussed offline is that with
-fsyntax-only, gcc needs to be told the language being
compiled explicitly ("-x c"), otherwise we get:
$ gcc -c -fsyntax-only (...)
cc1: error: output filename specified twice
Below's what I pushed.
Thanks.
----------
New "make check-headers" rule.
Tries to compile each header in isolation, thus ensuring headers are
self-contained.
Defaults to checking all $HFILES_NO_SRCDIR headers.
Do:
make check-headers CHECK_HEADERS="header.h list.h"
to check specific headers.
gdb/
2014-01-13 Pedro Alves <palves@redhat.com>
* Makefile.in (CHECK_HEADERS): New variable.
(check-headers:): New rule.
---
gdb/ChangeLog | 5 +++++
gdb/Makefile.in | 22 ++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6cdafcc..18ed4d3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-13 Pedro Alves <palves@redhat.com>
+
+ * Makefile.in (CHECK_HEADERS): New variable.
+ (check-headers:): New rule.
+
2014-01-13 Tom Tromey <tromey@redhat.com>
* cli/cli-setshow.c (do_set_command): Update.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 824b26b..9811cbe 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1050,6 +1050,28 @@ check//%: force
"$$target"; \
else true; fi
+# The set of headers checked by 'check-headers' by default.
+CHECK_HEADERS = $(HFILES_NO_SRCDIR)
+
+# Try to compile each header in isolation, thus ensuring headers are
+# self-contained.
+#
+# Defaults to checking all $HFILES_NO_SRCDIR headers.
+#
+# Do:
+#
+# make check-headers CHECK_HEADERS="header.h list.h"
+#
+# to check specific headers.
+#
+check-headers:
+ @echo Checking headers.
+ for i in $(CHECK_HEADERS) ; do \
+ $(CC) -x c -c -fsyntax-only $(INTERNAL_CFLAGS) \
+ -include defs.h $(srcdir)/$$i ; \
+ done
+.PHONY: check-headers
+
info install-info clean-info dvi pdf install-pdf html install-html: force
@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
--
1.7.11.7