python 2.7 compilation failure -Wincompatible-pointer-types using GNU GCC 14 under Gentoo

Author:

main menu
passing argument 1 of Tcl_NewUnicodeObj

Yet another GNU GCC 14 error when building the old Python 2.7.18, which is not supported any more, but still in use in legacy software:

x86_64-pc-linux-gnu-gcc -fPIC -fno-strict-aliasing -march=haswell -O2 -fomit-frame-pointer -pipe -fwrapv -DNDEBUG -DWITH_APPINIT=1 -DWITH_BLT=1 -I/usr/X11R6/include -I. -IInclude -I./Include -I/usr/local/include -I/var/tmp/portage/dev-lang/python-2.7.18_p16-r2/work/Python-2.7.18/Include -I/var/tmp/portage/dev-lang/python-2.7.18_p16-r2/work/Python-2.7.18 -c /var/tmp/portage/dev-lang/python-2.7.18_p16-r2/work/Python-2.7.18/Modules/_tkinter.c -o build/temp.linux-x86_64-2.7/var/tmp/portage/dev-lang/python-2.7.18_p16-r2/work/Python-2.7.18/Modules/_tkinter.o
/var/tmp/portage/dev-lang/python-2.7.18_p16-r2/work/Python-2.7.18/Modules/_tkinter.c: In function 'AsObj':
/var/tmp/portage/dev-lang/python-2.7.18_p16-r2/work/Python-2.7.18/Modules/_tkinter.c:1178:38: error: passing argument 1 of 'Tcl_NewUnicodeObj' from incompatible pointer type [-Wincompatible-pointer-types]
 1178 |             return Tcl_NewUnicodeObj(inbuf, size);
      |                                      ^~~~~
      |                                      |
      |                                      Py_UNICODE * {aka unsigned int *}

In version 14 of GNU GCC has been decided to throw an error by default (with standard >=C99) when there is a warning -Wincompatible-pointer-types. Some of the old software is not ready for such implementation, so using the older GNU GCC like version 13 or suppressing the error with CFLAGS=”-Wno-error=incompatible-pointer-types” should fix the error to warning and the compilation would not be interrupted.
Probably the code in the legacy Python 2.7 branch wouldn’t be fixed, so there are some work-around, which my be used:

1) Just use older than version 14 of NU GCC

Under Gentoo just switch back for this package to older GNU GCC with gcc-config tool:

srv ~ # gcc-config -l
 [1] x86_64-pc-linux-gnu-10.3.0
 [2] x86_64-pc-linux-gnu-11.3.0
 [3] x86_64-pc-linux-gnu-12
 [4] x86_64-pc-linux-gnu-13
 [5] x86_64-pc-linux-gnu-14 *
srv ~ # gcc-config x86_64-pc-linux-gnu-13
 * Switching native-compiler to x86_64-pc-linux-gnu-13 ...
>>> Regenerating /etc/ld.so.cache...

 * If you intend to use the gcc from the new profile in an already
 * running shell, please remember to do:

 *   . /etc/profile

srv ~ # . /etc/profile
srv ~ # emerge -v "<python-3"

List all available versions, select an older than 14 and reload the profile environments and then emerge the package. The compilation phase will only output a warning and package will be built and installed on the system.

2)Change the CFLAGS environment in Gentoo’s make.conf to not interpret the incompatible-pointer-types as an error.

If no older GNU GCC version is available just edit the CFLAGS to add “-Wno-error=incompatible-pointer-types” in /etc/portage/make.conf.

3) Change the CFLAGS environment variables only for the current package.

It is possible to tune the CFLAGS per a package by adding them before the emerge command, too:

srv ~ # CFLAGS="$CFLAGS -Wno-error=incompatible-pointer-types" emerge "<python-3"

The above line builds successfully the Python 2.7.18 with GNU GCC 14, because it interprets the incompatible-pointer-types as a warning not error.

This case is similar to mplayer 1.5 compilation failure -Wincompatible-pointer-types using GNU GCC 14 under Gentoo.

Leave a Reply

Your email address will not be published. Required fields are marked *