RFC: disabling -Werror

538 views
Skip to first unread message

Paweł Hajdan, Jr.

unread,
Nov 4, 2015, 9:37:02 AM11/4/15
to gn-dev
I'd like to use an option to disable -Werror when using GN build.

There is a switch for that in GYP (-Dwerror=) but I couldn't find an equivalent in GN.

I found -Werror in src/build/config/compiler/BUILD.gn

Would you be OK with an arg for that? What would be the best name for it to fit best with GN conventions? As a starting point, I'd suggest "enable_werror = true".

WDYT?

Paweł

Sylvain Defresne

unread,
Nov 4, 2015, 9:41:37 AM11/4/15
to Paweł Hajdan, Jr., gn-dev
Why do you need to build without -Werror? Wouldn't it be better to fix the warnings causing the error or selectively disabling them instead of completely removing -Werror.

If we decide to provide an option to allow this (and I'm not sure we'd like to do), I think we should name it after its purpose (treating warning as error) instead of how it is implemented by the compiler (-Werror). I would suggest something like "treat_warning_as_errors = true".
-- Sylvain

Dirk Pranke

unread,
Nov 4, 2015, 1:11:27 PM11/4/15
to Sylvain Defresne, Paweł Hajdan, Jr., gn-dev
To build on what Sylvain says, it would be helpful to know why you want to disable the flag. We shouldn't add new args unless we know that they are regularly needed and used.

-- Dirk

Ben Boeckel

unread,
Nov 4, 2015, 1:12:36 PM11/4/15
to Sylvain Defresne, Paweł Hajdan, Jr., gn-dev
On Wed, Nov 04, 2015 at 14:41:27 +0000, Sylvain Defresne wrote:
> Why do you need to build without -Werror? Wouldn't it be better to fix the
> warnings causing the error or selectively disabling them instead of
> completely removing -Werror.

In general, for developers, -Werror is fine, but for folks with other
compilers, some warnings may be noise (think new warnings added to GCC
which have a high false-positive rate or using icc/pgi).

For example, Fedora usually bumps its compiler earlier than many
upstreams, so it is left with the wreckage of a package using -Werror
with the new warnings in the updated compiler.

Not sure how much this applies to Chromium, but that'd be a reason for
having an option at least (though the default would still be arguable).

--Ben

Dirk Pranke

unread,
Nov 4, 2015, 1:18:39 PM11/4/15
to Ben Boeckel, Sylvain Defresne, Paweł Hajdan, Jr., gn-dev
I was assuming Paweł was asking about Chromium in particular, and if
there were downstream packagers that needed this that would be a good
reason.

GN doesn't really have a "default" set of rules at this point, so discussing
whether or not a default set would support such a flag is kinda moot.

-- Dirk

Tomasz Śniatowski

unread,
Nov 4, 2015, 1:26:14 PM11/4/15
to Dirk Pranke, Sylvain Defresne, Paweł Hajdan, Jr., gn-dev
As an external perspective: On some non-standard setups mandatory -Werror is an annoying hurdle that forces doing things in a specific order, or editing build files. For example with a new compiler it's much more interesting to know if the build manages to link properly than it is to spend time on fixing / disabling fancy new warnings first. I think -Werror should absolutely be on by default, but a way to disable it without a patched build file would be very welcome (and ditto for linker-level Werror equivalent).

--
Tomasz

To unsubscribe from this group and stop receiving emails from it, send an email to gn-dev+un...@chromium.org.

Dirk Pranke

unread,
Nov 4, 2015, 2:44:49 PM11/4/15
to Ben Boeckel, Sylvain Defresne, Paweł Hajdan, Jr., gn-dev
On Wed, Nov 4, 2015 at 10:18 AM, Dirk Pranke <dpr...@chromium.org> wrote:


On Wed, Nov 4, 2015 at 10:12 AM, Ben Boeckel <ben.b...@kitware.com> wrote:
On Wed, Nov 04, 2015 at 14:41:27 +0000, Sylvain Defresne wrote:
> Why do you need to build without -Werror? Wouldn't it be better to fix the
> warnings causing the error or selectively disabling them instead of
> completely removing -Werror.

In general, for developers, -Werror is fine, but for folks with other
compilers, some warnings may be noise (think new warnings added to GCC
which have a high false-positive rate or using icc/pgi).

For example, Fedora usually bumps its compiler earlier than many
upstreams, so it is left with the wreckage of a package using -Werror
with the new warnings in the updated compiler.

Not sure how much this applies to Chromium, but that'd be a reason for
having an option at least (though the default would still be arguable).

I was assuming Paweł was asking about Chromium in particular, and if
there were downstream packagers that needed this that would be a good
reason.

Actually, re-reading this now, I was mis-parsing what Paweł wrote. Given
that there is a GYP flag, I would be more inclined to add a GN flag for parity,
but I'd still like to know in what cases we actually need to use it (or who is
actually using it), rather than the theoretical "some people might want to set
this" reason, which I fully understand.

-- Dirk

Nico Weber

unread,
Nov 4, 2015, 3:39:23 PM11/4/15
to Dirk Pranke, Ben Boeckel, Sylvain Defresne, Paweł Hajdan, Jr., gn-dev
On Wed, Nov 4, 2015 at 11:44 AM, Dirk Pranke <dpr...@chromium.org> wrote:


On Wed, Nov 4, 2015 at 10:18 AM, Dirk Pranke <dpr...@chromium.org> wrote:


On Wed, Nov 4, 2015 at 10:12 AM, Ben Boeckel <ben.b...@kitware.com> wrote:
On Wed, Nov 04, 2015 at 14:41:27 +0000, Sylvain Defresne wrote:
> Why do you need to build without -Werror? Wouldn't it be better to fix the
> warnings causing the error or selectively disabling them instead of
> completely removing -Werror.

In general, for developers, -Werror is fine, but for folks with other
compilers, some warnings may be noise (think new warnings added to GCC
which have a high false-positive rate or using icc/pgi).

For example, Fedora usually bumps its compiler earlier than many
upstreams, so it is left with the wreckage of a package using -Werror
with the new warnings in the updated compiler.

Not sure how much this applies to Chromium, but that'd be a reason for
having an option at least (though the default would still be arguable).

I was assuming Paweł was asking about Chromium in particular, and if
there were downstream packagers that needed this that would be a good
reason.

Actually, re-reading this now, I was mis-parsing what Paweł wrote. Given
that there is a GYP flag, I would be more inclined to add a GN flag for parity,
but I'd still like to know in what cases we actually need to use it (or who is
actually using it), rather than the theoretical "some people might want to set
this" reason, which I fully understand.

I think this is needed in cases where we don't control the compiler or system headers, i.e. arbitrary versions of gcc on linux (the CrOS bots do build with gcc, but only with a single version, and different versions have different warnings) and system headers on linux (e.g. fread() might have a "you must not ignore the return value of this function" annotation or it might not). On Windows, Mac, and Android we know exactly which compiler's getting used and we support only one (or a small set of) system headers. So this is mostly needed on Linux, from what I understand.

Paweł Hajdan, Jr.

unread,
Nov 6, 2015, 5:18:51 AM11/6/15
to Nico Weber, Dirk Pranke, Ben Boeckel, Sylvain Defresne, gn-dev
Reply all
Reply to author
Forward
0 new messages