From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20578 invoked by alias); 13 Jan 2014 19:42:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 20568 invoked by uid 89); 13 Jan 2014 19:42:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS 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 ESMTP; Mon, 13 Jan 2014 19:42:49 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0DJglb3013894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Jan 2014 14:42:47 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0DJgjgP026556; Mon, 13 Jan 2014 14:42:46 -0500 Message-ID: <52D441B5.20307@redhat.com> Date: Mon, 13 Jan 2014 19:42:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Tom Tromey CC: Joel Brobecker , gdb-patches@sourceware.org Subject: Re: [PATCH] New "make check-headers" rule. References: <1384151855-12926-1-git-send-email-brobecker@adacore.com> <5283CD04.3080501@redhat.com> <87y54qvfw1.fsf@fleche.redhat.com> In-Reply-To: <87y54qvfw1.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-01/txt/msg00364.txt.bz2 On 11/14/2013 09:21 PM, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves 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 * 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 + + * Makefile.in (CHECK_HEADERS): New variable. + (check-headers:): New rule. + 2014-01-13 Tom Tromey * 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