Skip to content

Compilation failure with GCC 15 + Python 3.12: mypyc/lib-rt/pythoncapi_compat.h:41:11: error: ‘_Py_NULL’ redefined [-Werror] #18698

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

Closed
mr-c opened this issue Feb 17, 2025 · 0 comments · Fixed by #18699
Labels
bug mypy got something wrong

Comments

@mr-c
Copy link
Contributor

mr-c commented Feb 17, 2025

Bug Report

Hello, in Debian we are testing the upcoming GCC 15 release, and we found a compilation error when compiling for Python 3.12.

The Debian bug report is at https://bugs.debian.org/1097426

To Reproduce

Compile using GCC 15.x

To build with GCC 15, either set CC=gcc-15 CXX=g++-15 explicitly, or install the gcc, g++, gfortran, ... packages from Debian experimental.

apt-get -t=experimental install g++

GCC 15 now defaults to the C23/C++23 standards, exposing many FTBFS. Other Common build failures are new warnings resulting in build failures with -Werror turned on, or new/dropped symbols in Debian symbols files. For other C/C++ related build failures see the porting guide at http://gcc.gnu.org/gcc-15/porting_to.html

Expected Behavior

Compilation suceeds

Actual Behavior

x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/mypy-1.15.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wno-misleading-indentation -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.12 -c build/mypy/checkmember.c -o build/temp.linux-x86_64-cpython-312/build/mypy/checkmember.o -O3 -g2 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-ignored-optimization-argument -Wno-cpp
In file included from /build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/pythonsupport.h:11,
                 from /build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/CPy.h:12,
                 from /build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/init.c:2,
                 from build/__native_3204bda914b7f2c6f497.c:1:
/build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/pythoncapi_compat.h:41:11: error: ‘_Py_NULL’ redefined [-Werror]
   41 | #  define _Py_NULL nullptr
      |           ^~~~~~~~
In file included from /usr/include/python3.12/Python.h:38,
                 from /build/reproducible-path/mypy-1.15.0/mypyc/lib-rt/init.c:1:
/usr/include/python3.12/pyport.h:32:11: note: this is the location of the previous definition
   32 | #  define _Py_NULL NULL
      |           ^~~~~~~~

Your Environment

  • GCC version: 15-20250213-1
  • Mypy version used: 1.15.0
  • Mypy command-line flags: NA
  • Python version used: 3.12.9
@mr-c mr-c added the bug mypy got something wrong label Feb 17, 2025
x612skm pushed a commit to x612skm/mypy-dev that referenced this issue Feb 24, 2025
…hon#18699)

Fixes: python#18698 

This is a naive fix for the gcc 15 error when compiling for Python 3.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant