[libvirt] [PATCH v3] Makefile: Fix parallel build after Xen-xl parser introduction

Well, the parallel build doesn't work as there are not dependencies set correctly. When running 'make -j' I see this error: make[2]: Entering directory '/home/zippy/work/libvirt/libvirt.git/src' GEN util/virkeymaps.h GEN locking/lock_protocol.h make[2]: *** No rule to make target 'xenconfig/xen_xl_disk.h', needed by 'all'. Stop. make[2]: *** Waiting for unfinished jobs.... GEN lxc/lxc_controller_dispatch.h The fix is to correctly set dependencies by letting make know that .c and .h are to be generated from .l. Moreover, the section is moved closer to the other section which uses it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/Makefile.am | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c6d736e..6e5f9c3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1000,23 +1000,6 @@ CPU_SOURCES = \ VMX_SOURCES = \ vmx/vmx.c vmx/vmx.h -AM_LFLAGS = -Pxl_disk_ --header-file=../$*.h -LEX_OUTPUT_ROOT = lex.xl_disk_ -BUILT_SOURCES += xenconfig/xen_xl_disk.c xenconfig/xen_xl_disk.h -# Generated header file is not implicitly added to dist -EXTRA_DIST += xenconfig/xen_xl_disk.h -CLEANFILES += xenconfig/xen_xl_disk.h xenconfig/xen_xl_disk.c - -XENXLDISKPARSER_SOURCES = xenconfig/xen_xl_disk.l - -XENCONFIG_SOURCES = \ - xenconfig/xenxs_private.h \ - xenconfig/xen_common.c xenconfig/xen_common.h \ - xenconfig/xen_sxpr.c xenconfig/xen_sxpr.h \ - xenconfig/xen_xm.c xenconfig/xen_xm.h \ - xenconfig/xen_xl.c xenconfig/xen_xl.h \ - xenconfig/xen_xl_disk.h - pkgdata_DATA = cpu/cpu_map.xml EXTRA_DIST += $(pkgdata_DATA) @@ -1070,6 +1053,31 @@ libvirt_vmx_la_SOURCES = $(VMX_SOURCES) endif WITH_VMX if WITH_XENCONFIG +# Disable the default rule for lex files because we need to generete the +# xen_xl_disk files into srcdir instread of builddir. +.l.c: + +$(XENXLDISKPARSER_GENERATED): $(XENXLDISKPARSER_SOURCES) + $(AM_V_LEX) $(SHELL) $(YLWRAP) $< lex.xl_disk_.c \ + $(abs_srcdir)/xenconfig/xen_xl_disk.c -- $(LEXCOMPILE) + +AM_LFLAGS = -Pxl_disk_ --header-file=$(abs_srcdir)/xenconfig/xen_xl_disk.h +XENXLDISKPARSER_GENERATED = xenconfig/xen_xl_disk.c xenconfig/xen_xl_disk.h + +BUILT_SOURCES += $(XENXLDISKPARSER_GENERATED) +EXTRA_DIST += $(XENXLDISKPARSER_GENERATED) +MAINTAINERCLEANFILES += $(XENXLDISKPARSER_GENERATED) + +XENXLDISKPARSER_SOURCES = xenconfig/xen_xl_disk.l + +XENCONFIG_SOURCES = \ + xenconfig/xenxs_private.h \ + xenconfig/xen_common.c xenconfig/xen_common.h \ + xenconfig/xen_sxpr.c xenconfig/xen_sxpr.h \ + xenconfig/xen_xm.c xenconfig/xen_xm.h \ + xenconfig/xen_xl.c xenconfig/xen_xl.h \ + xenconfig/xen_xl_disk_i.h + # Flex generated XL disk parser needs to be compiled without WARN_FLAGS # Add the generated object to its own library to control CFLAGS noinst_LTLIBRARIES += libvirt_xenxldiskparser.la @@ -1077,6 +1085,8 @@ libvirt_xenxldiskparser_la_CFLAGS = \ -I$(top_srcdir)/src/conf $(AM_CFLAGS) -Wno-unused-parameter libvirt_xenxldiskparser_la_SOURCES = \ $(XENXLDISKPARSER_SOURCES) +libvirt_xenxldiskparser_la_DEPENDENCIES = \ + $(XENXLDISKPARSER_GENERATED) noinst_LTLIBRARIES += libvirt_xenconfig.la libvirt_la_BUILT_LIBADD += libvirt_xenconfig.la -- 2.0.5

