Skip to content

Builtin modules can't depend on build-helper output because _freeze_module links every static module #160689

Open

Description

@itamaro

Feature or enhancement

On POSIX, Programs/_freeze_module and _bootstrap_python are linked with $(LIBRARY_OBJS_OMIT_FROZEN), which includes $(MODOBJS): every static module from every Setup file, including Modules/Setup.local and (with MODULE_BUILDTYPE=static) all of Setup.stdlib. The only objects left out vs. the final libpython are Python/frozen.o and, for _freeze_module, Modules/getpath.o.

So a builtin module can't depend on anything produced by the build helpers:

  • If its source includes a header generated by $(FREEZE_MODULE), make reports a circular dependency and the module fails to compile because the header doesn't exist yet.
  • If it references a symbol from Modules/getpath.o (e.g. _Py_Get_Getpath_CodeObject()), linking _freeze_module fails, since that binary gets getpath_noop.o instead.

We even have a workaround for the second case - getpath_noop.c stubs _Py_Get_Getpath_CodeObject() purely so that _testinternalcapi links into _freeze_module under MODULE_BUILDTYPE=static.

Windows doesn't have this problem: PCbuild/_freeze_module.vcxproj compiles a fixed list of sources with PC/config_minimal.c.

Proposed fix: link the helpers with the core objects plus the Modules/Setup.bootstrap modules only, i.e. the POSIX equivalent of config_minimal.c.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. self-assigned this
    on Oct 26, 2026
  2. added
    type-featureA feature request or enhancement
    buildThe build process and cross-build
    on Oct 26, 2026
  3. added a commit that references this issue on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buildThe build process and cross-buildtype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions