]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-131691: Fix exception handling setting for clang-cl on Windows (GH-131730)
authorChris Eibl <138194463+chris-eibl@users.noreply.github.com>
Tue, 25 Mar 2025 23:07:52 +0000 (00:07 +0100)
committerGitHub <noreply@github.com>
Tue, 25 Mar 2025 23:07:52 +0000 (23:07 +0000)
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.

Misc/NEWS.d/next/Build/2025-03-25-19-14-24.gh-issue-131691.2BgHU5.rst [new file with mode: 0644]
PCbuild/pyproject-clangcl.props
PCbuild/pyproject.props

diff --git a/Misc/NEWS.d/next/Build/2025-03-25-19-14-24.gh-issue-131691.2BgHU5.rst b/Misc/NEWS.d/next/Build/2025-03-25-19-14-24.gh-issue-131691.2BgHU5.rst
new file mode 100644 (file)
index 0000000..b956764
--- /dev/null
@@ -0,0 +1,2 @@
+clang-cl on Windows needs option ``/EHa`` to support SEH (structured
+exception handling) correctly. Fix by Chris Eibl.
index d949c37d562594c38e0ad4af16641a17efb43898..a574cf84ee5d6c42c2fd1284a687088b08da4fc3 100644 (file)
 
   <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>
index b5a236ee3e37d51bc7e4fc72e610726d602341b1..4e414dc913b9d5d537f6050611484b572f2df79a 100644 (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>
     </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" />