From patchwork Wed Aug 23 16:47:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Kolpackov X-Patchwork-Id: 805129 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-460824-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Iw8sSijO"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xctdQ08Wfz9s8J for ; Thu, 24 Aug 2017 02:47:37 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=HIi4SX7BybdHPAuT6Lkr3e9NBbTNt6 Mo0+ErWWEHAUxRLMkH9Z2B7lGFBI3F5WhYnoiUaUfBKbypRMFzPzZ9fOOJ21RubX QQbNfOyk85jfa6ta923l42aYbv5ZLhdzgVPgvpZ0pLi7EXc57AqE2klc1J2xY5xk /sAWDYFD9v2+Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=Cd6uoNpdvW1F8xQ6/VL1ZUhI4q0=; b=Iw8s SijOPrLnG7IAFNiKYPd/gaqS0xkbD1+Vp0sPF4nCO0xThaI3GObMHvmyh8ThqdIg JPkD398C8V+nt6nI6jmpMLhqnyZTIQnEII7BnBZDDD7dEaDgxv6m7uGAaBKGGylx UxfjkXxl928X2TXNifz0zP8JmB0T3cqQJgbI+GA= Received: (qmail 4238 invoked by alias); 23 Aug 2017 16:47:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 4219 invoked by uid 89); 23 Aug 2017 16:47:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=paperwork, boris, Boris, our X-HELO: codesynthesis.com Received: from codesynthesis.com (HELO codesynthesis.com) (70.85.31.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Aug 2017 16:47:27 +0000 Received: from brak.codesynthesis.com (82-194-157-138.dyn.salzburg-online.at [82.194.157.138]) (authenticated bits=0) by codesynthesis.com (8.14.4/8.14.4/Debian-4) with ESMTP id v7NGlJEL006821 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Aug 2017 12:47:25 -0400 Received: by brak.codesynthesis.com (Postfix, from userid 1000) id DDFCF1A800E0; Wed, 23 Aug 2017 18:47:13 +0200 (SAST) Date: Wed, 23 Aug 2017 18:47:13 +0200 From: Boris Kolpackov To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH PING] Write dependency information (-M*) even if there are errors Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Ping. On 13 Aug 2017 Boris Kolpackov writes: Hi, I've been instructed to resend this patch from the gcc mailing list: Currently GCC does not write extracted header dependency information if there are errors. However, this can be useful when dealing with outdated generated headers that trigger errors which would have been resolved if we could update it. A concrete example in our case is a version check with #error. The included (trivial) patch changes this behavior. Note also that this is how Clang already behaves. I've tested the patch in build2 and everything works well (i.e., no invalid dependency output in the face of various preprocessor errors such as #error, stray #else, etc). While I don't foresee any backwards-compatibility issues with such an unconditional change (after all, the compiler still exists with an error status), if there are concerns, I could re-do it via an option (e.g., -ME, analogous to -MG). Joseph Myers writes: > I suppose a question for the present proposal would be making sure any > dependencies generated in this case do not include dependencies on files > that don't exist (so #include "some-misspelling.h" doesn't create any sort > of dependency on such a header). Good point. I've tested this and I believe everything is in order: unless -MG is specified, a non-existent header is treated as a fatal error so we don't even get to writing the dependency info. And if -MG is specified, then there is no error and we get the missing header in the dependency output, as requested. P.S. I have the paperwork necessary to contribute on file with FSF. Thanks, Boris Index: gcc/c-family/ChangeLog =================================================================== --- gcc/c-family/ChangeLog (revision 250514) +++ gcc/c-family/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2017-08-06 Boris Kolpackov + + * c-opts.c (c_common_finish): Write dependency information even if + there are errors. + 2017-07-14 David Malcolm * c-common.c (try_to_locate_new_include_insertion_point): New Index: gcc/c-family/c-opts.c =================================================================== --- gcc/c-family/c-opts.c (revision 250514) +++ gcc/c-family/c-opts.c (working copy) @@ -1152,8 +1157,11 @@ { FILE *deps_stream = NULL; - /* Don't write the deps file if there are errors. */ - if (cpp_opts->deps.style != DEPS_NONE && !seen_error ()) + /* Note that we write the dependencies even if there are errors. This is + useful for handling outdated generated headers that now trigger errors + (for example, with #error) which would be resolved by re-generating + them. In a sense, this complements -MG. */ + if (cpp_opts->deps.style != DEPS_NONE) { /* If -M or -MM was seen without -MF, default output to the output stream. */