@@ -283,14 +283,19 @@ BUILDPYTHON= python$(BUILDEXE)
283
283
PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@
284
284
UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/update_file.py
285
285
PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
286
- # Standard builds use _bootstrap_python for freezing, cross compiling
287
- # uses build Python, which must have the same version and bytecode,
288
- PYTHON_FOR_FREEZE?=@PYTHON_FOR_FREEZE@
286
+
287
+ # Normal builds use Programs/_freeze_module.c for bootstrapping and
288
+ # ./_bootstrap_python Programs/_freeze_module.py for remaining modules
289
+ # Cross builds use an external "build Python" for all modules.
290
+ PYTHON_FOR_FREEZE=@PYTHON_FOR_FREEZE@
291
+ FREEZE_MODULE_BOOTSTRAP=@FREEZE_MODULE_BOOTSTRAP@
292
+ FREEZE_MODULE_BOOTSTRAP_DEPS=@FREEZE_MODULE_BOOTSTRAP_DEPS@
293
+ FREEZE_MODULE=@FREEZE_MODULE@
294
+ FREEZE_MODULE_DEPS=@FREEZE_MODULE_DEPS@
295
+
289
296
_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
290
297
BUILD_GNU_TYPE= @build@
291
298
HOST_GNU_TYPE= @host@
292
- # Allow developers to override freeze_module command for cross building (bpo-45886)
293
- FREEZE_MODULE?=@FREEZE_MODULE@
294
299
295
300
# Tcl and Tk config info from --with-tcltk-includes and -libs options
296
301
TCLTK_INCLUDES= @TCLTK_INCLUDES@
@@ -967,7 +972,7 @@ _bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modu
967
972
.PHONY: regen-deepfreeze
968
973
regen-deepfreeze: $(DEEPFREEZE_OBJS)
969
974
970
- DEEPFREEZE_DEPS=$(srcdir)/Tools/scripts/deepfreeze.py _bootstrap_python
975
+ DEEPFREEZE_DEPS=$(srcdir)/Tools/scripts/deepfreeze.py $(FREEZE_MODULE_DEPS)
971
976
972
977
# BEGIN: deepfreeze modules
973
978
@@ -1044,6 +1049,30 @@ Python/deepfreeze/frozen_only.c: Python/frozen_modules/frozen_only.h $(DEEPFREEZ
1044
1049
1045
1050
############################################################################
1046
1051
# frozen modules (including importlib)
1052
+ #
1053
+ # Freezing is a multi step process. It works differently for standard builds
1054
+ # and cross builds. Standard builds use Programs/_freeze_module and
1055
+ # _bootstrap_python for freezing and deepfreezing, so users can build Python
1056
+ # without an existing Python installation. Cross builds cannot execute
1057
+ # compiled binaries and therefore rely on an external build Python
1058
+ # interpreter. The build interpreter must have same version and same bytecode
1059
+ # as the host (target) binary.
1060
+ #
1061
+ # Standard build process:
1062
+ # 1) compile minimal core objects for Py_Compile*() and PyMarshal_Write*().
1063
+ # 2) build Programs/_freeze_module binary.
1064
+ # 3) create frozen module headers for importlib and getpath.
1065
+ # 4) build _bootstrap_python binary.
1066
+ # 5) create remaining frozen module headers with
1067
+ # ``./_bootstrap_python Programs/_freeze_module.py``. The pure Python
1068
+ # script is used to test the cross compile code path.
1069
+ # 6) deepfreeze modules with _bootstrap_python
1070
+ #
1071
+ # Cross compile process:
1072
+ # 1) create all frozen module headers with external build Python and
1073
+ # Programs/_freeze_module.py script.
1074
+ # 2) deepfreeze modules with external build Python.
1075
+ #
1047
1076
1048
1077
# FROZEN_FILES_* are auto-generated by Tools/scripts/freeze_modules.py.
1049
1078
FROZEN_FILES_IN = \
@@ -1104,83 +1133,83 @@ Modules/getpath_noop.o: $(srcdir)/Modules/getpath_noop.c Makefile
1104
1133
Programs/_freeze_module: Programs/_freeze_module.o Modules/getpath_noop.o $(LIBRARY_OBJS_OMIT_FROZEN)
1105
1134
$(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_module.o Modules/getpath_noop.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS)
1106
1135
1136
+ # We manually freeze getpath.py rather than through freeze_modules
1137
+ Python/frozen_modules/getpath.h: Modules/getpath.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1138
+ $(FREEZE_MODULE_BOOTSTRAP) getpath $(srcdir)/Modules/getpath.py Python/frozen_modules/getpath.h
1139
+
1107
1140
# BEGIN: freezing modules
1108
1141
1109
- Python/frozen_modules/importlib._bootstrap.h: $(FREEZE_MODULE) Lib/importlib/_bootstrap.py
1110
- $(FREEZE_MODULE ) importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h
1142
+ Python/frozen_modules/importlib._bootstrap.h: Lib/importlib/_bootstrap.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1143
+ $(FREEZE_MODULE_BOOTSTRAP ) importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h
1111
1144
1112
- Python/frozen_modules/importlib._bootstrap_external.h: $(FREEZE_MODULE) Lib/importlib/_bootstrap_external.py
1113
- $(FREEZE_MODULE ) importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h
1145
+ Python/frozen_modules/importlib._bootstrap_external.h: Lib/importlib/_bootstrap_external.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1146
+ $(FREEZE_MODULE_BOOTSTRAP ) importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h
1114
1147
1115
- Python/frozen_modules/zipimport.h: $(FREEZE_MODULE) Lib/zipimport.py
1116
- $(FREEZE_MODULE ) zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h
1148
+ Python/frozen_modules/zipimport.h: Lib/zipimport.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1149
+ $(FREEZE_MODULE_BOOTSTRAP ) zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h
1117
1150
1118
- Python/frozen_modules/abc.h: $(FREEZE_MODULE) Lib/abc.py
1151
+ Python/frozen_modules/abc.h: Lib/abc.py $(FREEZE_MODULE_DEPS)
1119
1152
$(FREEZE_MODULE) abc $(srcdir)/Lib/abc.py Python/frozen_modules/abc.h
1120
1153
1121
- Python/frozen_modules/codecs.h: $(FREEZE_MODULE) Lib/codecs.py
1154
+ Python/frozen_modules/codecs.h: Lib/codecs.py $(FREEZE_MODULE_DEPS)
1122
1155
$(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h
1123
1156
1124
- Python/frozen_modules/io.h: $(FREEZE_MODULE) Lib/io.py
1157
+ Python/frozen_modules/io.h: Lib/io.py $(FREEZE_MODULE_DEPS)
1125
1158
$(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h
1126
1159
1127
- Python/frozen_modules/_collections_abc.h: $(FREEZE_MODULE) Lib/_collections_abc.py
1160
+ Python/frozen_modules/_collections_abc.h: Lib/_collections_abc.py $(FREEZE_MODULE_DEPS)
1128
1161
$(FREEZE_MODULE) _collections_abc $(srcdir)/Lib/_collections_abc.py Python/frozen_modules/_collections_abc.h
1129
1162
1130
- Python/frozen_modules/_sitebuiltins.h: $(FREEZE_MODULE) Lib/_sitebuiltins.py
1163
+ Python/frozen_modules/_sitebuiltins.h: Lib/_sitebuiltins.py $(FREEZE_MODULE_DEPS)
1131
1164
$(FREEZE_MODULE) _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py Python/frozen_modules/_sitebuiltins.h
1132
1165
1133
- Python/frozen_modules/genericpath.h: $(FREEZE_MODULE) Lib/genericpath.py
1166
+ Python/frozen_modules/genericpath.h: Lib/genericpath.py $(FREEZE_MODULE_DEPS)
1134
1167
$(FREEZE_MODULE) genericpath $(srcdir)/Lib/genericpath.py Python/frozen_modules/genericpath.h
1135
1168
1136
- Python/frozen_modules/ntpath.h: $(FREEZE_MODULE) Lib/ntpath.py
1169
+ Python/frozen_modules/ntpath.h: Lib/ntpath.py $(FREEZE_MODULE_DEPS)
1137
1170
$(FREEZE_MODULE) ntpath $(srcdir)/Lib/ntpath.py Python/frozen_modules/ntpath.h
1138
1171
1139
- Python/frozen_modules/posixpath.h: $(FREEZE_MODULE) Lib/posixpath.py
1172
+ Python/frozen_modules/posixpath.h: Lib/posixpath.py $(FREEZE_MODULE_DEPS)
1140
1173
$(FREEZE_MODULE) posixpath $(srcdir)/Lib/posixpath.py Python/frozen_modules/posixpath.h
1141
1174
1142
- Python/frozen_modules/os.h: $(FREEZE_MODULE) Lib/os.py
1175
+ Python/frozen_modules/os.h: Lib/os.py $(FREEZE_MODULE_DEPS)
1143
1176
$(FREEZE_MODULE) os $(srcdir)/Lib/os.py Python/frozen_modules/os.h
1144
1177
1145
- Python/frozen_modules/site.h: $(FREEZE_MODULE) Lib/site.py
1178
+ Python/frozen_modules/site.h: Lib/site.py $(FREEZE_MODULE_DEPS)
1146
1179
$(FREEZE_MODULE) site $(srcdir)/Lib/site.py Python/frozen_modules/site.h
1147
1180
1148
- Python/frozen_modules/stat.h: $(FREEZE_MODULE) Lib/stat.py
1181
+ Python/frozen_modules/stat.h: Lib/stat.py $(FREEZE_MODULE_DEPS)
1149
1182
$(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
1150
1183
1151
- Python/frozen_modules/importlib.util.h: $(FREEZE_MODULE) Lib/importlib/util.py
1184
+ Python/frozen_modules/importlib.util.h: Lib/importlib/util.py $(FREEZE_MODULE_DEPS)
1152
1185
$(FREEZE_MODULE) importlib.util $(srcdir)/Lib/importlib/util.py Python/frozen_modules/importlib.util.h
1153
1186
1154
- Python/frozen_modules/importlib.machinery.h: $(FREEZE_MODULE) Lib/importlib/machinery.py
1187
+ Python/frozen_modules/importlib.machinery.h: Lib/importlib/machinery.py $(FREEZE_MODULE_DEPS)
1155
1188
$(FREEZE_MODULE) importlib.machinery $(srcdir)/Lib/importlib/machinery.py Python/frozen_modules/importlib.machinery.h
1156
1189
1157
- Python/frozen_modules/runpy.h: $(FREEZE_MODULE) Lib/runpy.py
1190
+ Python/frozen_modules/runpy.h: Lib/runpy.py $(FREEZE_MODULE_DEPS)
1158
1191
$(FREEZE_MODULE) runpy $(srcdir)/Lib/runpy.py Python/frozen_modules/runpy.h
1159
1192
1160
- Python/frozen_modules/__hello__.h: $(FREEZE_MODULE) Lib/__hello__.py
1193
+ Python/frozen_modules/__hello__.h: Lib/__hello__.py $(FREEZE_MODULE_DEPS)
1161
1194
$(FREEZE_MODULE) __hello__ $(srcdir)/Lib/__hello__.py Python/frozen_modules/__hello__.h
1162
1195
1163
- Python/frozen_modules/__phello__.h: $(FREEZE_MODULE) Lib/__phello__/__init__.py
1196
+ Python/frozen_modules/__phello__.h: Lib/__phello__/__init__.py $(FREEZE_MODULE_DEPS)
1164
1197
$(FREEZE_MODULE) __phello__ $(srcdir)/Lib/__phello__/__init__.py Python/frozen_modules/__phello__.h
1165
1198
1166
- Python/frozen_modules/__phello__.ham.h: $(FREEZE_MODULE) Lib/__phello__/ham/__init__.py
1199
+ Python/frozen_modules/__phello__.ham.h: Lib/__phello__/ham/__init__.py $(FREEZE_MODULE_DEPS)
1167
1200
$(FREEZE_MODULE) __phello__.ham $(srcdir)/Lib/__phello__/ham/__init__.py Python/frozen_modules/__phello__.ham.h
1168
1201
1169
- Python/frozen_modules/__phello__.ham.eggs.h: $(FREEZE_MODULE) Lib/__phello__/ham/eggs.py
1202
+ Python/frozen_modules/__phello__.ham.eggs.h: Lib/__phello__/ham/eggs.py $(FREEZE_MODULE_DEPS)
1170
1203
$(FREEZE_MODULE) __phello__.ham.eggs $(srcdir)/Lib/__phello__/ham/eggs.py Python/frozen_modules/__phello__.ham.eggs.h
1171
1204
1172
- Python/frozen_modules/__phello__.spam.h: $(FREEZE_MODULE) Lib/__phello__/spam.py
1205
+ Python/frozen_modules/__phello__.spam.h: Lib/__phello__/spam.py $(FREEZE_MODULE_DEPS)
1173
1206
$(FREEZE_MODULE) __phello__.spam $(srcdir)/Lib/__phello__/spam.py Python/frozen_modules/__phello__.spam.h
1174
1207
1175
- Python/frozen_modules/frozen_only.h: $(FREEZE_MODULE) Tools/freeze/flag.py
1208
+ Python/frozen_modules/frozen_only.h: Tools/freeze/flag.py $(FREEZE_MODULE_DEPS)
1176
1209
$(FREEZE_MODULE) frozen_only $(srcdir)/Tools/freeze/flag.py Python/frozen_modules/frozen_only.h
1177
1210
1178
1211
# END: freezing modules
1179
1212
1180
- # We manually freeze getpath.py rather than through freeze_modules
1181
- Python/frozen_modules/getpath.h: $(FREEZE_MODULE) Modules/getpath.py
1182
- $(FREEZE_MODULE) getpath $(srcdir)/Modules/getpath.py Python/frozen_modules/getpath.h
1183
-
1184
1213
Tools/scripts/freeze_modules.py: $(FREEZE_MODULE)
1185
1214
1186
1215
.PHONY: regen-frozen
0 commit comments