summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-10-22 13:36:28 (GMT)
committerGitHub <noreply@github.com>2021-10-22 13:36:28 (GMT)
commit03e9f5dc751b8c441a85f428abc3f432ffe46345 (patch)
tree3ea47646a3402f2ad8bdda2366bd9a214899ff44 /Modules
parent86dfb55d2e091cf633dbd7aabcd49d96fb1f9d81 (diff)
downloadcpython-03e9f5dc751b8c441a85f428abc3f432ffe46345.zip
cpython-03e9f5dc751b8c441a85f428abc3f432ffe46345.tar.gz
cpython-03e9f5dc751b8c441a85f428abc3f432ffe46345.tar.bz2
bpo-43974: Move Py_BUILD_CORE_MODULE into module code (GH-29157)
setup.py no longer defines Py_BUILD_CORE_MODULE. Instead every module defines the macro before #include "Python.h" unless Py_BUILD_CORE_BUILTIN is already defined. Py_BUILD_CORE_BUILTIN is defined for every module that is built by Modules/Setup. The PR also simplifies Modules/Setup. Makefile and makesetup already define Py_BUILD_CORE_BUILTIN and include Modules/internal for us. Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Setup62
-rw-r--r--Modules/_abc.c3
-rw-r--r--Modules/_asynciomodule.c4
-rw-r--r--Modules/_blake2/blake2b_impl.c4
-rw-r--r--Modules/_blake2/blake2module.c4
-rw-r--r--Modules/_blake2/blake2s_impl.c4
-rw-r--r--Modules/_ctypes/_ctypes.c3
-rw-r--r--Modules/_ctypes/callbacks.c4
-rw-r--r--Modules/_ctypes/cfield.c4
-rw-r--r--Modules/_ctypes/stgdict.c4
-rw-r--r--Modules/_cursesmodule.c4
-rw-r--r--Modules/_datetimemodule.c4
-rw-r--r--Modules/_decimal/_decimal.c3
-rw-r--r--Modules/_hashopenssl.c4
-rw-r--r--Modules/_heapqmodule.c4
-rw-r--r--Modules/_json.c4
-rw-r--r--Modules/_lsprof.c4
-rw-r--r--Modules/_math.c4
-rw-r--r--Modules/_pickle.c4
-rw-r--r--Modules/_posixsubprocess.c4
-rw-r--r--Modules/_queuemodule.c4
-rw-r--r--Modules/_randommodule.c4
-rw-r--r--Modules/_sha3/sha3module.c4
-rw-r--r--Modules/_struct.c4
-rw-r--r--Modules/_testinternalcapi.c4
-rw-r--r--Modules/_testmultiphase.c3
-rw-r--r--Modules/_xxsubinterpretersmodule.c3
-rw-r--r--Modules/_zoneinfo.c4
-rw-r--r--Modules/arraymodule.c4
-rw-r--r--Modules/binascii.c4
-rw-r--r--Modules/cmathmodule.c4
-rw-r--r--Modules/mathmodule.c4
-rw-r--r--Modules/md5module.c3
-rw-r--r--Modules/sha1module.c3
-rw-r--r--Modules/sha256module.c3
-rw-r--r--Modules/sha512module.c3
-rw-r--r--Modules/unicodedata.c4
37 files changed, 160 insertions, 37 deletions
diff --git a/Modules/Setup b/Modules/Setup
index a4440df..a5b1a7b 100644
--- a/Modules/Setup
+++ b/Modules/Setup
@@ -99,26 +99,26 @@ PYTHONPATH=$(COREPYTHONPATH)
# cannot be built as shared!
_collections _collectionsmodule.c
-_abc -DPy_BUILD_CORE_BUILTIN _abc.c
+_abc _abc.c
_codecs _codecsmodule.c
-_functools -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _functoolsmodule.c
-_io -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c
-_locale -DPy_BUILD_CORE_BUILTIN _localemodule.c # -lintl
-_operator -DPy_BUILD_CORE_BUILTIN _operator.c
-_signal -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal signalmodule.c
-_sre -DPy_BUILD_CORE_BUILTIN _sre.c
+_functools _functoolsmodule.c
+_io -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c
+_locale _localemodule.c # -lintl
+_operator _operator.c
+_signal signalmodule.c
+_sre _sre.c
_stat _stat.c
_symtable symtablemodule.c # setup.py can't track the .h file that _symtable depends on.
-_thread -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _threadmodule.c
+_thread _threadmodule.c
_tracemalloc _tracemalloc.c # See bpo-35053 as to why this is built in.
_weakref _weakref.c
atexit atexitmodule.c
errno errnomodule.c
faulthandler faulthandler.c
itertools itertoolsmodule.c
-posix -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c
+posix posixmodule.c
pwd pwdmodule.c
-time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c
+time timemodule.c
# ---
@@ -139,7 +139,7 @@ time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c
#_asyncio _asynciomodule.c
#_bisect _bisectmodule.c
-#_blake2 -DPy_BUILD_CORE_BUILTIN _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
+#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
#_codecs_cn cjkcodecs/_codecs_cn.c
#_codecs_hk cjkcodecs/_codecs_hk.c
#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
@@ -150,31 +150,31 @@ time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c
#_csv _csv.c
#_datetime _datetimemodule.c
#_elementtree -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI -I$(srcdir)/Modules/expat _elementtree.c
-#_heapq -DPy_BUILD_CORE_MODULE _heapqmodule.c
-#_json -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _json.c
+#_heapq _heapqmodule.c
+#_json _json.c
#_lsprof _lsprof.c rotatingtree.c
-#_md5 -DPy_BUILD_CORE_BUILTIN md5module.c
+#_md5 md5module.c
#_multibytecodec cjkcodecs/multibytecodec.c
#_opcode _opcode.c
-#_pickle -DPy_BUILD_CORE_MODULE _pickle.c
-#_posixsubprocess -DPy_BUILD_CORE_BUILTIN _posixsubprocess.c
-#_queue -DPy_BUILD_CORE_MODULE _queuemodule.c
-#_random -DPy_BUILD_CORE_MODULE _randommodule.c
-#_sha1 -DPy_BUILD_CORE_BUILTIN sha1module.c
-#_sha256 -DPy_BUILD_CORE_BUILTIN sha256module.c
-#_sha512 -DPy_BUILD_CORE_BUILTIN sha512module.c
-#_sha3 -DPy_BUILD_CORE_BUILTIN _sha3/sha3module.c
+#_pickle _pickle.c
+#_posixsubprocess _posixsubprocess.c
+#_queue _queuemodule.c
+#_random _randommodule.c
+#_sha1 sha1module.c
+#_sha256 sha256module.c
+#_sha512 sha512module.c
+#_sha3 _sha3/sha3module.c
#_statistics _statisticsmodule.c
-#_struct -DPy_BUILD_CORE_MODULE _struct.c
+#_struct _struct.c
#_typing _typingmodule.c
-#_zoneinfo -DPy_BUILD_CORE_MODULE _zoneinfo.c
-#array -DPy_BUILD_CORE_MODULE arraymodule.c
+#_zoneinfo _zoneinfo.c
+#array arraymodule.c
#audioop audioop.c
-#binascii -DPy_BUILD_CORE_MODULE binascii.c
-#cmath -DPy_BUILD_CORE_MODULE cmathmodule.c _math.c # -lm
-#math -DPy_BUILD_CORE_MODULE mathmodule.c _math.c # -lm
+#binascii binascii.c
+#cmath cmathmodule.c _math.c # -lm
+#math mathmodule.c _math.c # -lm
#pyexpat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY -DUSE_PYEXPAT_CAPI -I$(srcdir)/Modules/expat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c
-#unicodedata -DPy_BUILD_CORE_BUILTIN unicodedata.c
+#unicodedata unicodedata.c
# Modules with some UNIX dependencies -- on by default:
# (If you have a really backward UNIX, select and socket may not be
@@ -286,7 +286,7 @@ time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c
# provided by the ncurses library. e.g. on Linux, link with -lncurses
# instead of -lcurses).
-#_curses -DPy_BUILD_CORE_MODULE -lcurses -ltermcap _cursesmodule.c
+#_curses -lcurses -ltermcap _cursesmodule.c
# Wrapper for the panel library that's part of ncurses and SYSV curses.
#_curses_panel -lpanel -lncurses _curses_panel.c
@@ -305,7 +305,7 @@ xxsubtype xxsubtype.c # Required for the test suite to pass!
#_testbuffer _testbuffer.c
#_testcapi _testcapimodule.c # CANNOT be statically compiled!
#_testimportmultiple _testimportmultiple.c
-#_testinternalcapi -DPy_BUILD_CORE_MODULE -I$(srcdir)/Include/internal _testinternalcapi.c
+#_testinternalcapi _testinternalcapi.c
#_testmultiphase _testmultiphase.c
diff --git a/Modules/_abc.c b/Modules/_abc.c
index 8aa6835..b7465c3 100644
--- a/Modules/_abc.c
+++ b/Modules/_abc.c
@@ -1,4 +1,7 @@
/* ABCMeta implementation */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
#include "Python.h"
#include "pycore_moduleobject.h" // _PyModule_GetState()
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index adc5ff9..8386a50 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -1,3 +1,7 @@
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_pyerrors.h" // _PyErr_ClearExcState()
#include "pycore_pystate.h" // _PyThreadState_GET()
diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c
index b16324e..e1421dd 100644
--- a/Modules/_blake2/blake2b_impl.c
+++ b/Modules/_blake2/blake2b_impl.c
@@ -13,6 +13,10 @@
* The blake2s_impl.c is autogenerated from blake2b_impl.c.
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_strhex.h" // _Py_strhex()
diff --git a/Modules/_blake2/blake2module.c b/Modules/_blake2/blake2module.c
index 631de2c..3b6bba2 100644
--- a/Modules/_blake2/blake2module.c
+++ b/Modules/_blake2/blake2module.c
@@ -8,6 +8,10 @@
* any warranty. http://creativecommons.org/publicdomain/zero/1.0/
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "impl/blake2.h"
diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c
index 6b31a36..763c017 100644
--- a/Modules/_blake2/blake2s_impl.c
+++ b/Modules/_blake2/blake2s_impl.c
@@ -13,6 +13,10 @@
* The blake2s_impl.c is autogenerated from blake2s_impl.c.
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_strhex.h" // _Py_strhex()
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index f8940fd..96078c7 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -98,6 +98,9 @@ bytes(cdata)
* PyCField_Type
*
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
#define PY_SSIZE_T_CLEAN
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index c24f04c..0f7789a 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -1,3 +1,7 @@
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
// windows.h must be included before pycore internal headers
#ifdef MS_WIN32
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index 2cfd657..515b280 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -1,3 +1,7 @@
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
// windows.h must be included before pycore internal headers
#ifdef MS_WIN32
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 43669d7..6c1917b 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -1,3 +1,7 @@
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
// windows.h must be included before pycore internal headers
#ifdef MS_WIN32
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 511073f..3770a03 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -100,6 +100,10 @@ static const char PyCursesVersion[] = "2.2";
/* Includes */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#define PY_SSIZE_T_CLEAN
#include "Python.h"
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index e54a01b..67441eb 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -7,6 +7,10 @@
* the capsule are defined below */
#define _PY_DATETIME_IMPL
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_long.h" // _PyLong_GetOne()
#include "pycore_object.h" // _PyObject_Init()
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index 237edd5..7fc7315 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -25,6 +25,9 @@
* SUCH DAMAGE.
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
#include <Python.h>
#include "pycore_pystate.h" // _PyThreadState_GET()
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index b4ba60b..1249191 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -18,6 +18,10 @@
#endif
#define OPENSSL_NO_DEPRECATED 1
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#define PY_SSIZE_T_CLEAN
#include "Python.h"
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c
index 20468c2..3dbaaa0 100644
--- a/Modules/_heapqmodule.c
+++ b/Modules/_heapqmodule.c
@@ -6,6 +6,10 @@ annotated by François Pinard, and converted to C by Raymond Hettinger.
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_list.h" // _PyList_ITEMS()
diff --git a/Modules/_json.c b/Modules/_json.c
index 6f68c1f..1c9c506 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -4,8 +4,8 @@
* and as an extension module (Py_BUILD_CORE_MODULE define) on other
* platforms. */
-#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE)
-# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined"
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
#endif
#include "Python.h"
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 2e27afc..ff499aa 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -1,3 +1,7 @@
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_pystate.h" // _PyThreadState_GET()
diff --git a/Modules/_math.c b/Modules/_math.c
index 68e3a23..c1936a1 100644
--- a/Modules/_math.c
+++ b/Modules/_math.c
@@ -1,6 +1,10 @@
/* Definitions of some C99 math library functions, for those platforms
that don't implement these functions already. */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include <float.h>
#include "_math.h"
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 53ab571..0d9e57a 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -4,8 +4,8 @@
* and as an extension module (Py_BUILD_CORE_MODULE define) on other
* platforms. */
-#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE)
-# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined"
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
#endif
#include "Python.h"
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 63207de..de599f8 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -1,4 +1,8 @@
/* Authors: Gregory P. Smith & Jeffrey Yasskin */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_fileutils.h"
#if defined(HAVE_PIPE2) && !defined(_GNU_SOURCE)
diff --git a/Modules/_queuemodule.c b/Modules/_queuemodule.c
index eb61349..413387f 100644
--- a/Modules/_queuemodule.c
+++ b/Modules/_queuemodule.c
@@ -1,3 +1,7 @@
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "structmember.h" // PyMemberDef
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index 65d41f4..5243d5a 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -66,6 +66,10 @@
/* ---------------------------------------------------------------*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_moduleobject.h" // _PyModule_GetState()
#ifdef HAVE_PROCESS_H
diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c
index a033c4e..bfa9661 100644
--- a/Modules/_sha3/sha3module.c
+++ b/Modules/_sha3/sha3module.c
@@ -15,6 +15,10 @@
*
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_strhex.h" // _Py_strhex()
#include "../hashlib.h"
diff --git a/Modules/_struct.c b/Modules/_struct.c
index a8003a9..210dbdc 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -3,6 +3,10 @@
/* New version supporting byte order, alignment and size options,
character strings, and unsigned numbers */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#define PY_SSIZE_T_CLEAN
#include "Python.h"
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 3ba9396..1ca0606 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -2,8 +2,8 @@
* C Extension module to test Python internal C APIs (Include/internal).
*/
-#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE)
-# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined"
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
#endif
/* Always enable assertions */
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c
index 2d25e16..ee69c42 100644
--- a/Modules/_testmultiphase.c
+++ b/Modules/_testmultiphase.c
@@ -1,6 +1,9 @@
/* Testing module for multi-phase initialization of extension modules (PEP 489)
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
#include "Python.h"
#include "pycore_namespace.h" // _PyNamespace_New()
diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c
index b5c0a63..3f68376 100644
--- a/Modules/_xxsubinterpretersmodule.c
+++ b/Modules/_xxsubinterpretersmodule.c
@@ -1,6 +1,9 @@
/* interpreters module */
/* low-level access to interpreter primitives */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
#include "Python.h"
#include "frameobject.h"
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index 04fa094..cac3470 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -1,3 +1,7 @@
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_long.h" // _PyLong_GetOne()
#include "structmember.h"
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 5e57fe1..030ede5 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -3,6 +3,10 @@
/* An array is a uniform list -- all items have the same type.
The item type is restricted to simple C types like int or float */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_floatobject.h" // _PyFloat_Unpack4()
diff --git a/Modules/binascii.c b/Modules/binascii.c
index 7037d34..fec0d82 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -53,6 +53,10 @@
** Brandon Long, September 2001.
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#define PY_SSIZE_T_CLEAN
#include "Python.h"
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c
index 0f22049..0e0489c 100644
--- a/Modules/cmathmodule.c
+++ b/Modules/cmathmodule.c
@@ -2,6 +2,10 @@
/* much code borrowed from mathmodule.c */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_dtoa.h"
#include "_math.h"
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 4fac0cc..6c12a4e 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -52,6 +52,10 @@ raised for division by zero and mod by zero.
returned.
*/
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#include "Python.h"
#include "pycore_bitutils.h" // _Py_bit_length()
#include "pycore_call.h" // _PyObject_CallNoArgs()
diff --git a/Modules/md5module.c b/Modules/md5module.c
index 4d03f6b..48b11e0 100644
--- a/Modules/md5module.c
+++ b/Modules/md5module.c
@@ -15,6 +15,9 @@
*/
/* MD5 objects */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
#include "Python.h"
#include "hashlib.h"
diff --git a/Modules/sha1module.c b/Modules/sha1module.c
index 153bc12..9153557 100644
--- a/Modules/sha1module.c
+++ b/Modules/sha1module.c
@@ -15,6 +15,9 @@
*/
/* SHA1 objects */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
#include "Python.h"
#include "hashlib.h"
diff --git a/Modules/sha256module.c b/Modules/sha256module.c
index 5858071..17ee866 100644
--- a/Modules/sha256module.c
+++ b/Modules/sha256module.c
@@ -15,6 +15,9 @@
*/
/* SHA objects */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
#include "Python.h"
#include "pycore_bitutils.h" // _Py_bswap32()
diff --git a/Modules/sha512module.c b/Modules/sha512module.c
index e50b69b..bf4408b 100644
--- a/Modules/sha512module.c
+++ b/Modules/sha512module.c
@@ -15,6 +15,9 @@
*/
/* SHA objects */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
#include "Python.h"
#include "pycore_bitutils.h" // _Py_bswap64()
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index e863e53..bdbddcf 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -12,6 +12,10 @@
------------------------------------------------------------------------ */
+#ifndef Py_BUILD_CORE_BUILTIN
+# define Py_BUILD_CORE_MODULE 1
+#endif
+
#define PY_SSIZE_T_CLEAN
#include "Python.h"