[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 3/3] maint: Avoid -Ignulib on standalone examples

Travis shows that clang (but not gcc) fails to build after our
recent gnulib updates, due to:

  CC       domtop/domtop.o
In file included from dommigrate/dommigrate.c:26:
In file included from ../gnulib/lib/stdlib.h:100:
In file included from ../gnulib/lib/unistd.h:40:
In file included from /usr/include/unistd.h:638:
In file included from ../gnulib/lib/sys/select.h:110:
In file included from ../gnulib/lib/signal.h:67:
../gnulib/lib/pthread.h:74:3: error: "Please include config.h first."
 #error "Please include config.h first."

This probably stems from gcc and clang having a subtle difference in
-isystem vs. -I include behaviors on #include_next, where that difference
then results in clang trying to pick up same-named gnulib headers merely
because their directory was in the search path, while gcc did not hit
that problem.

But for our examples that are intended to be standalone, we want to
work with the bare-bones libc, without any interference from our
<config.h> or from gnulib.  The easiest way to do that is by using
per-binary CPPFLAGS, and including gnulib headers only for example
binaries that still use <config.h>.

Signed-off-by: Eric Blake <eblake redhat com>

I don't have a local clang setup, so I'm relying on CI testing to
prove whether this fixes the build failures that Travis reported...
 examples/Makefile.am | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/Makefile.am b/examples/Makefile.am
index 61cf2af4a5..d85e1d5ace 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -34,7 +34,8 @@ EXTRA_DIST = \

-	-I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir) \
+	-I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)
 	-I$(top_builddir)/gnulib/lib -I$(top_srcdir)/gnulib/lib
 	$(top_builddir)/src/libvirt.la $(top_builddir)/gnulib/lib/libgnu.la \
@@ -49,13 +50,16 @@ noinst_PROGRAMS=dominfo/info1 dommigrate/dommigrate domsuspend/suspend \
 dominfo_info1_SOURCES = dominfo/info1.c
 dommigrate_dommigrate_SOURCES = dommigrate/dommigrate.c
 domsuspend_suspend_SOURCES = domsuspend/suspend.c
+domsuspend_suspend_CPPFLAGS = $(AM_CPPFLAGS) $(GNULIB_CPPFLAGS)
 domtop_domtop_SOURCES = domtop/domtop.c
 hellolibvirt_hellolibvirt_SOURCES = hellolibvirt/hellolibvirt.c

 object_events_event_test_CFLAGS = \
 object_events_event_test_SOURCES = object-events/event-test.c
+object_events_event_test_CPPFLAGS = $(AM_CPPFLAGS) $(GNULIB_CPPFLAGS)

 openauth_openauth_SOURCES = openauth/openauth.c
 rename_rename_SOURCES = rename/rename.c
@@ -67,6 +71,7 @@ admin_client_limits_SOURCES = admin/client_limits.c
 admin_client_info_SOURCES = admin/client_info.c
 admin_client_close_SOURCES = admin/client_close.c
 admin_logging_SOURCES = admin/logging.c


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]