Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Consider removing some unused build flags #144228

Open
Labels
buildThe build process and cross-build
@johnslavik

Description

@johnslavik

Description

Tripped up by--with-readline in our configure file while debuggingGH-142353, I was curious if we have any other unused build flags.

Removing them could slightly shorten preprocessing work, reduce cognitive load when debugging platform‑specific issues, and reduce the risk of accidentally relying on dead configuration paths.

After runningmake regen-configure, I put together this script withripgrep:

# t.shFLAGS="$(rg'#\s*define\s+(\w+)' -g pyconfig.h -g pyconfig.h.in -or'$1' --no-line-number --no-filename)"forflagin$FLAGSdo        rg"\b$flag\b" -g!pyconfig.h -g!pyconfig.h.in. --stats| rg'\b0 matches' -r"$flag"done

Then I ran this command:

bash t.sh| sort| uniq

I got the following results:

Expand results
DIRENTDONT_HAVE_SIG_ALARMDONT_HAVE_SIG_PAUSEHAVE_ACOSHHAVE_ASINHHAVE_ATANHHAVE_ERFHAVE_ERFCHAVE_EXPM1HAVE_INTPTR_THAVE_LIBSOCKETHAVE_LOG1PHAVE_LOG2HAVE_PUTENVHAVE_STRERRORHAVE_UINTPTR_THAVE_X509_VERIFY_PARAM_SET1_HOSTPy_CONFIG_HPy_NTDDI_Py_PASTE_VERSIONPy_SOCKET_FD_CAN_BE_GE_FD_SETSIZE_Py_STRINGIZE_Py_STRINGIZE1SIZEOF_HKEYUSE_SOCKET_W64WITH_READLINEWORD_BIT

These macros are not referenced by any CPython source files outside configuration headers (pyconfig.h,PC/pyconfig.h andpyconfig.h.in files) and are not part of the documented public API.

A few of them are actually used and cannot be removed. Most of them, however, weren't used in years (or decades) and appear to be safely removable, because they no longer affect the behavior of Python.

Here's what I found about every single one of them.

PC/pyconfig.h and pyconfig.h

  • HAVE_ERF,HAVE_ERFC

    Unused since5839575.

PC/pyconfig.h

pyconfig.h

  • HAVE_ACOSH,HAVE_ASINH,HAVE_ATANH,HAVE_EXPM1,HAVE_LOG1P

    Unused sincefa26245.

  • HAVE_LOG2

    Unused since5839575.

Ambiguous

Not touching these before I get additional feedback.
Consider them out of the scope of my proposal for now!

  • HAVE_INTPTR_T,HAVE_UINTPTR_T (PC/pyconfig.h)

    Added infe393f4, never used since. Maybe it's intentionally reserved for future use?

    cc:@zooba,@loewis, can this be removed?

  • Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE (PC/pyconfig.h)

    Allowing this seems to have caused a stack corruption fixed inaa26b27. Since the fix, the flag has not been used.

    cc:@zooba,@cf-natali, can this be removed?

  • WORD_BIT (PC/pyconfig.h)

    Standardized by POSIX.1 (IEEE Std 1003.1).

    Not sure if it should be in PC/.
    Maybe it is used downstream?

    cc:@zooba,@mhammond, do we need this in PC/pyconfig.h?

Still used or won't fix

  • Py_CONFIG_H (PC/pyconfig.h)

    This was identified by the script, but it's an include guard.

  • _W64 (PC/pyconfig.h)

    Used in PC/pyconfig.h to definePy_ssize_t.

  • Py_NTDDI (PC/pyconfig)

    Used for definingNTDDI_VERSION.

  • _Py_PASTE_VERSION (PC/pyconfig.h)

    Used for defining_Py_COMPILER.

  • _Py_STRINGIZE,_Py_STRINGIZE1 (PC/pyconfig.h)

    I'd not touch these, as they are used for defining_Py_COMPILER.
    These correspond toPy_STRINGIFY and_Py_XSTRINGIFY from the pymacro.h header.
    MakingPC/pyconfig.h include pymacro.h just forPy_STRINGIFY doesn't seem like a sensible option.

Conclusion

I'm going to start from PRs one per every item (grouping one or more related macros) in the bullet lists of flags certainly removable.

Going forward, I'll appreciate feedback about the ambiguous flags or any things that I've overlooked.

Are there any flags listed for removal that still have known downstream or platform‑specific uses? I pinged some changeset authors to help decide the most ambiguous cases.

Finally, I considered adding automated checks for unused configuration macros, but given the amount of variables involved, this seems non-trivial and not worth it.

Thanks for reading through all of this!

cc@vstinner@encukou I think you will have useful insights into this one.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-build

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp