]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
pybindings: Fix a build warning on Fedora
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 15 Feb 2023 19:06:33 +0000 (12:06 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 15 Feb 2023 19:06:36 +0000 (12:06 -0700)
While building python bindings on Fedora 34, gcc 11.3.1 triggers a
build warning:
[1/1] Cythonizing libcgroup.pyx
In file included from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/limits.h:26,
                 from /usr/lib/gcc/x86_64-redhat-linux/11/include/limits.h:203,
                 from /usr/lib/gcc/x86_64-redhat-linux/11/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/11/include/limits.h:34,
                 from /usr/include/python3.9/Python.h:11,
                 from libcgroup.c:25:
/usr/include/features.h:397:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  397 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~

the reason being the default compiler flags for c/c++ includes
'-Wp,-D_FORTIFY_SOURCE=2' and '-D_FORTIFY_SOURCE=2'. Whereas Ubuntu
compilers include '-D_FORTIFY_SOURCE=2' option only.  This can be
fixed by adding '-O2' to the CPP Flags in the pybinding Makefile and
there is no side effect in both Fedora and Ubuntu because by default
'-D_FORTIFY_SOURCE=2' is included. The Ubuntu automatically auto
includes '-D_FORTIFY_SOURCE=2' when '-O2' is passed but here it's been
already explicitly passed.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 577d364472701b24a85a1bdadd8ec32b76c45eb5)

src/python/Makefile.am

index 0683d00d67779f3aa5b3513d5179f157e7cc171f..49638ac00f796f9545fe71a5215e6fa3548f863c 100644 (file)
@@ -9,7 +9,7 @@
 
 PY_DISTUTILS = \
        VERSION_RELEASE="@PACKAGE_VERSION@" \
-       CPPFLAGS="-I\${top_srcdir}/include ${AM_CPPFLAGS} ${CPPFLAGS}" \
+       CPPFLAGS="-I\${top_srcdir}/include ${AM_CPPFLAGS} ${CPPLAGS} -O2" \
        CFLAGS="$(CODE_COVERAGE_CFLAGS) ${AM_CFLAGS} ${CFLAGS}" \
        LDFLAGS="$(CODE_COVERAGE_LIBS) ${AM_LDFLAGS} ${LDFLAGS}" \
        ${PYTHON} ${srcdir}/setup.py