mirror of https://github.com/python/cpython
bpo-45950: Introduce Bootstrap Python again (#29859)
The build system now uses a :program:`_bootstrap_python` interpreter for freezing and deepfreezing again. To speed up build process the build tools :program:`_bootstrap_python` and :program:`_freeze_module` are no longer build with LTO. Cross building depends on a build Python interpreter, which must have same version and bytecode as target host Python.
This commit is contained in:
parent
ccb73a0d50
commit
84ca1232b0
|
@ -60,6 +60,7 @@ Lib/distutils/command/*.pdb
|
|||
Lib/lib2to3/*.pickle
|
||||
Lib/test/data/*
|
||||
!Lib/test/data/README
|
||||
/_bootstrap_python
|
||||
/Makefile
|
||||
/Makefile.pre
|
||||
Mac/Makefile
|
||||
|
|
|
@ -90,6 +90,9 @@ CONFIGURE_CFLAGS_NODIST=@CFLAGS_NODIST@
|
|||
# Use it when a linker flag should _not_ be part of the distutils LDFLAGS
|
||||
# once Python is installed (bpo-35257)
|
||||
CONFIGURE_LDFLAGS_NODIST=@LDFLAGS_NODIST@
|
||||
# LDFLAGS_NOLTO is an extra flag to disable lto. It is used to speed up building
|
||||
# of _bootstrap_python and _freeze_module tools, which don't need LTO.
|
||||
CONFIGURE_LDFLAGS_NOLTO=@LDFLAGS_NOLTO@
|
||||
CONFIGURE_CPPFLAGS= @CPPFLAGS@
|
||||
CONFIGURE_LDFLAGS= @LDFLAGS@
|
||||
# Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the
|
||||
|
@ -103,6 +106,7 @@ PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include
|
|||
PY_CPPFLAGS= $(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
|
||||
PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS)
|
||||
PY_LDFLAGS_NODIST=$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)
|
||||
PY_LDFLAGS_NOLTO=$(PY_LDFLAGS) $(CONFIGURE_LDFLAGS_NOLTO) $(LDFLAGS_NODIST)
|
||||
NO_AS_NEEDED= @NO_AS_NEEDED@
|
||||
CCSHARED= @CCSHARED@
|
||||
# LINKFORSHARED are the flags passed to the $(CC) command that links
|
||||
|
@ -279,6 +283,9 @@ BUILDPYTHON= python$(BUILDEXE)
|
|||
PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@
|
||||
UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/update_file.py
|
||||
PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
|
||||
# Standard builds use _bootstrap_python for freezing, cross compiling
|
||||
# uses build Python, which must have the same version and bytecode,
|
||||
PYTHON_FOR_FREEZE?=@PYTHON_FOR_FREEZE@
|
||||
_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
|
||||
BUILD_GNU_TYPE= @build@
|
||||
HOST_GNU_TYPE= @host@
|
||||
|
@ -938,75 +945,88 @@ regen-test-frozenmain: $(BUILDPYTHON)
|
|||
Programs/_testembed: Programs/_testembed.o $(LIBRARY_DEPS)
|
||||
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
|
||||
|
||||
############################################################################
|
||||
# "Bootstrap Python" used to run deepfreeze.py
|
||||
|
||||
BOOTSTRAP_HEADERS = \
|
||||
Python/frozen_modules/importlib._bootstrap.h \
|
||||
Python/frozen_modules/importlib._bootstrap_external.h
|
||||
|
||||
Programs/_bootstrap_python.o: Programs/_bootstrap_python.c $(BOOTSTRAP_HEADERS) $(PYTHON_HEADERS)
|
||||
|
||||
_bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modules/getpath.o Modules/Setup.local
|
||||
$(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ $(LIBRARY_OBJS_OMIT_FROZEN) \
|
||||
Programs/_bootstrap_python.o Modules/getpath.o $(LIBS) $(MODLIBS) $(SYSLIBS)
|
||||
|
||||
############################################################################
|
||||
# Deepfreeze targets
|
||||
|
||||
.PHONY: regen-deepfreeze
|
||||
regen-deepfreeze: $(DEEPFREEZE_OBJS)
|
||||
|
||||
DEEPFREEZE_DEPS=$(srcdir)/Tools/scripts/deepfreeze.py
|
||||
DEEPFREEZE_DEPS=$(srcdir)/Tools/scripts/deepfreeze.py _bootstrap_python
|
||||
|
||||
# BEGIN: deepfreeze modules
|
||||
|
||||
Python/deepfreeze/importlib._bootstrap.c: Python/frozen_modules/importlib._bootstrap.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/importlib._bootstrap.h -m importlib._bootstrap -o Python/deepfreeze/importlib._bootstrap.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/importlib._bootstrap.h -m importlib._bootstrap -o Python/deepfreeze/importlib._bootstrap.c
|
||||
|
||||
Python/deepfreeze/importlib._bootstrap_external.c: Python/frozen_modules/importlib._bootstrap_external.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/importlib._bootstrap_external.h -m importlib._bootstrap_external -o Python/deepfreeze/importlib._bootstrap_external.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/importlib._bootstrap_external.h -m importlib._bootstrap_external -o Python/deepfreeze/importlib._bootstrap_external.c
|
||||
|
||||
Python/deepfreeze/zipimport.c: Python/frozen_modules/zipimport.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/zipimport.h -m zipimport -o Python/deepfreeze/zipimport.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/zipimport.h -m zipimport -o Python/deepfreeze/zipimport.c
|
||||
|
||||
Python/deepfreeze/abc.c: Python/frozen_modules/abc.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/abc.h -m abc -o Python/deepfreeze/abc.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/abc.h -m abc -o Python/deepfreeze/abc.c
|
||||
|
||||
Python/deepfreeze/codecs.c: Python/frozen_modules/codecs.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/codecs.h -m codecs -o Python/deepfreeze/codecs.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/codecs.h -m codecs -o Python/deepfreeze/codecs.c
|
||||
|
||||
Python/deepfreeze/io.c: Python/frozen_modules/io.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/io.h -m io -o Python/deepfreeze/io.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/io.h -m io -o Python/deepfreeze/io.c
|
||||
|
||||
Python/deepfreeze/_collections_abc.c: Python/frozen_modules/_collections_abc.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/_collections_abc.h -m _collections_abc -o Python/deepfreeze/_collections_abc.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/_collections_abc.h -m _collections_abc -o Python/deepfreeze/_collections_abc.c
|
||||
|
||||
Python/deepfreeze/_sitebuiltins.c: Python/frozen_modules/_sitebuiltins.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/_sitebuiltins.h -m _sitebuiltins -o Python/deepfreeze/_sitebuiltins.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/_sitebuiltins.h -m _sitebuiltins -o Python/deepfreeze/_sitebuiltins.c
|
||||
|
||||
Python/deepfreeze/genericpath.c: Python/frozen_modules/genericpath.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/genericpath.h -m genericpath -o Python/deepfreeze/genericpath.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/genericpath.h -m genericpath -o Python/deepfreeze/genericpath.c
|
||||
|
||||
Python/deepfreeze/ntpath.c: Python/frozen_modules/ntpath.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/ntpath.h -m ntpath -o Python/deepfreeze/ntpath.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/ntpath.h -m ntpath -o Python/deepfreeze/ntpath.c
|
||||
|
||||
Python/deepfreeze/posixpath.c: Python/frozen_modules/posixpath.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/posixpath.h -m posixpath -o Python/deepfreeze/posixpath.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/posixpath.h -m posixpath -o Python/deepfreeze/posixpath.c
|
||||
|
||||
Python/deepfreeze/os.c: Python/frozen_modules/os.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/os.h -m os -o Python/deepfreeze/os.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/os.h -m os -o Python/deepfreeze/os.c
|
||||
|
||||
Python/deepfreeze/site.c: Python/frozen_modules/site.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/site.h -m site -o Python/deepfreeze/site.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/site.h -m site -o Python/deepfreeze/site.c
|
||||
|
||||
Python/deepfreeze/stat.c: Python/frozen_modules/stat.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/stat.h -m stat -o Python/deepfreeze/stat.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/stat.h -m stat -o Python/deepfreeze/stat.c
|
||||
|
||||
Python/deepfreeze/__hello__.c: Python/frozen_modules/__hello__.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__hello__.h -m __hello__ -o Python/deepfreeze/__hello__.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__hello__.h -m __hello__ -o Python/deepfreeze/__hello__.c
|
||||
|
||||
Python/deepfreeze/__phello__.c: Python/frozen_modules/__phello__.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__phello__.h -m __phello__ -o Python/deepfreeze/__phello__.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__phello__.h -m __phello__ -o Python/deepfreeze/__phello__.c
|
||||
|
||||
Python/deepfreeze/__phello__.ham.c: Python/frozen_modules/__phello__.ham.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__phello__.ham.h -m __phello__.ham -o Python/deepfreeze/__phello__.ham.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__phello__.ham.h -m __phello__.ham -o Python/deepfreeze/__phello__.ham.c
|
||||
|
||||
Python/deepfreeze/__phello__.ham.eggs.c: Python/frozen_modules/__phello__.ham.eggs.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__phello__.ham.eggs.h -m __phello__.ham.eggs -o Python/deepfreeze/__phello__.ham.eggs.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__phello__.ham.eggs.h -m __phello__.ham.eggs -o Python/deepfreeze/__phello__.ham.eggs.c
|
||||
|
||||
Python/deepfreeze/__phello__.spam.c: Python/frozen_modules/__phello__.spam.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__phello__.spam.h -m __phello__.spam -o Python/deepfreeze/__phello__.spam.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__phello__.spam.h -m __phello__.spam -o Python/deepfreeze/__phello__.spam.c
|
||||
|
||||
Python/deepfreeze/frozen_only.c: Python/frozen_modules/frozen_only.h $(DEEPFREEZE_DEPS)
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/frozen_only.h -m frozen_only -o Python/deepfreeze/frozen_only.c
|
||||
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/frozen_only.h -m frozen_only -o Python/deepfreeze/frozen_only.c
|
||||
|
||||
# END: deepfreeze modules
|
||||
|
||||
|
@ -2295,6 +2315,7 @@ clean-retain-profile: pycremoval
|
|||
find build -name '*.py[co]' -exec rm -f {} ';' || true
|
||||
-rm -f pybuilddir.txt
|
||||
-rm -f Lib/lib2to3/*Grammar*.pickle
|
||||
-rm -f _bootstrap_python
|
||||
-rm -f Programs/_testembed Programs/_freeze_module
|
||||
-rm -f Python/deepfreeze/*.[co]
|
||||
-rm -f Python/frozen_modules/*.h
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
The build system now uses a :program:`_bootstrap_python` interpreter for
|
||||
freezing and deepfreezing again. To speed up build process the build tools
|
||||
:program:`_bootstrap_python` and :program:`_freeze_module` are no longer
|
||||
build with LTO.
|
|
@ -0,0 +1,105 @@
|
|||
|
||||
/* Frozen modules bootstrap
|
||||
*
|
||||
* Limited and restricted Python interpreter to run
|
||||
* "Tools/scripts/deepfreeze.py" on systems with no or older Python
|
||||
* interpreter.
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
#include "pycore_import.h"
|
||||
|
||||
/* Includes for frozen modules: */
|
||||
#include "Python/frozen_modules/importlib._bootstrap.h"
|
||||
#include "Python/frozen_modules/importlib._bootstrap_external.h"
|
||||
/* End includes */
|
||||
|
||||
/* Note that a negative size indicates a package. */
|
||||
|
||||
static const struct _frozen bootstrap_modules[] = {
|
||||
{"_frozen_importlib", _Py_M__importlib__bootstrap, (int)sizeof(_Py_M__importlib__bootstrap)},
|
||||
{"_frozen_importlib_external", _Py_M__importlib__bootstrap_external, (int)sizeof(_Py_M__importlib__bootstrap_external)},
|
||||
{0, 0, 0} /* bootstrap sentinel */
|
||||
};
|
||||
static const struct _frozen stdlib_modules[] = {
|
||||
{0, 0, 0} /* stdlib sentinel */
|
||||
};
|
||||
static const struct _frozen test_modules[] = {
|
||||
{0, 0, 0} /* test sentinel */
|
||||
};
|
||||
const struct _frozen *_PyImport_FrozenBootstrap = bootstrap_modules;
|
||||
const struct _frozen *_PyImport_FrozenStdlib = stdlib_modules;
|
||||
const struct _frozen *_PyImport_FrozenTest = test_modules;
|
||||
|
||||
static const struct _module_alias aliases[] = {
|
||||
{"_frozen_importlib", "importlib._bootstrap"},
|
||||
{"_frozen_importlib_external", "importlib._bootstrap_external"},
|
||||
{0, 0} /* aliases sentinel */
|
||||
};
|
||||
const struct _module_alias *_PyImport_FrozenAliases = aliases;
|
||||
|
||||
/* Embedding apps may change this pointer to point to their favorite
|
||||
collection of frozen modules: */
|
||||
|
||||
const struct _frozen *PyImport_FrozenModules = NULL;
|
||||
|
||||
int
|
||||
#ifdef MS_WINDOWS
|
||||
wmain(int argc, wchar_t **argv)
|
||||
#else
|
||||
main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
PyStatus status;
|
||||
|
||||
PyConfig config;
|
||||
PyConfig_InitIsolatedConfig(&config);
|
||||
// don't warn, pybuilddir.txt does not exist yet
|
||||
config.pathconfig_warnings = 0;
|
||||
// parse arguments
|
||||
config.parse_argv = 1;
|
||||
// add current script dir to sys.path
|
||||
config.isolated = 0;
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
status = PyConfig_SetArgv(&config, argc, argv);
|
||||
#else
|
||||
status = PyConfig_SetBytesArgv(&config, argc, argv);
|
||||
#endif
|
||||
if (PyStatus_Exception(status)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = PyConfig_Read(&config);
|
||||
if (config.run_filename == NULL) {
|
||||
status = PyStatus_Error("Run filename expected");
|
||||
goto error;
|
||||
}
|
||||
|
||||
#define CLEAR(ATTR) \
|
||||
do { \
|
||||
PyMem_RawFree(ATTR); \
|
||||
ATTR = NULL; \
|
||||
} while (0)
|
||||
|
||||
// isolate from system Python
|
||||
CLEAR(config.base_prefix);
|
||||
CLEAR(config.prefix);
|
||||
CLEAR(config.base_exec_prefix);
|
||||
CLEAR(config.exec_prefix);
|
||||
|
||||
status = Py_InitializeFromConfig(&config);
|
||||
if (PyStatus_Exception(status)) {
|
||||
goto error;
|
||||
}
|
||||
PyConfig_Clear(&config);
|
||||
|
||||
return Py_RunMain();
|
||||
|
||||
error:
|
||||
PyConfig_Clear(&config);
|
||||
if (PyStatus_IsExit(status)) {
|
||||
return status.exitcode;
|
||||
}
|
||||
Py_ExitStatusException(status);
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
|
||||
/* Frozen modules bootstrap */
|
||||
|
||||
/* This file is linked with "bootstrap Python"
|
||||
which is used (only) to run Tools/scripts/deepfreeze.py. */
|
||||
|
||||
#include "Python.h"
|
||||
#include "pycore_import.h"
|
||||
|
||||
/* Includes for frozen modules: */
|
||||
#include "frozen_modules/importlib._bootstrap.h"
|
||||
#include "frozen_modules/importlib._bootstrap_external.h"
|
||||
#include "frozen_modules/zipimport.h"
|
||||
/* End includes */
|
||||
|
||||
/* Note that a negative size indicates a package. */
|
||||
|
||||
static const struct _frozen bootstrap_modules[] = {
|
||||
{"_frozen_importlib", _Py_M__importlib__bootstrap, (int)sizeof(_Py_M__importlib__bootstrap)},
|
||||
{"_frozen_importlib_external", _Py_M__importlib__bootstrap_external, (int)sizeof(_Py_M__importlib__bootstrap_external)},
|
||||
{"zipimport", _Py_M__zipimport, (int)sizeof(_Py_M__zipimport)},
|
||||
{0, 0, 0} /* bootstrap sentinel */
|
||||
};
|
||||
static const struct _frozen stdlib_modules[] = {
|
||||
{0, 0, 0} /* stdlib sentinel */
|
||||
};
|
||||
static const struct _frozen test_modules[] = {
|
||||
{0, 0, 0} /* test sentinel */
|
||||
};
|
||||
const struct _frozen *_PyImport_FrozenBootstrap = bootstrap_modules;
|
||||
const struct _frozen *_PyImport_FrozenStdlib = stdlib_modules;
|
||||
const struct _frozen *_PyImport_FrozenTest = test_modules;
|
||||
|
||||
static const struct _module_alias aliases[] = {
|
||||
{"_frozen_importlib", "importlib._bootstrap"},
|
||||
{"_frozen_importlib_external", "importlib._bootstrap_external"},
|
||||
{0, 0} /* aliases sentinel */
|
||||
};
|
||||
const struct _module_alias *_PyImport_FrozenAliases = aliases;
|
||||
|
||||
|
||||
/* Embedding apps may change this pointer to point to their favorite
|
||||
collection of frozen modules: */
|
||||
|
||||
const struct _frozen *PyImport_FrozenModules = NULL;
|
|
@ -1,3 +1,8 @@
|
|||
"""Deep freeze
|
||||
|
||||
The script is executed by _bootstrap_python interpreter. Shared library
|
||||
extension modules are not available.
|
||||
"""
|
||||
import argparse
|
||||
import ast
|
||||
import builtins
|
||||
|
@ -8,7 +13,6 @@ import re
|
|||
import sys
|
||||
import time
|
||||
import types
|
||||
import unicodedata
|
||||
from typing import Dict, FrozenSet, Tuple, TextIO
|
||||
|
||||
import umarshal
|
||||
|
|
|
@ -589,7 +589,7 @@ def regen_makefile(modules):
|
|||
])
|
||||
deepfreezerules.append(f'{cfile}: {frozen_header} $(DEEPFREEZE_DEPS)')
|
||||
deepfreezerules.append(
|
||||
f"\t$(PYTHON_FOR_REGEN) "
|
||||
f"\t$(PYTHON_FOR_FREEZE) "
|
||||
f"$(srcdir)/Tools/scripts/deepfreeze.py "
|
||||
f"{frozen_header} -m {src.frozenid} -o {cfile}")
|
||||
deepfreezerules.append('')
|
||||
|
|
|
@ -845,6 +845,7 @@ SHLIB_SUFFIX
|
|||
LIBTOOL_CRUFT
|
||||
OTHER_LIBTOOL_OPT
|
||||
UNIVERSAL_ARCH_FLAGS
|
||||
LDFLAGS_NOLTO
|
||||
LDFLAGS_NODIST
|
||||
CFLAGS_NODIST
|
||||
BASECFLAGS
|
||||
|
@ -932,6 +933,7 @@ CONFIG_ARGS
|
|||
SOVERSION
|
||||
VERSION
|
||||
PYTHON_FOR_REGEN
|
||||
PYTHON_FOR_FREEZE
|
||||
PYTHON_FOR_BUILD
|
||||
FREEZE_MODULE
|
||||
host_os
|
||||
|
@ -3250,6 +3252,7 @@ fi
|
|||
as_fn_error $? "\"$with_build_python\" has incompatible version $build_python_ver (expected: $PACKAGE_VERSION)" "$LINENO" 5
|
||||
fi
|
||||
ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
|
||||
PYTHON_FOR_FREEZE="$with_build_python"
|
||||
PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_build_python" >&5
|
||||
$as_echo "$with_build_python" >&6; }
|
||||
|
@ -3261,12 +3264,19 @@ else
|
|||
|
||||
fi
|
||||
PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
|
||||
PYTHON_FOR_FREEZE="./_bootstrap_python"
|
||||
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python interpreter freezing" >&5
|
||||
$as_echo_n "checking for Python interpreter freezing... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_FOR_FREEZE" >&5
|
||||
$as_echo "$PYTHON_FOR_FREEZE" >&6; }
|
||||
|
||||
|
||||
for ac_prog in python$PACKAGE_VERSION python3.10 python3.9 python3.8 python3.7 python3.6 python3 python
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
|
@ -3314,7 +3324,7 @@ test -n "$PYTHON_FOR_REGEN" || PYTHON_FOR_REGEN="python3"
|
|||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python for regen version" >&5
|
||||
$as_echo_n "checking Python for regen version... " >&6; }
|
||||
if command -v $PYTHON_FOR_REGEN >/dev/null 2>&1; then
|
||||
if command -v "$PYTHON_FOR_REGEN" >/dev/null 2>&1; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $($PYTHON_FOR_REGEN -V 2>/dev/null)" >&5
|
||||
$as_echo "$($PYTHON_FOR_REGEN -V 2>/dev/null)" >&6; }
|
||||
else
|
||||
|
@ -7101,6 +7111,7 @@ fi
|
|||
if test "$Py_LTO" = 'true' ; then
|
||||
case $CC in
|
||||
*clang*)
|
||||
LDFLAGS_NOLTO="-fno-lto"
|
||||
|
||||
if test -n "$ac_tool_prefix"; then
|
||||
# Extract the first word of "${ac_tool_prefix}llvm-ar", so it can be a program name with args.
|
||||
|
@ -7254,6 +7265,7 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
|
|||
then
|
||||
as_fn_error $? "thin lto is not supported under gcc compiler." "$LINENO" 5
|
||||
fi
|
||||
LDFLAGS_NOLTO="-fno-lto"
|
||||
case $ac_sys_system in
|
||||
Darwin*)
|
||||
LTOFLAGS="-flto -Wl,-export_dynamic"
|
||||
|
@ -7534,6 +7546,7 @@ fi
|
|||
|
||||
|
||||
|
||||
|
||||
# The -arch flags for universal builds on macOS
|
||||
UNIVERSAL_ARCH_FLAGS=
|
||||
|
||||
|
|
15
configure.ac
15
configure.ac
|
@ -143,8 +143,9 @@ AC_ARG_WITH(
|
|||
if test "$build_python_ver" != "$PACKAGE_VERSION"; then
|
||||
AC_MSG_ERROR(["$with_build_python" has incompatible version $build_python_ver (expected: $PACKAGE_VERSION)])
|
||||
fi
|
||||
dnl use build Python for regeneration, too
|
||||
dnl Build Python interpreter is used for regeneration and freezing.
|
||||
ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
|
||||
PYTHON_FOR_FREEZE="$with_build_python"
|
||||
PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python
|
||||
AC_MSG_RESULT([$with_build_python])
|
||||
], [
|
||||
|
@ -152,17 +153,22 @@ AC_ARG_WITH(
|
|||
[AC_MSG_ERROR([Cross compiling requires --with-build-python])]
|
||||
)
|
||||
PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
|
||||
PYTHON_FOR_FREEZE="./_bootstrap_python"
|
||||
]
|
||||
)
|
||||
AC_SUBST([PYTHON_FOR_BUILD])
|
||||
|
||||
AC_MSG_CHECKING([for Python interpreter freezing])
|
||||
AC_MSG_RESULT([$PYTHON_FOR_FREEZE])
|
||||
AC_SUBST([PYTHON_FOR_FREEZE])
|
||||
|
||||
AC_CHECK_PROGS([PYTHON_FOR_REGEN],
|
||||
[python$PACKAGE_VERSION python3.10 python3.9 python3.8 python3.7 python3.6 python3 python],
|
||||
[python3])
|
||||
AC_SUBST(PYTHON_FOR_REGEN)
|
||||
|
||||
AC_MSG_CHECKING([Python for regen version])
|
||||
if command -v $PYTHON_FOR_REGEN >/dev/null 2>&1; then
|
||||
if command -v "$PYTHON_FOR_REGEN" >/dev/null 2>&1; then
|
||||
AC_MSG_RESULT([$($PYTHON_FOR_REGEN -V 2>/dev/null)])
|
||||
else
|
||||
AC_MSG_RESULT([missing])
|
||||
|
@ -1510,6 +1516,8 @@ esac
|
|||
if test "$Py_LTO" = 'true' ; then
|
||||
case $CC in
|
||||
*clang*)
|
||||
dnl flag to disable lto during linking
|
||||
LDFLAGS_NOLTO="-fno-lto"
|
||||
AC_SUBST(LLVM_AR)
|
||||
AC_PATH_TOOL(LLVM_AR, llvm-ar, '', ${llvm_path})
|
||||
AC_SUBST(LLVM_AR_FOUND)
|
||||
|
@ -1565,6 +1573,8 @@ if test "$Py_LTO" = 'true' ; then
|
|||
then
|
||||
AC_MSG_ERROR([thin lto is not supported under gcc compiler.])
|
||||
fi
|
||||
dnl flag to disable lto during linking
|
||||
LDFLAGS_NOLTO="-fno-lto"
|
||||
case $ac_sys_system in
|
||||
Darwin*)
|
||||
LTOFLAGS="-flto -Wl,-export_dynamic"
|
||||
|
@ -1746,6 +1756,7 @@ fi
|
|||
AC_SUBST(BASECFLAGS)
|
||||
AC_SUBST(CFLAGS_NODIST)
|
||||
AC_SUBST(LDFLAGS_NODIST)
|
||||
AC_SUBST(LDFLAGS_NOLTO)
|
||||
|
||||
# The -arch flags for universal builds on macOS
|
||||
UNIVERSAL_ARCH_FLAGS=
|
||||
|
|
Loading…
Reference in New Issue