Skip to content

Commit 15a4576

Browse files
gpsheadmiss-islington
authored andcommitted
pythongh-157142: Fix linking _freeze_module with built-in test modules (pythonGH-157143)
Programs/_freeze_module is linked with Modules/getpath_noop.o rather than Modules/getpath.o, and getpath_noop.c only defined _PyConfig_InitPathConfig(). With MODULE_BUILDTYPE=static (the default on wasm), _testinternalcapi.o is part of LIBRARY_OBJS_OMIT_FROZEN and its get_getpath_codeobject() left _Py_Get_Getpath_CodeObject() as an undefined reference. Define a stub for it. (cherry picked from commit c8da735) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
1 parent 1c5df82 commit 15a4576

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix the link of ``Programs/_freeze_module`` when extension modules are built
2+
in (``MODULE_BUILDTYPE=static``) and the test modules are enabled:
3+
``Modules/getpath_noop.c`` now defines ``_Py_Get_Getpath_CodeObject()``,
4+
which ``_testinternalcapi`` uses.

Modules/getpath_noop.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
/* Implements the getpath API for compiling with no functionality */
22

33
#include "Python.h"
4-
#include "pycore_pathconfig.h"
4+
#include "pycore_initconfig.h" // _Py_Get_Getpath_CodeObject()
5+
#include "pycore_pathconfig.h" // _PyConfig_InitPathConfig()
56

67
PyStatus
78
_PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
89
{
910
return PyStatus_Error("path configuration is unsupported");
1011
}
12+
13+
/* Used by _testinternalcapi, which is linked into Programs/_freeze_module
14+
when extension modules are built in (MODULE_BUILDTYPE=static). */
15+
PyObject *
16+
_Py_Get_Getpath_CodeObject(void)
17+
{
18+
PyErr_SetString(PyExc_RuntimeError,
19+
"path configuration is unsupported");
20+
return NULL;
21+
}

0 commit comments

Comments
 (0)