Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Python with -Wundef: don't use undefined macros #90828

Closed
vstinner opened this issue Feb 6, 2022 · 14 comments
Closed

Build Python with -Wundef: don't use undefined macros #90828

vstinner opened this issue Feb 6, 2022 · 14 comments
Labels
3.11 only security fixes build The build process and cross-build

Comments

@vstinner
Copy link
Member

vstinner commented Feb 6, 2022

BPO 46670
Nosy @vstinner, @markshannon
PRs
  • bpo-46670: Define all macros for stringlib #31176
  • bpo-46670: Remove unused get_frame_state() function #31177
  • bpo-46670: Test if a macro is defined, not its value #31178
  • bpo-46670: Fix #ifdef WORDS_BIGENDIAN in audioop.c #31179
  • bpo-46670: Fix #ifdef in sha3module.c #31180
  • bpo-46670: Remove unused macros in the Python directory #31192
  • bpo-46670: Remove unused macros in the Objects directory #31193
  • bpo-46670: Remove unused macros in the Modules directory #31194
  • bpo-46670: Remove unused macros in ceval.c #31196
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2022-02-06.23:52:36.108>
    labels = ['build', '3.11']
    title = "Build Python with -Wundef: don't use undefined macros"
    updated_at = <Date 2022-02-07.15:22:33.054>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2022-02-07.15:22:33.054>
    actor = 'vstinner'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Build']
    creation = <Date 2022-02-06.23:52:36.108>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46670
    keywords = ['patch']
    message_count = 10.0
    messages = ['412690', '412695', '412696', '412697', '412746', '412753', '412755', '412756', '412757', '412758']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'Mark.Shannon']
    pr_nums = ['31176', '31177', '31178', '31179', '31180', '31192', '31193', '31194', '31196']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46670'
    versions = ['Python 3.11']

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 6, 2022

    Building Python with "gcc -Wundef" emits many warnings about usage of undefined macros. If a macro is not defined, it is equal to 0.

    The problem is that a macro can be undefined because of a missing #include, or because of a typo in its name, or because "#ifdef MACRO" should be used instead of "#if MACRO". It can hide bugs.

    I plan to fix these warnings.

    @vstinner vstinner added 3.11 only security fixes build The build process and cross-build labels Feb 6, 2022
    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 7, 2022

    New changeset 16f96a4 by Victor Stinner in branch 'main':
    bpo-46670: Remove unused get_frame_state() function (GH-31177)
    16f96a4

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 7, 2022

    New changeset 097f74a by Victor Stinner in branch 'main':
    bpo-46670: Define all macros for stringlib (GH-31176)
    097f74a

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 7, 2022

    New changeset b556f53 by Victor Stinner in branch 'main':
    bpo-46670: Test if a macro is defined, not its value (GH-31178)
    b556f53

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 7, 2022

    -Wexpansion-to-defined and -Wunused-macros options are also interesting.

    @markshannon
    Copy link
    Member

    New changeset 4b603f6 by Victor Stinner in branch 'main':
    bpo-46670: Remove unused macros in ceval.c (GH-31196)
    4b603f6

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 7, 2022

    New changeset 4f1d3f3 by Victor Stinner in branch 'main':
    bpo-46670: Remove unused macros in the Modules directory (GH-31194)
    4f1d3f3

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 7, 2022

    New changeset 7603491 by Victor Stinner in branch 'main':
    bpo-46670: Remove unused macros in the Objects directory (GH-31193)
    7603491

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 7, 2022

    New changeset 7d8b69e by Victor Stinner in branch 'main':
    bpo-46670: Remove unused macros in the Python directory (GH-31192)
    7d8b69e

    @vstinner
    Copy link
    Member Author

    vstinner commented Feb 7, 2022

    New changeset f20ca76 by Victor Stinner in branch 'main':
    bpo-46670: Fix #ifdef in sha3module.c (GH-31180)
    f20ca76

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @bedevere-bot
    Copy link

    GH-98674 is a backport of this pull request to the 3.10 branch.

    1 similar comment
    @bedevere-bot
    Copy link

    GH-98674 is a backport of this pull request to the 3.10 branch.

    @bedevere-bot
    Copy link

    GH-98677 is a backport of this pull request to the 3.10 branch.

    @vstinner
    Copy link
    Member Author

    I fixed the usage of undefined macros, but I failed to find time to add -Wundef in the configure script. I'm always scared by modifying the Python build scripts which can break some platforms. If someone wants to add this compiler flag, please go ahead. I prefer to close this issue for now.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants