Skip to content

Commit 488174d

Browse files
authored
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.
1 parent 90b82f2 commit 488174d

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
clang-cl on Windows needs option ``/EHa`` to support SEH (structured
2+
exception handling) correctly. Fix by Chris Eibl.

PCbuild/pyproject-clangcl.props

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838

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

PCbuild/pyproject.props

+7-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
<LinkIncremental Condition="$(Configuration) != 'Debug'">false</LinkIncremental>
2626
</PropertyGroup>
2727

28-
<!-- We need the above overridden OutDir, so this must be imported after PropertyGroup -->
29-
<Import Project="pyproject-clangcl.props" Condition="$(PlatformToolset) == 'ClangCL' and $(__PyprojectClangCl_Props_Imported) != 'true'" />
30-
3128
<PropertyGroup Condition="$(TargetExt) != ''">
3229
<TargetNameExt>$(TargetName)$(TargetExt)</TargetNameExt>
3330
<_TargetNameSep>$(TargetNameExt.LastIndexOf(`.`))</_TargetNameSep>
@@ -130,6 +127,13 @@
130127
</Midl>
131128
</ItemDefinitionGroup>
132129

130+
<!--
131+
We need the overridden OutDir (PropertyGroup Label="Globals"),
132+
and want to be able to override some ClCompile parameters,
133+
so this must not be included erlier.
134+
-->
135+
<Import Project="pyproject-clangcl.props" Condition="$(PlatformToolset) == 'ClangCL' and $(__PyprojectClangCl_Props_Imported) != 'true'" />
136+
133137
<UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
134138
<ParameterGroup>
135139
<FileName Required="true" />

0 commit comments

Comments
 (0)