Skip to content

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Nov 15, 2019

The two macOS Travis machines run with --enable-werror. This PR adds -Werror=unused-variable to the existing vla, switch and thread-safety-analysis checks. This should prevent the need for fixes like b07b07c, 26a93bc, dd777f3, 99be644, fa39f67, 16bcc1b, bb079a0, bdaed47 and ecf9b25 with minimal nuisance.

Thoughts for followups:

  • Travis starts these macOS machines fairly late, so we should consider setting --enable-werror on earlier machines as well.
  • We should encourage the use of --enable-werror by developers. Maybe switch it on by default for --enable-debug?
  • See practicalswift's overview of other checks to consider in RFC: Enabling some commonly enabled compiler diagnostics #17344

@laanwj
Copy link
Member

laanwj commented Nov 15, 2019

Concept ACK. If we can trust the compiler to be consistent on this.

OTOH this warning was already enabled, and you're only promoting it to -Werror in the CI. I do agree that's the only good use of Werror. It should never be enabled by default by configure scripts. So it should be ok.

@practicalswift
Copy link
Contributor

ACK ce47c11

@maflcko
Copy link
Member

maflcko commented Nov 15, 2019

Are you sure this enabled by default? I couldn't find it here: https://clang.llvm.org/docs/DiagnosticsReference.html#wmost

What would be the downside of explicitly enabling it?

@maflcko
Copy link
Member

maflcko commented Nov 15, 2019

Also, would be nice to call git revert on one of the commits and then give us a link to the travis run

@Sjors
Copy link
Member Author

Sjors commented Nov 15, 2019

Here's a Travis build that should fail: https://travis-ci.org/Sjors/bitcoin/builds/612381391

@MarcoFalke wrote:

Are you sure this enabled by default?

Not sure I understand your question. I tested on my own machine with ./configure --enable-werror and it caught it. We set this for Travis here:

export BITCOIN_CONFIG="--enable-gui --enable-reduce-exports --enable-werror"

@maflcko
Copy link
Member

maflcko commented Nov 15, 2019

Oh, I am wondering if -Wunused-variable is enabled by default in clang. Couldn't find it mentioned in the docs.

@practicalswift
Copy link
Contributor

@MarcoFalke I think it is enabled by -Wall in GCC, but not in Clang. I incorrectly claimed it being enabled by -Wall also in Clang in #17344. Sorry about that: I've now corrected that comment :)

@Sjors
Copy link
Member Author

Sjors commented Nov 15, 2019

I normally do get unused variable warnings on macOS.

@maflcko
Copy link
Member

maflcko commented Nov 15, 2019

So to ask my previous question again: What would be the downside of explicitly enabling it instead of relying on clangs undocumented default, which even differs for different oses.

@Sjors
Copy link
Member Author

Sjors commented Nov 15, 2019

Enabling -Wunused-variable by default sounds good to me, but also orthogonal to this PR, which is about making sure Travis catches it as an error.

@laanwj
Copy link
Member

laanwj commented Nov 15, 2019

I don't think it's entirely orthogonal. If you make a warning an error in the CI, I think it's reasonable to enable it by default (in non-WError mode) for normal builds. Otherwise people will realize it only when the CI fails and with the large turn-around cycle that's suboptimal.

@ryanofsky
Copy link
Contributor

If you make a warning an error in the CI, I think it's reasonable to enable it by default (in non-WError mode)

Yes, please. The worst travis problems to deal with are the ones that happen remotely but not locally.

Turn corresponding warning on by default (not always covered by -Wall).
@Sjors Sjors force-pushed the 2019/11/Werror-unused-variable branch from ce47c11 to 18b18f8 Compare November 15, 2019 16:37
@Sjors
Copy link
Member Author

Sjors commented Nov 15, 2019

Good point. Added.

New Travis build that should fail: https://travis-ci.org/Sjors/bitcoin/builds/612471016

@maflcko
Copy link
Member

maflcko commented Nov 15, 2019

ACK 18b18f8

@practicalswift
Copy link
Contributor

ACK 18b18f8 -- nice!

maflcko pushed a commit that referenced this pull request Nov 15, 2019
18b18f8 [build] ./configure --enable-werror: add unused-variable (Sjors Provoost)

