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
fix C++ build for MSVC 2022 #21096
fix C++ build for MSVC 2022 #21096
Conversation
Can the GitHub CI runner be increased to windows-2022 then too? https://github.com/Perl/perl5/blob/blead/.github/workflows/testsuite.yml#L460 I couldn't build Perl with Visual Studio 2022 under Windows 11. Thanks. |
Do you mean 2022? There is no 2021, see https://visualstudio.microsoft.com/vs/older-downloads/ Do you mean as C++ with this branch? The I could only see us increasing the required version for CI if we added a C++ build. |
I tried building with both VS 2019 and 2017, both updated since their original installation. Both successfully did a default build of this branch: 2019 accepted the 2017 warned about
but successfully built this branch. For C++ builds: 2019 successfully built this branch with 2017 failed to build this branch with I'll re-work this to only add the |
This produced errors with MSVC C++ builds like: C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\um\wspiapi.h(53): error C2894: templates cannot be declared to have 'C' linkage
This generated code like: char * filename; if (items < 3) filename = "DynaLoader"; else { filename = (char *)SvPV_nolen(ST(2)) which failed in C++ builds (and isn't valid in C either), when assigning a "const char *" (well, "const char [11]") to "char *".
C++ has a similar feature, but it has a different syntax, both as of C++20 do support designated struct initializers.
…extended_errno which C++ forbids.
C++ builds threw an error on these.
21060 also has this fix
Unfortunately this means older versions of MSVC that don't have C++20 support can no longer build perl as C++.
…finition This caused the link stage to fail with a C++ build, as the type annotated C++ name was used for the definition rather than the extern "C" name.
and note that only 2019 or later can build as C++, since the use of designated initialisers means we need at least C++20 and only 2019 and 2022 support that. "cl /?" for 2019 doesn't list "-std:c++20" as an option at least of 19.29.30148, but it does accept it.
clang-16 rejects this, MSVC warns about it. Part of fixing Perl#21073
clang++ complains about this. The replacement prevents the warning and should be back-compatible.
for the C++ compatibility changes. I also need to bump some cpan/ but we don't own those, so I'll do it separately.
since we don't own it, and mark it as customized
since we don't own it, and mark the customized files.
since we don't own it, and mark the modified files customized
since we don't own it, and mark the modified files as customized
since we don't own it, and mark the modified files as customized
5d5e6ae
to
14b61ef
Compare
Marked this as a release blocker AFAIK this fixes recent build regressions, but it that happened longer ago then arguably it should not block release. |
Fixes #21073 for MSVC
Draft since it shouldn't be applied as is.
Includes Leont's designated array initialization revert.