Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Dec 6, 2020

This PR makes possible to cross-compile Windows build with --enable-werror --enable-suppress-external-warnings.
Some problems are fixed, others are silenced.

Also --enable-werror is enabled for Cirrus CI Windows build (the last one on Cirrus CI without --enable-werror).

@hebasto
Copy link
Member Author

hebasto commented Dec 6, 2020

cc @fanquake @MarcoFalke @vasild

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 6, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@laanwj
Copy link
Member

laanwj commented Dec 7, 2020

I'm a bit divided on whether building on every platform/compiler combination 'with -Werror' is actually a goal of the project. I mean, I think this is impossible, and will result in a lot of warning fixing for the sake of warning fixing.

In general Werror is a curse.

@maflcko
Copy link
Member

maflcko commented Dec 7, 2020

Tend to agree with @laanwj, especially if the workarounds will make already hard to understand files like fs.cpp even more verbose.

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 06ff475

Sometimes important warnings are emitted only on some platforms, so I think it is good to use -Werror on as most platforms as possible.

If keeping Windows builds warning-free turns out to be too big burden then the NO_WERROR=1 can be added back.

@hebasto
Copy link
Member Author

hebasto commented Dec 7, 2020

I'm a bit divided on whether building on every platform/compiler combination 'with -Werror' is actually a goal of the project. I mean, I think this is impossible, and will result in a lot of warning fixing for the sake of warning fixing.

In general Werror is a curse.

Tend to agree with @laanwj, especially if the workarounds will make already hard to understand files like fs.cpp even more verbose.

Fair enough.

The goal of this PR (combined with #20544) is to prevent changes that introduce new warnings.

Anyway, feel free to close this.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 9, 2020

🕵️ @practicalswift has been requested to review this pull request as specified in the REVIEWERS file.

@practicalswift
Copy link
Contributor

Concept ACK

@hebasto
Copy link
Member Author

hebasto commented Dec 10, 2020

Updated 06ff475 -> 926f6d8 (pr20586.01 -> pr20586.02, diff).

@MarcoFalke

Tend to agree with @laanwj, especially if the workarounds will make already hard to understand files like fs.cpp even more verbose.

Only one-line change in fs.cpp now.

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 926f6d8

src/fs.cpp Outdated

static std::string openmodeToStr(std::ios_base::openmode mode)
{
switch (mode & ~std::ios_base::ate) {
switch (static_cast<int>(mode & ~std::ios_base::ate)) { // casting is required to suppress -Wswitch warnings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NACK, the standard doesn't guarantee this fits in an int...

Can you use a pragma to disable the warning here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@hebasto
Copy link
Member Author

hebasto commented Dec 19, 2020

Reverted back 06ff475 <- 926f6d8 (pr20586.01 <- pr20586.02) as was requested by @luke-jr.

This variant has been already ACKed by @vasild.

@practicalswift
Copy link
Contributor

practicalswift commented Mar 6, 2021

cr ACK 06ff475: patch looks correct

FWIW, having this in master would have prevented the issue #21355 pre-merge :)

@hebasto
Copy link
Member Author

hebasto commented Apr 13, 2021

Updated 06ff475 -> b367745 (pr20586.01 -> pr20586.03):

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b367745

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b367745

Tested on Linux cross-compiling to Windows passing --enable-werror to configure

Master:

script/standard.cpp:215:26: error: control reaches end of non-void function [-Werror=return-type]
  215 |     std::vector<valtype> vSolutions;

PR:
Builds fine and built binaries work fine on Windows 10

@practicalswift
Copy link
Contributor

cr ACK b367745: patch looks correct

@hebasto
Copy link
Member Author

hebasto commented Jun 17, 2021

@laanwj @MarcoFalke @luke-jr

Do you mind having another look at this PR?


#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be needed after the boost::fs removal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no, as this bunch of code should go:

bitcoin/src/fs.h

Lines 66 to 69 in d6e0d78

// Work around this issue by creating stream objects with `_wfopen` in
// combination with `__gnu_cxx::stdio_filebuf`. This workaround can be removed
// with an upgrade to C++17, where streams can be constructed directly from
// `std::filesystem::path` objects.

@laanwj
Copy link
Member

laanwj commented Aug 27, 2021

I'm not a big fan in general of pragmas or fixing warnings for the sake of fixing warnings but this seems minimal enough.
Code review ACK b367745

@laanwj laanwj merged commit 19364c0 into bitcoin:master Aug 27, 2021
@hebasto hebasto deleted the 201206-win branch August 27, 2021 06:46
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 28, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 27, 2022
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.

8 participants