Pull request description:

  The two macOS Travis machines run with `--enable-werror`. This PR adds `-Werror=unused-variable` to the existing `vla`, `switch` and `thread-safety-analysis` checks. This should prevent the need for fixes like b07b07c, 26a93bc, dd777f3, 99be644, fa39f67, 16bcc1b, bb079a0, bdaed47 and ecf9b25 with minimal nuisance.

  Thoughts for followups:
  * Travis starts these macOS machines fairly late, so we should consider setting `--enable-werror` on earlier machines as well.
  * We should encourage the use of `--enable-werror` by developers. Maybe switch it on by default for `--enable-debug`?
  * See practicalswift's overview of other checks to consider in #17344

ACKs for top commit:
  MarcoFalke:
    ACK 18b18f8
  practicalswift:
    ACK 18b18f8 -- nice!

Tree-SHA512: 892b471ca5ea547f3c952ac88190cbebf8110cb7aec6f20466aeb312aeb0910bfe990f914e153c40ecb55709c03775ef30770412ad76f9d532ca77055596c582
@maflcko maflcko merged commit 18b18f8 into bitcoin:master Nov 15, 2019
@Sjors
Copy link
Member Author

Sjors commented Nov 15, 2019

Travis catches the issue as expected (had to restart a few times for timeouts): https://travis-ci.org/Sjors/bitcoin/jobs/612471028#L2333

@Sjors Sjors deleted the 2019/11/Werror-unused-variable branch November 15, 2019 20:46
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 15, 2019
18b18f8 [build] ./configure --enable-werror: add unused-variable (Sjors Provoost)

Pull request description:

  The two macOS Travis machines run with `--enable-werror`. This PR adds `-Werror=unused-variable` to the existing `vla`, `switch` and `thread-safety-analysis` checks. This should prevent the need for fixes like b07b07c, 26a93bc, dd777f3, 99be644, fa39f67, 16bcc1b, bb079a0, bdaed47 and ecf9b25 with minimal nuisance.

  Thoughts for followups:
  * Travis starts these macOS machines fairly late, so we should consider setting `--enable-werror` on earlier machines as well.
  * We should encourage the use of `--enable-werror` by developers. Maybe switch it on by default for `--enable-debug`?
  * See practicalswift's overview of other checks to consider in bitcoin#17344

ACKs for top commit:
  MarcoFalke:
    ACK 18b18f8
  practicalswift:
    ACK 18b18f8 -- nice!

Tree-SHA512: 892b471ca5ea547f3c952ac88190cbebf8110cb7aec6f20466aeb312aeb0910bfe990f914e153c40ecb55709c03775ef30770412ad76f9d532ca77055596c582
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 16, 2019
@Sjors
Copy link
Member Author

Sjors commented Nov 20, 2019

This turned out to be premature, reverting the error part in #17533

@laanwj
Copy link
Member

laanwj commented Nov 20, 2019

yup, a textbook example of why to be careful with making things Werror
(didn't see this particular one coming either !)

sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
18b18f8 [build] ./configure --enable-werror: add unused-variable (Sjors Provoost)

Pull request description:

  The two macOS Travis machines run with `--enable-werror`. This PR adds `-Werror=unused-variable` to the existing `vla`, `switch` and `thread-safety-analysis` checks. This should prevent the need for fixes like b07b07c, 26a93bc, dd777f3, 99be644, fa39f67, 16bcc1b, bb079a0, bdaed47 and ecf9b25 with minimal nuisance.

  Thoughts for followups:
  * Travis starts these macOS machines fairly late, so we should consider setting `--enable-werror` on earlier machines as well.
  * We should encourage the use of `--enable-werror` by developers. Maybe switch it on by default for `--enable-debug`?
  * See practicalswift's overview of other checks to consider in bitcoin#17344

ACKs for top commit:
  MarcoFalke:
    ACK 18b18f8
  practicalswift:
    ACK 18b18f8 -- nice!

Tree-SHA512: 892b471ca5ea547f3c952ac88190cbebf8110cb7aec6f20466aeb312aeb0910bfe990f914e153c40ecb55709c03775ef30770412ad76f9d532ca77055596c582
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
kwvg added a commit to kwvg/dash that referenced this pull request Jun 17, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jun 17, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jun 17, 2021
UdjinM6 added a commit to dashpay/dash that referenced this pull request Jun 23, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants