Closed Bug 1367834 Opened 7 years ago Closed 7 years ago

Reduce volume of compiler warnings printed at end of the build

Categories

(Firefox Build System :: General, enhancement)

enhancement
Not set
normal

Tracking

(firefox55 fixed)

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: gps, Assigned: gps)

References

Details

Attachments

(1 file)

People are complaining about the volume of compiler warnings printed at the end of the build because they aren't actionable. Let's do something about it.
Comment on attachment 8871370 [details]
Bug 1367834 - Suppress compiler warnings for 3rd party projects;

https://reviewboard.mozilla.org/r/142842/#review146596

I'm not a fan of the fixed list here, but I'm not totally sure if there's a good way around it.  Pushing back to try and stimulate other ideas.

The reporting loop thing needs to be fixed in some way.

::: python/mozbuild/mozbuild/mach_commands.py:482
(Diff revision 1)
>              if not status:
> +                # Suppress warnings for 3rd party projects in local builds
> +                # until we suppress them for real.
> +                # TODO remove entries/feature once we stop generating warnings
> +                # in these directories.
> +                LOCAL_SUPPRESS_DIRS = (

Could we not derive this from a BUILDSTATUS line about whether the directory permits compiler warnings or not?  I'd rather not maintain this list here if we can avoid it.  Or is this sort of a least-bad solution, because we still want to give people the option to fix warnings in their newly-imported third-party library or similar?

::: python/mozbuild/mozbuild/mach_commands.py:515
(Diff revision 1)
> +                if 'MOZ_AUTOMATION' not in os.environ:
> +                    for d in LOCAL_SUPPRESS_DIRS:
> +                        count = 0
> +                        for warning in sorted(monitor.instance_warnings):
> +                            if warning['normpath'].startswith(d):
> +                                count += 1
> +
> +                        if count:
> +                            self.log(logging.WARNING, 'suppressed_warning',
> +                                     {'dir': d, 'count': count},
> +                                     '(suppressed {count} warnings in {dir})')
> +

This loop is pretty inefficient in the local case, since you'll be sorting `monitor.instance_warnings` for each entry in `LOCAL_SUPPRESS_DIRS`.

`.startswith` accepts a tuple of prefixes, so you can just:

`if warning['normpath'].startswith(LOCAL_SUPPRESS_DIRS):`

though maybe it doesn't accept lists, so you might have to make `LOCAL_SUPPRESS_DIRS` a tuple right off the bat.

Also, WDYT about structuring things like:

```
// if we have to use a fixed set of dirs...
LOCAL_SUPPRESS_DIRS = (...)

sorted_warnings = list(sorted(monitor.instance_warnings))
...add `normpath` to all warnings...
relevant = [w for w in sorted_warnings
            if not w['normpath'].startswith(LOCAL_SUPPRESS_DIRS)]

in_automation = 'MOZ_AUTOMATION' in os.environ
if not in_automation:
  ...compute how many warnings we suppressed and print a message...

for warning in (relevant if not in_automation else sorted_warnings):
  ...stuff...
```

I think that makes the flow a little more obvious, fewer conditionals and whatnot.
Attachment #8871370 - Flags: review?(nfroyd) → review-
Comment on attachment 8871370 [details]
Bug 1367834 - Suppress compiler warnings for 3rd party projects;

https://reviewboard.mozilla.org/r/142842/#review146596

> Could we not derive this from a BUILDSTATUS line about whether the directory permits compiler warnings or not?  I'd rather not maintain this list here if we can avoid it.  Or is this sort of a least-bad solution, because we still want to give people the option to fix warnings in their newly-imported third-party library or similar?

I'm not a fan of it either. I'm very much going for a quick fix to make people happy. I view this whole thing as temporary, so I'd prefer to not add too much infrastructure around tracking things unless it can be used to improve monitoring in some other way.

> This loop is pretty inefficient in the local case, since you'll be sorting `monitor.instance_warnings` for each entry in `LOCAL_SUPPRESS_DIRS`.
> 
> `.startswith` accepts a tuple of prefixes, so you can just:
> 
> `if warning['normpath'].startswith(LOCAL_SUPPRESS_DIRS):`
> 
> though maybe it doesn't accept lists, so you might have to make `LOCAL_SUPPRESS_DIRS` a tuple right off the bat.
> 
> Also, WDYT about structuring things like:
> 
> ```
> // if we have to use a fixed set of dirs...
> LOCAL_SUPPRESS_DIRS = (...)
> 
> sorted_warnings = list(sorted(monitor.instance_warnings))
> ...add `normpath` to all warnings...
> relevant = [w for w in sorted_warnings
>             if not w['normpath'].startswith(LOCAL_SUPPRESS_DIRS)]
> 
> in_automation = 'MOZ_AUTOMATION' in os.environ
> if not in_automation:
>   ...compute how many warnings we suppressed and print a message...
> 
> for warning in (relevant if not in_automation else sorted_warnings):
>   ...stuff...
> ```
> 
> I think that makes the flow a little more obvious, fewer conditionals and whatnot.

I agree. I'll make this much better in the next version.
Comment on attachment 8871370 [details]
Bug 1367834 - Suppress compiler warnings for 3rd party projects;

https://reviewboard.mozilla.org/r/142842/#review146614

Well, your plan worked, somebody did something about these warnings. :)

::: python/mozbuild/mozbuild/mach_commands.py:523
(Diff revision 2)
> +                for d, count in sorted(suppressed_by_dir.items()):
> +                    self.log(logging.WARNING, 'suppressed_warning',
> +                             {'dir': d, 'count': count},
> +                             '(suppressed {count} warnings in {dir})')

Willing to bet you a beverage that people will still complain about this. :)
Attachment #8871370 - Flags: review?(nfroyd) → review+
Comment on attachment 8871370 [details]
Bug 1367834 - Suppress compiler warnings for 3rd party projects;

https://reviewboard.mozilla.org/r/142842/#review146614

> Willing to bet you a beverage that people will still complain about this. :)

I'm not going to take that bet because you are probably correct. As I said in the commit message, let's take a big step and refine until people are generally happy.

FWIW, with the change to not print warnings after backend error, I don't think people will complain as much. The reason is that the warnings are printed after the last build backend output but before the rest of the summary information printed by mach. There usually isn't anything too valuable in the last lines of the build output. And since we only print warnings that occur during the current build, an incremental build shouldn't print many warnings, so there will be little output to scroll over.

But we'll see...

Thanks for the prompt reviews.
Pushed by gszorc@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/508dbbb885fc
Suppress compiler warnings for 3rd party projects; r=froydnj
https://hg.mozilla.org/mozilla-central/rev/508dbbb885fc
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Depends on: 1373951
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: