GH-131691: Fix exception handling setting for clang-cl on Windows (GH-131730)

The /EHa option for Clang-CL behaves differently than the same option for MSVC, which is why we don't use it for both compilers.
This commit is contained in:
Chris Eibl
2025-03-26 00:07:52 +01:00
committed by GitHub
parent 90b82f2b61
commit 488174dc68
3 changed files with 17 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
clang-cl on Windows needs option ``/EHa`` to support SEH (structured
exception handling) correctly. Fix by Chris Eibl.

View File

@@ -38,6 +38,14 @@
<ItemDefinitionGroup>
<ClCompile>
<!--
ExceptionHandling=Async sets MSVC's /EHa (-fasync-exceptions in clang)
For clang, /EHa just has a slightly different meaning compared to MSVC,
so this option is needed to handle SEH correctly
(even though MSVC does not need it).
Please see GH-131691 for details.
-->
<ExceptionHandling>Async</ExceptionHandling>
<AdditionalOptions>-Wno-deprecated-non-prototype -Wno-unused-label -Wno-pointer-sign -Wno-incompatible-pointer-types-discards-qualifiers -Wno-unused-function %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Platform)' == 'Win32'">-m32 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Platform)' == 'x64'">-m64 %(AdditionalOptions)</AdditionalOptions>

View File

@@ -25,9 +25,6 @@
<LinkIncremental Condition="$(Configuration) != 'Debug'">false</LinkIncremental>
</PropertyGroup>
<!-- We need the above overridden OutDir, so this must be imported after PropertyGroup -->
<Import Project="pyproject-clangcl.props" Condition="$(PlatformToolset) == 'ClangCL' and $(__PyprojectClangCl_Props_Imported) != 'true'" />
<PropertyGroup Condition="$(TargetExt) != ''">
<TargetNameExt>$(TargetName)$(TargetExt)</TargetNameExt>
<_TargetNameSep>$(TargetNameExt.LastIndexOf(`.`))</_TargetNameSep>
@@ -130,6 +127,13 @@
</Midl>
</ItemDefinitionGroup>
<!--
We need the overridden OutDir (PropertyGroup Label="Globals"),
and want to be able to override some ClCompile parameters,
so this must not be included erlier.
-->
<Import Project="pyproject-clangcl.props" Condition="$(PlatformToolset) == 'ClangCL' and $(__PyprojectClangCl_Props_Imported) != 'true'" />
<UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<FileName Required="true" />