pylzma icon indicating copy to clipboard operation
pylzma copied to clipboard

Fails to build with GCC 14 due to -Wdeprecated-declarations

Open glaubitz opened this issue 1 year ago • 1 comments

Trying to build pylzma with GCC 14 fails with:

[   13s]   gcc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -DPY_SSIZE_T_CLEAN=1 -DWITH_COMPAT=1 -DPYLZMA_VERSION=0.5.0 -D_7ZIP_ST=1 -Isrc/sdk/C -I/usr/include/python3.10 -c src/compat/LzmaCompatDecode.c -o build/temp.linux-x86_64-cpython-310/src/compat/LzmaCompatDecode.o
[   14s]   gcc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -DPY_SSIZE_T_CLEAN=1 -DWITH_COMPAT=1 -DPYLZMA_VERSION=0.5.0 -D_7ZIP_ST=1 -Isrc/sdk/C -I/usr/include/python3.10 -c src/pylzma/pylzma.c -o build/temp.linux-x86_64-cpython-310/src/pylzma/pylzma.o
[   14s]   src/pylzma/pylzma.c: In function ‘PyInit_pylzma’:
[   14s]   src/pylzma/pylzma.c:296:5: warning: ‘PyEval_InitThreads’ is deprecated [-Wdeprecated-declarations]
[   14s]     296 |     PyEval_InitThreads();
[   14s]         |     ^~~~~~~~~~~~~~~~~~
[   14s]   In file included from /usr/include/python3.10/Python.h:130,
[   14s]                    from src/pylzma/pylzma.c:26:
[   14s]   /usr/include/python3.10/ceval.h:122:37: note: declared here
[   14s]     122 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
[   14s]         |                                     ^~~~~~~~~~~~~~~~~~
[   14s]   gcc -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -IVendor/ -fPIC -DPY_SSIZE_T_CLEAN=1 -DWITH_COMPAT=1 -DPYLZMA_VERSION=0.5.0 -D_7ZIP_ST=1 -Isrc/sdk/C -I/usr/include/python3.10 -c src/pylzma/pylzma_aes.c -o build/temp.linux-x86_64-cpython-310/src/pylzma/pylzma_aes.o
[   14s]   src/pylzma/pylzma_aes.c:158:5: error: initialization of ‘long int’ from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
[   14s]     158 |     NULL,                                /* printfunc  tp_print;   */
[   14s]         |     ^~~~
[   14s]   src/pylzma/pylzma_aes.c:158:5: note: (near initialization for ‘CAESDecrypt_Type.tp_vectorcall_offset’)
[   14s]   error: command '/usr/bin/gcc' failed with exit code 1
[   14s]   error: subprocess-exited-with-error
[   14s]   
[   14s]   × Building wheel for pylzma (pyproject.toml) did not run successfully.
[   14s]   │ exit code: 1
[   14s]   ╰─> See above for output.
[   14s]   
[   14s]   note: This error originates from a subprocess, and is likely not a problem with pip.
[   14s]   full command: /usr/bin/python3.10 /usr/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmpdhloe_ms
[   14s]   cwd: /home/abuild/rpmbuild/BUILD/pylzma-0.5.0
[   14s]   Building wheel for pylzma (pyproject.toml): finished with status 'error'
[   14s]   ERROR: Failed building wheel for pylzma

To reproduce the error, build pylzma with GCC 14 as the default C/C++ compiler.

glaubitz avatar Jun 05 '24 11:06 glaubitz

I hit this error as well, on macOS with clang 16.

src/pylzma/pylzma_aes.c:158:5: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]

I get the error on python versions lower than 12. On python 12, pylzma installs without errors or warnings (well, except the deprecation warning about legacy 'setup.py install' method).

On affected python versions, a workaround exists:

CFLAGS=-Wno-int-conversion pip install pylzma

mawbid avatar Sep 24 '24 12:09 mawbid