On 01/07/2015 10:17 AM, Pavel Hrdina wrote:
Well, the parallel build doesn't work as there are not dependencies set correctly. When running 'make -j' I see this error:
make[2]: Entering directory '/home/zippy/work/libvirt/libvirt.git/src' GEN util/virkeymaps.h GEN locking/lock_protocol.h make[2]: *** No rule to make target 'xenconfig/xen_xl_disk.h', needed by 'all'. Stop. make[2]: *** Waiting for unfinished jobs.... GEN lxc/lxc_controller_dispatch.h
The fix is to correctly set dependencies by letting make know that .c and .h are to be generated from .l. Moreover, the section is moved closer to the other section which uses it.
Still not working for me in VPATH, and I still haven't figured out why... :) Meanwhile, since we are NOT storing the generated files in git, we have a choice: 1. the generated files should be part of the tarball (and generate them into srcdir, not builddir, which makes this patch's attempts to override automake's rules wrong) 2. the generated files should NOT be part of the tarball, and users that want to build the xen drivers MUST have flex installed locally (GNU coding standards discourage this, but we already require users to install GNU make locally, which is also against GNU coding standards) I'd lean towards 1 (which is part of why I'm not sure I like this patch, but what is also taking me time to come up with an alternative), but can live with 2 if we get it working. But observe what happens right now if you don't have flex. Configure succeeds, then make fails: LEX xenconfig/xen_xl_disk.c /home/eblake/libvirt/build-aux/missing: line 81: flex: command not found WARNING: 'flex' is missing on your system. You should only need it if you modified a '.l' file. You may want to install the Fast Lexical Analyzer package: <http://flex.sourceforge.net/> I'd MUCH rather that we fix things to fail at configure time if flex is not installed but xen must be built rather than delaying failure to make time (or put another way, if flex is not present and xen is not explicitly requested, then configure should default to not attempting xen). It probably also means that we need to update bootstrap.conf (especially if we go with option 1, to make sure developers can produce a working tarball) and/or config.spec (to make sure rpms can build xen parts for Fedora) to require flex. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 01/07/2015 02:08 PM, Eric Blake wrote:
On 01/07/2015 10:17 AM, Pavel Hrdina wrote:
Well, the parallel build doesn't work as there are not dependencies set correctly. When running 'make -j' I see this error:
make[2]: Entering directory '/home/zippy/work/libvirt/libvirt.git/src' GEN util/virkeymaps.h GEN locking/lock_protocol.h make[2]: *** No rule to make target 'xenconfig/xen_xl_disk.h', needed by 'all'. Stop. make[2]: *** Waiting for unfinished jobs.... GEN lxc/lxc_controller_dispatch.h
The fix is to correctly set dependencies by letting make know that .c and .h are to be generated from .l. Moreover, the section is moved closer to the other section which uses it.
Still not working for me in VPATH, and I still haven't figured out why... :)
The error I got this time was: CC xenconfig/libvirt_xenconfig_la-xen_xl.lo ../../src/xenconfig/xen_xl.c:29:25: fatal error: xen_xl_disk.h: No such file or directory #include "xen_xl_disk.h" ^ compilation terminated. CC xenconfig/libvirt_xenxldiskparser_la-xen_xl_disk.lo but that may be an issue with me starting from a dirty build (make has the annoying habit of treating a target as up-to-date if the file exists in srcdir, even if you have rewritten the makefile to generate the file only into builddir). I'll try again from a fresh clone. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 01/07/2015 02:43 PM, Eric Blake wrote:
CC xenconfig/libvirt_xenconfig_la-xen_xl.lo ../../src/xenconfig/xen_xl.c:29:25: fatal error: xen_xl_disk.h: No such file or directory #include "xen_xl_disk.h" ^ compilation terminated. CC xenconfig/libvirt_xenxldiskparser_la-xen_xl_disk.lo
but that may be an issue with me starting from a dirty build (make has the annoying habit of treating a target as up-to-date if the file exists in srcdir, even if you have rewritten the makefile to generate the file only into builddir). I'll try again from a fresh clone.
It appears I hit a separate issue, and that your builds don't have xenconfig enabled while mine do. I've posted an independent patch for the VPATH issue I was seeing, and am back to investigating your patch (I still think it would be better as two parts - code motion, then fixing semantics). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 01/08/2015 12:56 AM, Eric Blake wrote:
On 01/07/2015 02:43 PM, Eric Blake wrote:
CC xenconfig/libvirt_xenconfig_la-xen_xl.lo ../../src/xenconfig/xen_xl.c:29:25: fatal error: xen_xl_disk.h: No such file or directory #include "xen_xl_disk.h" ^ compilation terminated. CC xenconfig/libvirt_xenxldiskparser_la-xen_xl_disk.lo
but that may be an issue with me starting from a dirty build (make has the annoying habit of treating a target as up-to-date if the file exists in srcdir, even if you have rewritten the makefile to generate the file only into builddir). I'll try again from a fresh clone.
It appears I hit a separate issue, and that your builds don't have xenconfig enabled while mine do. I've posted an independent patch for the VPATH issue I was seeing, and am back to investigating your patch (I still think it would be better as two parts - code motion, then fixing semantics).
I'm OK with splitting the patch into two parts. Is you wrote in the previous mail this patch ensures that the generated files are included in tarball (which means generated into srcdir) and I'm building with xenconfig because I have enabled xen, xenapi and libxl. This patch works for me for VPATH and also non VPATH builds and I've also tested creating tarball and building from that tarball and it works. Thanks for the review and I'll send v4 with two patches. Pavel

On 01/07/2015 10:17 AM, Pavel Hrdina wrote:
Well, the parallel build doesn't work as there are not dependencies set correctly. When running 'make -j' I see this error:
make[2]: Entering directory '/home/zippy/work/libvirt/libvirt.git/src' GEN util/virkeymaps.h GEN locking/lock_protocol.h make[2]: *** No rule to make target 'xenconfig/xen_xl_disk.h', needed by 'all'. Stop. make[2]: *** Waiting for unfinished jobs.... GEN lxc/lxc_controller_dispatch.h
The fix is to correctly set dependencies by letting make know that .c and .h are to be generated from .l. Moreover, the section is moved closer to the other section which uses it.
I'd feel better if we split the patch into two parts - do plain code motion without any semantic changes, then the changes are a lot easier to see in isolation. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Eric Blake
-
Pavel Hrdina
-
Pavel Hrdina