diff options
author | Steve Dower <steve.dower@python.org> | 2024-02-26 19:14:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 19:14:14 (GMT) |
commit | 37a13b941394a1337576c67bff35d4a44a1157e2 (patch) | |
tree | 226b0d2647c251a3ccb12fe2e3b25de476929dc5 | |
parent | 72cff8d8e5a476d3406efb0491452bf9d6b02feb (diff) | |
download | cpython-37a13b941394a1337576c67bff35d4a44a1157e2.zip cpython-37a13b941394a1337576c67bff35d4a44a1157e2.tar.gz cpython-37a13b941394a1337576c67bff35d4a44a1157e2.tar.bz2 |
gh-115582: Make default PC/pyconfig.h work for free-threaded builds with manual /DPy_GIL_DISABLED (GH-115850)
-rw-r--r-- | Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst | 3 | ||||
-rw-r--r-- | PC/pyconfig.h.in | 7 | ||||
-rw-r--r-- | PCbuild/pythoncore.vcxproj | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst b/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst new file mode 100644 index 0000000..f2e82bf --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst @@ -0,0 +1,3 @@ +Building extensions intended for free-threaded builds of CPython now require +compiling with ``/DPy_GIL_DISABLED`` manually when using a regular install. This +is expected to change in future releases. diff --git a/PC/pyconfig.h.in b/PC/pyconfig.h.in index 8bbf877..d72d628 100644 --- a/PC/pyconfig.h.in +++ b/PC/pyconfig.h.in @@ -95,7 +95,12 @@ WIN32 is still required for the locale module. #endif /* Py_BUILD_CORE || Py_BUILD_CORE_BUILTIN || Py_BUILD_CORE_MODULE */ /* Define to 1 if you want to disable the GIL */ -#undef Py_GIL_DISABLED +/* Uncomment the definition for free-threaded builds, or define it manually + * when compiling extension modules. Note that we test with #ifdef, so + * defining as 0 will still disable the GIL. */ +#ifndef Py_GIL_DISABLED +/* #define Py_GIL_DISABLED 1 */ +#endif /* Compiler specific defines */ diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index c7b698f..ef21f85 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -677,7 +677,7 @@ <OldPyConfigH Condition="Exists('$(IntDir)pyconfig.h')">$([System.IO.File]::ReadAllText('$(IntDir)pyconfig.h'))</OldPyConfigH> </PropertyGroup> <PropertyGroup Condition="$(DisableGil) == 'true'"> - <PyConfigHText>$(PyConfigHText.Replace('#undef Py_GIL_DISABLED', '#define Py_GIL_DISABLED 1'))</PyConfigHText> + <PyConfigHText>$(PyConfigHText.Replace('/* #define Py_GIL_DISABLED 1 */', '#define Py_GIL_DISABLED 1'))</PyConfigHText> </PropertyGroup> <Message Text="Updating pyconfig.h" Condition="$(PyConfigHText.TrimEnd()) != $(OldPyConfigH.TrimEnd())" /> <WriteLinesToFile File="$(IntDir)pyconfig.h" |