-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Fix Windows build with --enable-werror #20586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
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. |
There was a problem hiding this 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.
Fair enough. The goal of this PR (combined with #20544) is to prevent changes that introduce new warnings. Anyway, feel free to close this. |
🕵️ @practicalswift has been requested to review this pull request as specified in the REVIEWERS file. |
Concept ACK |
Updated 06ff475 -> 926f6d8 (pr20586.01 -> pr20586.02, diff).
Only one-line change in |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Reverted back 06ff475 <- 926f6d8 (pr20586.01 <- pr20586.02) as was requested by @luke-jr. |
Updated 06ff475 -> b367745 (pr20586.01 -> pr20586.03):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK b367745
There was a problem hiding this 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
cr ACK b367745: patch looks correct |
Do you mind having another look at this PR? |
|
||
#if defined(__GNUC__) && !defined(__clang__) | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wswitch" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
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. |
I'm not a big fan in general of pragmas or fixing warnings for the sake of fixing warnings but this seems minimal enough. |
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
).