From: Francis Deslauriers Date: Wed, 8 May 2019 17:50:51 +0000 (-0400) Subject: Add -Werror=implicit-function-declaration to AM_CFLAGS X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=f9ddd0995e0b879f9b592e398d37bd1273a0ccb7 Add -Werror=implicit-function-declaration to AM_CFLAGS Implicit declaration of function is most likely always a bad thing. Implicit declaration of function is particularly problematic with Babeltrace 2 because of its plugin system. Currently, when building a plugin shared object, the compiler issues a warning when it encounters an implicit declaration but will create the .so just fine but with the implicit function marked as undefined, as expected by the standard prior to C99. When trying to load a Babeltrace plugin with an undefined symbol, glib's `g_module_open()` fails and Babeltrace then considers that this .so is not a valid Babeltrace plugin. A failure to load a plugin is not a error because we want Babeltrace to be able to list/use every plugins in a given directory by looking at every .so file. So we can't simply return an error in those cases. Since Babeltrace marks plugins with undefined symbols as invalid they can't be used in a graph. This problem is caused when a typo in a function name finds its way into the code and a warning message is ignored. It can also happen when the code uses a function of more recent library than what is currently installed on the system. So, to ensure this never happens, we promote the `-Wimplicit-function-declaration` warning to the rank of compilation error. This is diagnostic has been supported by GCC since v4.8 and Clang since v4 at least so we believe it's safe to enable it by default. Signed-off-by: Francis Deslauriers Change-Id: Ia43b4f8c85b6a6cb7557f084a2bed07e7ec043dc Reviewed-on: https://review.lttng.org/c/babeltrace/+/1278 Tested-by: jenkins Reviewed-by: Jérémie Galarneau --- diff --git a/configure.ac b/configure.ac index 9d7e4053..3fe3500f 100644 --- a/configure.ac +++ b/configure.ac @@ -675,7 +675,7 @@ AC_SUBST(LIBDIR) # Set global CFLAGS in AM_CFLAGS -AM_CFLAGS="-Wall -Wformat $PTHREAD_CFLAGS $GLIB_CFLAGS" +AM_CFLAGS="-Wall -Wformat -Werror=implicit-function-declaration $PTHREAD_CFLAGS $GLIB_CFLAGS" AC_SUBST(AM_CFLAGS) # Set global CPPFLAGS in AM_CPPFLAGS