Skip to content

ci: windows 2017 C++17 testing #2428

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

Closed
wants to merge 2 commits into from
Closed

Conversation

henryiii
Copy link
Collaborator

Pulling out the non-annotations changes from #2427

@henryiii henryiii changed the title ci: windows ci: windows 2017 C++17 testing Aug 23, 2020
@henryiii henryiii force-pushed the ci/win branch 2 times, most recently from 25f06ff to 4d2327a Compare August 23, 2020 15:35
@@ -30,15 +30,11 @@ jobs:
arch: x64
max-cxx-std: 17
args: "-DPYBIND11_FINDPYTHON=ON"
- runs-on: macos-latest
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was just to have a macOS FindPython run, but 3.9dev can also do FindPython without making another macOS run.

- runs-on: windows-2016
python: 3.7
arch: x86
max-cxx-std: 14
max-cxx-std: 17
args: "-DCMAKE_CXX_FLAGS='//permissive- //DWIN32 //D_WINDOWS //W3 //GR //EHsc'"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't seem to be able to inject a single flag (or flags properly) to MSVC's build...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Must be something with GHA, though. I just tried, and I can perfectly run cmake .. -DPYTHON_EXECUTABLE=C:\Python38\python.exe -DCMAKE_CXX_FLAGS=/permissive- :-/

Something with thing being escaped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is definitely messing with escaping.

@henryiii henryiii force-pushed the ci/win branch 3 times, most recently from f1c1ff4 to e5b886c Compare August 24, 2020 03:05
@henryiii
Copy link
Collaborator Author

@YannickJadoul Any idea why I'm getting C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\include\xlocale(319): error C2220: warning treated as error - no 'object' file generated ?

@YannickJadoul
Copy link
Collaborator

@YannickJadoul Any idea why I'm getting C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\include\xlocale(319): error C2220: warning treated as error - no 'object' file generated ?

No idea; didn't think we were elevating warnings to errors?
The actual error seems to be the line before, though: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc

But I'm a bit confused on whether and why VS 2017 would have different defaults to VS 2019.

@bstaletic
Copy link
Collaborator

So, by default, exception handling is utterly borked on MSVC.

Default exception handling behavior

The compiler always generates code that supports asynchronous structured exception handling (SEH). By default (that is, if no /EHsc, /EHs, or /EHa option is specified), the compiler supports SEH handlers in the native C++ catch(...) clause. However, it also generates code that only partially supports C++ exceptions. The default exception unwinding code doesn't destroy automatic C++ objects outside of try blocks that go out of scope because of an exception. Resource leaks and undefined behavior may result when a C++ exception is thrown.

https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=vs-2019

/EHsc means "please follow the standard".

@YannickJadoul
Copy link
Collaborator

So, by default, exception handling is utterly borked on MSVC.

...

/EHsc means "please follow the standard".

Fair enough. But why do the VS 2019 not have this problem?

Oh, maybe it's related to us asking VS 2017 "please follow the standard" with /permissive-?

@bstaletic
Copy link
Collaborator

I guess that's a possible explanation.

@bstaletic
Copy link
Collaborator

By the way, why don't we merge #2431 into this PR?

@YannickJadoul
Copy link
Collaborator

By the way, why don't we merge #2431 into this PR?

Happy with that. That's why I requested a review from @henryiii there :-) If this is necessary, maybe we should also add /EHsc to the flags?

@henryiii
Copy link
Collaborator Author

Let's see what we need to add, then we can combine the branches

@YannickJadoul
Copy link
Collaborator

OK! Feel free to steal or redirect my PR in whichever way works best for you :-)

@henryiii
Copy link
Collaborator Author

Found it, setting the flags manually here overrides the default:
https://gitlab.kitware.com/cmake/cmake/blob/v3.18.2/Modules/Platform/Windows-MSVC.cmake#L229

So it loses /EHsc if you add any flags.

@henryiii
Copy link
Collaborator Author

This would help the situation if added in the future: https://gitlab.kitware.com/cmake/cmake/-/issues/20610

@henryiii
Copy link
Collaborator Author

I've added the commit to #2431 and will go from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants