xmlsec / python-xmlsec

Python bindings for the XML Security Library.
MIT License
93 stars 97 forks source link

1.3.14: build fails with `-Wincompatible-pointer-types` #323

Open kloczek opened 2 months ago

kloczek commented 2 months ago

With latest glibc when compile is done with -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3x in $CFLAGS some warnings are turned into errors.

/usr/bin/gcc -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -grecord-gcc-switches -pipe -mtls-dialect=gnu2 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdata-sections -ffunction-sections -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -flto=auto -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -D_GNU_SOURCE -fPIC -fwrapv -ffat-lto-objects -fno-semantic-interposition -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -grecord-gcc-switches -pipe -mtls-dialect=gnu2 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdata-sections -ffunction-sections -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -flto=auto -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -D_GNU_SOURCE -fPIC -fwrapv -ffat-lto-objects -fno-semantic-interposition -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -grecord-gcc-switches -pipe -mtls-dialect=gnu2 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdata-sections -ffunction-sections -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -flto=auto -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -fPIC -DXMLSEC_CRYPTO_DYNAMIC_LOADING=1 -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_FTP=1 -DXMLSEC_NO_MD5=1 -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_DL_LIBLTDL=1 -DMODULE_NAME=xmlsec -DMODULE_VERSION=1.3.14 -I/usr/include/xmlsec1 -I/usr/include/libxml2 -I/usr/lib64/python3.10/site-packages/lxml/includes -I/usr/lib64/python3.10/site-packages/lxml -I/usr/lib64/python3.10/site-packages/lxml/includes/__pycache__ -I/usr/include/python3.10 -c /home/tkloczko/rpmbuild/BUILD/python-xmlsec-1.3.14/src/enc.c -o build/temp.linux-x86_64-cpython-310/home/tkloczko/rpmbuild/BUILD/python-xmlsec-1.3.14/src/enc.o -g -std=c99 -fPIC -fno-strict-aliasing -Wno-error=declaration-after-statement -Werror=implicit-function-declaration -Os
/home/tkloczko/rpmbuild/BUILD/python-xmlsec-1.3.14/src/enc.c: In function ‘PyXmlSec_ClearReplacedNodes’:
/home/tkloczko/rpmbuild/BUILD/python-xmlsec-1.3.14/src/enc.c:207:14: error: assignment to ‘struct LxmlElement **’ from incompatible pointer type ‘PyXmlSec_LxmlElementPtr’ {aka ‘struct LxmlElement *’} [-Wincompatible-pointer-types]
  207 |         elem = PyXmlSec_elementFactory(doc, n);
      |              ^
error: command '/usr/bin/gcc' failed with exit code 1
aucampia commented 2 months ago

Setting CFLAGS="-Wno-error=incompatible-pointer-types" in the environment helps.

hroncok commented 2 months ago

Casting the pointer type explicitly also helps https://github.com/xmlsec/python-xmlsec/pull/325