Skip to content

_MIPS_SIM comparison may contain undefined identifiers for _ABI #132026

Closed

Description

@sigv

Bug report

Bug description:

#include <Python.h>

When built on a MIPS architecture, _MIPS_SIM is used to determine architecture specifics. The value is expected to match either _ABIO32, _ABIN32 or _ABI64.

In gcc config/mips/mips.h these values are defined as compiler builtin_define inside of a switch/case. That means, mips64el and mips64 architectures know about _ABI64 but don't know about _ABIO32 and _ABIN32. In turn, when CPython tries to use them in comparison, they may be undefined identifiers.

In default compiler behavior, the undefined identifier will be evaluated as zero, and it will not match _MIPS_SIM. However, the issues pop up when -Wundef (or, even worse, -Werror=undef) compiler flag is enabled. Then suddenly it's visible as a warning or error:

In file included from /usr/include/python3.13/Python.h:14,
                 from example.c:1:
/usr/include/python3.13/pyconfig.h:59:20: error: "_ABIO32" is not defined, evaluates to 0 [-Werror=undef]
   59 | #  if _MIPS_SIM == _ABIO32
      |                    ^~~~~~~
/usr/include/python3.13/pyconfig.h:61:22: error: "_ABIN32" is not defined, evaluates to 0 [-Werror=undef]
   61 | #  elif _MIPS_SIM == _ABIN32
      |                      ^~~~~~~

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Apr 2, 2025
  2. added 2 commits that reference this issue on Apr 2, 2025
  3. added
    buildThe build process and cross-build
    on Apr 4, 2025
  4. added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    and removed
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    on Apr 4, 2025
  5. added 2 commits that reference this issue on Apr 6, 2025
  6. sigv commented on Apr 6, 2025

    @sigv
    ContributorAuthor

    This should be added to Platform: MIPS on Unsupported platforms board.

  7. added a commit that references this issue on Apr 6, 2025
  8. added a commit that references this issue on Apr 14, 2025
  9. added a commit that references this issue on Apr 27, 2025
  10. added a commit that references this issue on Apr 28, 2025
  11. added a commit that references this issue on Apr 28, 2025
  12. zware commented on Apr 28, 2025

    @zware
    Member

    Merged and backported; thanks for the report and patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-unsupportedbuildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions