public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Write dependency information (-M*) even if there are errors
@ 2017-08-13 17:36 Boris Kolpackov
  2017-08-23 17:33 ` [PATCH PING] " Boris Kolpackov
  2017-09-01 16:46 ` [PATCH] " Jeff Law
  0 siblings, 2 replies; 3+ messages in thread
From: Boris Kolpackov @ 2017-08-13 17:36 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1598 bytes --]

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 <joseph@codesourcery.com> 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

[-- Attachment #2: deps-on-error.diff --]
[-- Type: text/x-diff, Size: 1236 bytes --]

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 <boris@codesynthesis.com>
+
+	* c-opts.c (c_common_finish): Write dependency information even if
+	there are errors.
+
 2017-07-14  David Malcolm  <dmalcolm@redhat.com>
 
 	* 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.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH PING] Write dependency information (-M*) even if there are errors
  2017-08-13 17:36 [PATCH] Write dependency information (-M*) even if there are errors Boris Kolpackov
@ 2017-08-23 17:33 ` Boris Kolpackov
  2017-09-01 16:46 ` [PATCH] " Jeff Law
  1 sibling, 0 replies; 3+ messages in thread
From: Boris Kolpackov @ 2017-08-23 17:33 UTC (permalink / raw)
  To: gcc-patches

Ping.

On 13 Aug 2017 Boris Kolpackov <boris@codesynthesis.com> 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 <joseph@codesourcery.com> 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 <boris@codesynthesis.com>
+
+	* c-opts.c (c_common_finish): Write dependency information even if
+	there are errors.
+
 2017-07-14  David Malcolm  <dmalcolm@redhat.com>
 
 	* 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.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Write dependency information (-M*) even if there are errors
  2017-08-13 17:36 [PATCH] Write dependency information (-M*) even if there are errors Boris Kolpackov
  2017-08-23 17:33 ` [PATCH PING] " Boris Kolpackov
@ 2017-09-01 16:46 ` Jeff Law
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2017-09-01 16:46 UTC (permalink / raw)
  To: Boris Kolpackov, gcc-patches

On 08/13/2017 09:25 AM, Boris Kolpackov wrote:
> 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 <joseph@codesourcery.com> 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
> 
> 
> deps-on-error.diff
> 
> 
> 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 <boris@codesynthesis.com>
> +
> +	* c-opts.c (c_common_finish): Write dependency information even if
> +	there are errors.
Thanks.  I've installed this on the trunk.  Sorry for the delays.

jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-01 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-13 17:36 [PATCH] Write dependency information (-M*) even if there are errors Boris Kolpackov
2017-08-23 17:33 ` [PATCH PING] " Boris Kolpackov
2017-09-01 16:46 ` [PATCH] " Jeff Law

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).