Skip to content

Commit

Permalink
[python3] Add patch to fix Windows 11 SDK build failure. (microsoft#2…
Browse files Browse the repository at this point in the history
…0292)

* [python3] Remove spurious dependencies.

* [python3] Add workaround for SDK 10.0.22000.0

* x-add-version
  • Loading branch information
Hoikas authored Sep 29, 2021
1 parent 6d4792b commit f819f66
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From 0a72b7061ed79c5d6d37b41a5b1610e32fb371a4 Mon Sep 17 00:00:00 2001
From: Adam Johnson <[email protected]>
Date: Wed, 22 Sep 2021 21:04:21 -0400
Subject: [PATCH] workaround windows 11 sdk rc compiler error

winnt.h was changed to error if the `SYSTEM_CACHE_ALIGNMENT` cannot be
determined. when the RC compiler is invoked, this seems to fail where
previous SDKs silently set the ARM value.
---
PC/python_ver_rc.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/PC/python_ver_rc.h b/PC/python_ver_rc.h
index 90fc6ba1a1..e313a5138e 100644
--- a/PC/python_ver_rc.h
+++ b/PC/python_ver_rc.h
@@ -1,3 +1,10 @@
+// Temporarily workaround bug in Windows SDK 10.0.22000.0 winnt.h
+#ifdef RC_INVOKED
+# ifndef SYSTEM_CACHE_ALIGNMENT_SIZE
+# define SYSTEM_CACHE_ALIGNMENT_SIZE 64
+# endif
+#endif
+
// Resource script for Python core DLL.
// Currently only holds version information.
//
--
2.33.0.windows.1

14 changes: 9 additions & 5 deletions ports/python3/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ elseif(VCPKG_TARGET_IS_WINDOWS AND CMAKE_SYSTEM_VERSION EQUAL 6.1)
message(FATAL_ERROR "python3 requires the feature deprecated-win7-support when building on Windows 7.")
endif()

# The Windows 11 SDK has a problem that causes it to error on the resource files, so we patch that.
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
vcpkg_get_windows_sdk(WINSDK_VERSION)
if("${WINSDK_VERSION}" VERSION_GREATER_EQUAL "10.0.22000")
list(APPEND PATCHES "0008-workaround-windows-11-sdk-rc-compiler-error.patch")
endif()
endif()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO python/cpython
Expand Down Expand Up @@ -88,11 +96,6 @@ if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
"/p:ForceImportBeforeCppTargets=${SOURCE_PATH}/PCbuild/python_vcpkg.props"
)
endif()
string(REPLACE "\\" "" WindowsSDKVersion "$ENV{WindowsSDKVersion}")
list(APPEND OPTIONS
"/p:WindowsTargetPlatformVersion=${WindowsSDKVersion}"
"/p:DefaultWindowsSDKVersion=${WindowsSDKVersion}"
)
if(VCPKG_TARGET_IS_UWP)
list(APPEND OPTIONS "/p:IncludeUwp=true")
else()
Expand All @@ -117,6 +120,7 @@ if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
PROJECT_SUBPATH "PCbuild/pcbuild.proj"
OPTIONS ${OPTIONS}
LICENSE_SUBPATH "LICENSE"
TARGET_PLATFORM_VERSION "${WINSDK_VERSION}"
SKIP_CLEAN
)

Expand Down
9 changes: 1 addition & 8 deletions ports/python3/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "python3",
"version-semver": "3.9.7",
"port-version": 1,
"description": "The Python programming language",
"homepage": "https://github.com/python/cpython",
"supports": "!(arm | uwp)",
Expand Down Expand Up @@ -34,14 +35,6 @@
"name": "sqlite3",
"platform": "!(windows & static)"
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
],
"features": {
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5330,7 +5330,7 @@
},
"python3": {
"baseline": "3.9.7",
"port-version": 0
"port-version": 1
},
"qca": {
"baseline": "2.3.1",
Expand Down
5 changes: 5 additions & 0 deletions versions/p-/python3.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "6a1011c32aa2eb7de0b9a6184b2805e34c41f0b5",
"version-semver": "3.9.7",
"port-version": 1
},
{
"git-tree": "b3a545b39c982b7f0a12891765dd9909e364ebc6",
"version-semver": "3.9.7",
Expand Down

0 comments on commit f819f66

Please sign in to comment.