From 622d120665858246520982b81f59f9723fe6fa47 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 30 Oct 2019 15:20:20 -0400 Subject: [PATCH] Ignore -Wcast-function-type warning MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We get this when building on CentOS 8: bt2/native_bt.c:1819:23: error: cast between incompatible function types from ‘PyObject * (*)(PyObject *)’ {aka ‘struct _object * (*)(struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Werror=cast-function-type] {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, ^ bt2/native_bt.c:1820:23: error: cast between incompatible function types from ‘PyObject * (*)(PyObject *)’ {aka ‘struct _object * (*)(struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Werror=cast-function-type] {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, ^ bt2/native_bt.c:1823:23: error: cast between incompatible function types from ‘PyObject * (*)(PyObject *)’ {aka ‘struct _object * (*)(struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Werror=cast-function-type] {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, ^ bt2/native_bt.c:1824:23: error: cast between incompatible function types from ‘PyObject * (*)(SwigPyObject *)’ {aka ‘struct _object * (*)(struct *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Werror=cast-function-type] {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, ^ See comment in configure.ac for detailed explanation. It would have been nice to just disable it when building native_bt.c, but I am not sure how to do that in a way that's compatible with all compilers and that is not overly complicated. So let's just disable it globally for now. Change-Id: Iae5c5b6d96978f00e8b19098a438c60817226393 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2309 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- configure.ac | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure.ac b/configure.ac index 9e95aee5..79d98950 100644 --- a/configure.ac +++ b/configure.ac @@ -673,6 +673,19 @@ AX_COMPILER_FLAGS( -Wno-format-nonliteral dnl -Wno-double-promotion dnl -Wno-cast-align dnl + dnl + dnl Some versions of SWIG (like 3.0.12) generate code that produces + dnl -Wcast-function-type warnings. This warning is present in gcc >= 8. This + dnl combo happens on RHEL/Centos 8, for example. Later versions of SWIG (like + dnl 4.0.1) have the correct function signatures to not produce this warning. + dnl It's simpler to just disable the warning globally. + dnl + dnl Note that the Debian/Ubuntu SWIG package 3.0.12-2 contains a local patch to + dnl fix this (python-fix-function-cast-warnings.patch), so you won't be able to + dnl reproduce the warning using that package. + dnl + dnl Ref: https://github.com/swig/swig/issues/1259 + -Wno-cast-function-type dnl ]) # CFLAGS from AX_COMPILER_FLAGS. -- 2.34.1