Add -Werror=implicit-function-declaration to AM_CFLAGS
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 8 May 2019 17:50:51 +0000 (13:50 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 9 May 2019 15:17:57 +0000 (11:17 -0400)
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 <francis.deslauriers@efficios.com>
Change-Id: Ia43b4f8c85b6a6cb7557f084a2bed07e7ec043dc
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1278
Tested-by: jenkins
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac

index 9d7e4053d9ffb2ca647c1594c01d451af33fe304..3fe3500fd13541611092723f4d3f2822b4c638c4 100644 (file)
@@ -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
This page took 0.026224 seconds and 4 git commands to generate.