Uh oh!
There was an error while loading. Please reload this page.
build: turn warnings into errors for node sources - #32685
Conversation
nodejs-github-bot
commented
Apr 6, 2020
mscdex
commented
Apr 6, 2020
Will this cause issues for GCC < 8 and warnings from v8.h? |
addaleax
commented
Apr 6, 2020
Can we enable it only for CI then, in some way? I’m worried that we won’t know which environments consumers of our source code compile in and that we won’t know what warnings they receive, particularly warnings from future compiler versions that we aren’t yet aware of. |
danbev
commented
Apr 7, 2020
I'm not sure about |
danbev
commented
Apr 7, 2020
That is a good point. I'm not convinced this is actually worth the effort but I was asked to take a look at doing this and this is what I came up with. I don't see warnings as a big issue and they get fixed pretty quickly as it is. |
sam-github
commented
Apr 7, 2020
I think it could fix a lot of churn if code with warnings (in src under our control!) failed CI, since we CI with known compiler levels, it should be stable-ish. I guess it won't stop all warnings... I'm using clang 11 locally, and its pretty strict. For local builds, many projects have a |
This commit attempts to turn compilation warnings into errors for node's source code. The motivation for this is to enable these errors to be reported by CI runs on pull requests and be able to fix them before they land.
Currently, the following warning is generated from the inspector protocol: /out/Release/obj/gen/src/node/inspector/protocol/Protocol.cpp: In member function ‘virtual std::unique_ptr<node::inspector::protocol::Value> node::inspector::protocol::ListValue::clone() const’: /out/Release/obj/gen/src/node/inspector/protocol/Protocol.cpp:739:21: error: redundant move in return statement [-Werror=redundant-move] 739 | return std::move(result); | ~~~~~~~~~^~~~~~~~ This commit removes the move for DictionaryValue and ListValue.
This commit adds a configuration time flag named error-on-warn: $ ./configure --help | grep -A1 error-on-warn --error-on-warn Turn compiler warnings into errors for node core sources. The motivation for this is that CI jobs can use this flag to turn warnings into errors.
I've added a commit with a suggestion for this. ./configure --help | grep -A1 error-on-warn --error-on-warn Turn compiler warnings into errors for node core sources.This can be tested by adding an unused variable to some code in node core: $ ./configure
$ make -j8../src/node.cc: In member function ‘int node::Environment::InitializeInspector(std::unique_ptr<node::inspector::ParentInspectorHandle>)’:../src/node.cc:208:7: warning: unused variable ‘x’ [-Wunused-variable] 208 | int x = 10; | And using the new configuration option: $ ./configure --error-on-warn
$ make -j8../src/node.cc: In member function ‘int node::Environment::InitializeInspector(std::unique_ptr<node::inspector::ParentInspectorHandle>)’:../src/node.cc:208:7: error: unused variable ‘x’ [-Werror=unused-variable] 208 | int x = 10; | ^cc1plus: all warnings being treated as errorsWould something like this work if we add it to the CI jobs? |
Uh oh!
There was an error while loading. Please reload this page.
richardlau
commented
Apr 17, 2020
Sounds reasonable to me. |
nodejs-github-bot
commented
Apr 24, 2020
richardlau
commented
Apr 24, 2020
LGTM. For enabling on the CI by default we will need to edit the individual jobs. My plan would be:
|
danbev
commented
Apr 24, 2020
I'd like to land this but this is the first time I've seen a failure for the build-tarball job. Has anyone else see this before? (I'm able to run |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| parser.add_option('--error-on-warn', | ||
| action='store_true', | ||
| dest='error_on_warn', | ||
| help='Turn compiler warnings into errors for node core sources.') |
There was a problem hiding this comment.
Would be great to have this in the Windows vcbuild.bat also.
There was a problem hiding this comment.
Yeah, I agree. The problem for me is that I don't have a windows testing environment anymore. At least if this got merged we could enable this for pull requests.
mmarchini
left a comment
There was a problem hiding this comment.
Can be done on a follow up, but I think it makes sense to set this flag on Actions :)
This commit adds a configuration time flag named error-on-warn: $ ./configure --help | grep -A1 error-on-warn --error-on-warn Turn compiler warnings into errors for node core sources. The motivation for this is that CI jobs can use this flag to turn warnings into errors. PR-URL: #32685 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Currently, the following warning is generated from the inspector protocol: /out/Release/obj/gen/src/node/inspector/protocol/Protocol.cpp: In member function ‘virtual std::unique_ptr<node::inspector::protocol::Value> node::inspector::protocol::ListValue::clone() const’: /out/Release/obj/gen/src/node/inspector/protocol/Protocol.cpp:739:21: error: redundant move in return statement [-Werror=redundant-move] 739 | return std::move(result); | ~~~~~~~~~^~~~~~~~ This commit removes the move for DictionaryValue and ListValue. PR-URL: #32685 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
danbev
commented
Apr 30, 2020
This commit adds a configuration time flag named error-on-warn: $ ./configure --help | grep -A1 error-on-warn --error-on-warn Turn compiler warnings into errors for node core sources. The motivation for this is that CI jobs can use this flag to turn warnings into errors. PR-URL: #32685 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Currently, the following warning is generated from the inspector protocol: /out/Release/obj/gen/src/node/inspector/protocol/Protocol.cpp: In member function ‘virtual std::unique_ptr<node::inspector::protocol::Value> node::inspector::protocol::ListValue::clone() const’: /out/Release/obj/gen/src/node/inspector/protocol/Protocol.cpp:739:21: error: redundant move in return statement [-Werror=redundant-move] 739 | return std::move(result); | ~~~~~~~~~^~~~~~~~ This commit removes the move for DictionaryValue and ListValue. PR-URL: #32685 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
This commit adds a configuration time flag named error-on-warn: $ ./configure --help | grep -A1 error-on-warn --error-on-warn Turn compiler warnings into errors for node core sources. The motivation for this is that CI jobs can use this flag to turn warnings into errors. PR-URL: #32685 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Currently, the following warning is generated from the inspector protocol: /out/Release/obj/gen/src/node/inspector/protocol/Protocol.cpp: In member function ‘virtual std::unique_ptr<node::inspector::protocol::Value> node::inspector::protocol::ListValue::clone() const’: /out/Release/obj/gen/src/node/inspector/protocol/Protocol.cpp:739:21: error: redundant move in return statement [-Werror=redundant-move] 739 | return std::move(result); | ~~~~~~~~~^~~~~~~~ This commit removes the move for DictionaryValue and ListValue. PR-URL: #32685 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
This commit adds a configuration time flag named error-on-warn: $ ./configure --help | grep -A1 error-on-warn --error-on-warn Turn compiler warnings into errors for node core sources. The motivation for this is that CI jobs can use this flag to turn warnings into errors. PR-URL: #32685 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
richardlau
commented
May 11, 2020
I've cherry-picked a7ae7aa over to |
XCode builds on macOS do not appear to inherit the `cflags` setting. Signed-off-by: Richard Lau <riclau@uk.ibm.com> PR-URL: nodejs#33357 Refs: nodejs#32685 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Treat warnings as errors for non-deps code on Linux and macOS workflows. Signed-off-by: Richard Lau <riclau@uk.ibm.com> PR-URL: nodejs#33357 Refs: nodejs#32685 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
XCode builds on macOS do not appear to inherit the `cflags` setting. Signed-off-by: Richard Lau <riclau@uk.ibm.com> PR-URL: #33357 Refs: #32685 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Treat warnings as errors for non-deps code on Linux and macOS workflows. Signed-off-by: Richard Lau <riclau@uk.ibm.com> PR-URL: #33357 Refs: #32685 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Treat warnings as errors for non-deps code on Linux and macOS workflows. Signed-off-by: Richard Lau <riclau@uk.ibm.com> PR-URL: #33357 Refs: #32685 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
This pr attempts to turn compilation warnings into errors for node's source code.
The motivation for this is to enable these errors to be reported by CI runs on pull requests and be able to fix them before they land.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes