[PATCH] Fix building on architectures where ocamlopt is not available
--- builder/Makefile.am | 18 +++++++++++++- configure.ac | 2 ++ mllib/Makefile.am | 60 +++++++++++++++++++++++++++++++--------------- ocaml/Makefile.am | 28 +++++++++++++++------- ocaml/examples/Makefile.am | 13 ++++++++++ resize/Makefile.am | 18 +++++++++++++- sparsify/Makefile.am | 18 +++++++++++++- sysprep/Makefile.am | 18 +++++++++++++- 8 files changed, 143 insertions(+), 32 deletions(-) diff --git a/builder/Makefile.am b/builder/Makefile.am index f0cb1dd..bc7ab6e 100644 --- a/builder/Makefile.am +++ b/builder/Makefile.am @@ -68,7 +68,7 @@ noinst_DATA = if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +deps = \ $(top_builddir)/mllib/libdir.cmx \ $(top_builddir)/mllib/common_gettext.cmx \ $(top_builddir)/mllib/common_utils.cmx \ @@ -109,6 +109,12 @@ OBJECTS = \ cmdline.cmx \ builder.cmx +if HAVE_OCAMLOPT +OBJECTS = $(deps) +else +OBJECTS = $(patsubst %.cmx,%.cmo,$(deps)) +endif + bin_SCRIPTS = virt-builder # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -134,12 +140,22 @@ OCAMLCLIBS = \ -pthread -lpthread \ -lncurses -lcrypt +if HAVE_OCAMLOPT virt-builder: $(OBJECTS) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else +virt-builder: $(OBJECTS) + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ diff --git a/configure.ac b/configure.ac index 0326640..61281f2 100644 --- a/configure.ac +++ b/configure.ac @@ -1026,6 +1026,8 @@ AS_IF([test "x$enable_ocaml" != "xno"],[ ]) AM_CONDITIONAL([HAVE_OCAML], [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) +AM_CONDITIONAL([HAVE_OCAMLOPT], + [test "x$OCAMLOPT" != "xno" && test "x$OCAMLFIND" != "xno"]) AM_CONDITIONAL([HAVE_OCAMLDOC], [test "x$OCAMLDOC" != "xno"]) diff --git a/mllib/Makefile.am b/mllib/Makefile.am index 920928d..2e35d1e 100644 --- a/mllib/Makefile.am +++ b/mllib/Makefile.am @@ -69,6 +69,25 @@ if HAVE_OCAML # - We're not actually building a functioning program here, we're just # linking everything together to check all the modules build OK. # - This list must be in dependency order. +ocaml_modules = config \ + libdir \ + common_gettext \ + common_utils \ + urandom \ + random_seed \ + hostname \ + timezone \ + firstboot \ + perl_edit \ + tTY \ + fsync \ + progress \ + uRI \ + crypt \ + password \ + mkdtemp \ + planner + OBJECTS = \ $(top_builddir)/fish/guestfish-progress.o \ $(top_builddir)/fish/guestfish-uri.o \ @@ -77,25 +96,13 @@ OBJECTS = \ progress-c.o \ uri-c.o \ crypt-c.o \ - mkdtemp-c.o \ - config.cmx \ - libdir.cmx \ - common_gettext.cmx \ - common_utils.cmx \ - urandom.cmx \ - random_seed.cmx \ - hostname.cmx \ - timezone.cmx \ - firstboot.cmx \ - perl_edit.cmx \ - tTY.cmx \ - fsync.cmx \ - progress.cmx \ - uRI.cmx \ - crypt.cmx \ - password.cmx \ - mkdtemp.cmx \ - planner.cmx + mkdtemp-c.o + +if HAVE_OCAMLOPT +OBJECTS += $(patsubst %,%.cmx,$(ocaml_modules)) +else +OBJECTS += $(patsubst %,%.cmo,$(ocaml_modules)) +endif noinst_SCRIPTS = dummy @@ -116,11 +123,20 @@ OCAMLCLIBS = \ -L../gnulib/lib/.libs -lgnu dummy: $(OBJECTS) +if HAVE_OCAMLOPT $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ @@ -153,9 +169,15 @@ DEFAULT_INCLUDES = \ check_SCRIPTS = common_utils_tests +if HAVE_OCAMLOPT common_utils_tests: common_gettext.cmx common_utils.cmx common_utils_tests.cmx $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ -cclib -lncurses -o $@ +else +common_utils_tests: common_gettext.cmo common_utils.cmo common_utils_tests.cmo + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ -cclib -lncurses -o $@ +endif TESTS_ENVIRONMENT = $(top_builddir)/run --test diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 5dd2c9b..708b2e7 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -40,7 +40,10 @@ if HAVE_OCAML OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX OCAMLOPTFLAGS = $(OCAMLCFLAGS) -noinst_DATA = mlguestfs.cma mlguestfs.cmxa META +noinst_DATA = mlguestfs.cma META +if HAVE_OCAMLOPT +noinst_DATA += mlguestfs.cmxa +endif # Build the C part into a library, so that automake handles the C # compilation step for us. Note that we don't directly use this @@ -51,18 +54,15 @@ noinst_LIBRARIES = libguestfsocaml.a # 'libmlguestfs.a' and if run at the same time, they will stomp on or # corrupt each others copy. Hence we have to serialize the calls. -CLEANFILES += stamp-mlguestfs - -mlguestfs.cma mlguestfs.cmxa: stamp-mlguestfs - -stamp-mlguestfs: libguestfsocaml.a guestfs.cmo guestfs.cmx +mlguestfs.cma: libguestfsocaml.a guestfs.cmo $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmo \ -L$(top_builddir)/src/.libs -lguestfs + +mlguestfs.cmxa: libguestfsocaml.a guestfs.cmx $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmx \ -L$(top_builddir)/src/.libs -lguestfs - touch $@ libguestfsocaml_a_CPPFLAGS = \ -DGUESTFS_PRIVATE=1 \ @@ -121,11 +121,17 @@ test_progs_opt += \ t/guestfs_430_progress_messages.opt endif -test_progs_all = $(test_progs_bc) $(test_progs_opt) +test_progs_all = $(test_progs_bc) +if HAVE_OCAMLOPT +test_progs_all += $(test_progs_opt) +endif TESTS = run-bindtests $(test_progs_all) -noinst_DATA += bindtests.bc bindtests.opt $(test_progs_all) +noinst_DATA += bindtests.bc $(test_progs_all) +if HAVE_OCAMLOPT +noinst_DATA += bindtests.opt +endif %.bc: %.cmo mlguestfs.cma $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ @@ -178,3 +184,7 @@ install-data-hook: CLEANFILES += $(noinst_DATA) endif + +# Tell version 3.79 and up of GNU make to not build goals in this +# directory in parallel. +.NOTPARALLEL: diff --git a/ocaml/examples/Makefile.am b/ocaml/examples/Makefile.am index 200a0aa..472e180 100644 --- a/ocaml/examples/Makefile.am +++ b/ocaml/examples/Makefile.am @@ -49,6 +49,7 @@ noinst_SCRIPTS = create_disk inspect_vm OCAMLFINDFLAGS = -cclib -L$(top_builddir)/src/.libs +if HAVE_OCAMLOPT create_disk: create_disk.ml $(OCAMLFIND) ocamlopt $(OCAMLFINDFLAGS) -package unix -linkpkg \ -warn-error A -I .. mlguestfs.cmxa $< -o $@ @@ -56,5 +57,17 @@ create_disk: create_disk.ml inspect_vm: inspect_vm.ml $(OCAMLFIND) ocamlopt $(OCAMLFINDFLAGS) -package unix -linkpkg \ -warn-error A -I .. mlguestfs.cmxa $< -o $@ +else + +# This avoids: +# Error: Error on dynamically loaded library: ../dllmlguestfs.so: libguestfs.so.0: cannot open shared object file: No such file or directory +create_disk: create_disk.ml + $(top_builddir)/run $(OCAMLFIND) ocamlc $(OCAMLFINDFLAGS) -package unix -linkpkg \ + -warn-error A -I .. mlguestfs.cma $< -o $@ + +inspect_vm: inspect_vm.ml + $(top_builddir)/run $(OCAMLFIND) ocamlc $(OCAMLFINDFLAGS) -package unix -linkpkg \ + -warn-error A -I .. mlguestfs.cma $< -o $@ +endif endif diff --git a/resize/Makefile.am b/resize/Makefile.am index 76c26ee..ef35bf9 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -31,7 +31,7 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +deps = \ $(top_builddir)/mllib/tty-c.o \ $(top_builddir)/mllib/tTY.cmx \ $(top_builddir)/mllib/fsync-c.o \ @@ -47,6 +47,12 @@ OBJECTS = \ $(top_builddir)/mllib/config.cmx \ resize.cmx +if HAVE_OCAMLOPT +OBJECTS = $(deps) +else +OBJECTS = $(patsubst %.cmx,%.cmo,$(deps)) +endif + bin_SCRIPTS = virt-resize # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -69,12 +75,22 @@ OCAMLCLIBS = \ -L../src/.libs -lutils \ -L../gnulib/lib/.libs -lgnu +if HAVE_OCAMLOPT virt-resize: $(OBJECTS) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else +virt-resize: $(OBJECTS) + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am index 98d9c70..bf6caf0 100644 --- a/sparsify/Makefile.am +++ b/sparsify/Makefile.am @@ -32,7 +32,7 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +deps = \ $(top_builddir)/fish/guestfish-progress.o \ $(top_builddir)/mllib/tty-c.o \ $(top_builddir)/mllib/progress-c.o \ @@ -44,6 +44,12 @@ OBJECTS = \ statvfs-c.o \ sparsify.cmx +if HAVE_OCAMLOPT +OBJECTS = $(deps) +else +OBJECTS = $(patsubst %.cmx,%.cmo,$(deps)) +endif + bin_SCRIPTS = virt-sparsify # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -61,12 +67,22 @@ endif OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) OCAMLOPTFLAGS = $(OCAMLCFLAGS) +if HAVE_OCAMLOPT virt-sparsify: $(OBJECTS) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib -lncurses \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else +virt-sparsify: $(OBJECTS) + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib -lncurses \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index 9c9ab14..22da6fd 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -85,7 +85,7 @@ SOURCES = \ if HAVE_OCAML # Note this list must be in dependency order. -OBJECTS = \ +deps = \ $(top_builddir)/mllib/common_gettext.cmx \ $(top_builddir)/mllib/common_utils.cmx \ $(top_builddir)/fish/guestfish-uri.o \ @@ -106,6 +106,12 @@ OBJECTS = \ $(patsubst %,sysprep_operation_%.cmx,$(operations)) \ main.cmx +if HAVE_OCAMLOPT +OBJECTS = $(deps) +else +OBJECTS = $(patsubst %.cmx,%.cmo,$(deps)) +endif + bin_SCRIPTS = virt-sysprep # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L @@ -128,12 +134,22 @@ OCAMLCLIBS = \ -L../src/.libs -lutils \ -L../gnulib/lib/.libs -lgnu +if HAVE_OCAMLOPT virt-sysprep: $(OBJECTS) $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \ mlguestfs.cmxa -linkpkg $^ \ -cclib '$(OCAMLCLIBS)' \ $(OCAML_GCOV_LDFLAGS) \ -o $@ +else +virt-sysprep: $(OBJECTS) + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \ + mlguestfs.cma -linkpkg $^ \ + -cclib '$(OCAMLCLIBS)' \ + -custom \ + $(OCAML_GCOV_LDFLAGS) \ + -o $@ +endif .mli.cmi: $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ -- 1.9.0
On Fri, Feb 28, 2014 at 02:35:56PM +0100, Hilko Bengen wrote:
+if HAVE_OCAMLOPT +OBJECTS = $(deps) +else +OBJECTS = $(patsubst %.cmx,%.cmo,$(deps))
There's something about automake 1.13 which breaks use of patsubst / subst (or any GNU make extension used in certain automake variables). I can't test if it will specifically break this because I don't have access to any machines that don't have ocamlopt, but it's something to watch out for. In any case, I have pushed this since it works fine for me. Something for the future: It'd be nice to use automake to build objects. This is possible if the program contains at least one C object file. See: https://github.com/libguestfs/supermin/blob/master/src/Makefile.am#L96 https://github.com/libguestfs/supermin/blob/master/src/supermin-link.sh.in Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
On Fri, Feb 28, Richard W.M. Jones wrote:
I can't test if it will specifically break this because I don't have access to any machines that don't have ocamlopt, but it's something to watch out for.
In any case, I have pushed this since it works fine for me.
Any chance this can be backported to 1.24? Olaf
On Tue, Mar 11, 2014 at 10:51:50AM +0100, Olaf Hering wrote:
On Fri, Feb 28, Richard W.M. Jones wrote:
I can't test if it will specifically break this because I don't have access to any machines that don't have ocamlopt, but it's something to watch out for.
In any case, I have pushed this since it works fine for me.
Any chance this can be backported to 1.24?
Actually I looked at the patch when I was doing the 1.24.8 release but IIRC it was not a clean cherry pick. How about carrying it as a downstream patch (just for 1.24)? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
On Tue, Mar 11, Richard W.M. Jones wrote:
Actually I looked at the patch when I was doing the 1.24.8 release but IIRC it was not a clean cherry pick.
Thats why I sent out my backport to 1.24.x, too.
How about carrying it as a downstream patch (just for 1.24)?
It requires changes to Makefile.in as well because, depending on the distversion, automake is too old at least in SLES11. Olaf
On Tue, Mar 11, 2014 at 12:07:44PM +0100, Olaf Hering wrote:
On Tue, Mar 11, Richard W.M. Jones wrote:
How about carrying it as a downstream patch (just for 1.24)?
It requires changes to Makefile.in as well because, depending on the distversion, automake is too old at least in SLES11.
Yes, this is annoying. The way I do it for Fedora is to carry a patch for Makefile.in as well. This patch still has to be prepared with automake 1.13, so you'd have to make the patch on an OpenSUSE 13.1 box. Something like this: tar zxf libguestfs-1.24.8.tar.gz cp -a libguestfs-1.24.8 libguestfs-1.24.8.old pushd libguestfs-1.24.8 patch -p1 < ../old.patch automake popd diff -ur libguestfs-1.24.8.old libguestfs-1.24.8 > new.patch Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
On Fri, Feb 28, Hilko Bengen wrote:
--- builder/Makefile.am | 18 +++++++++++++- configure.ac | 2 ++ mllib/Makefile.am | 60 +++++++++++++++++++++++++++++++--------------- ocaml/Makefile.am | 28 +++++++++++++++-------
Something like this is required: diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 708b2e7..698e13a 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -37,6 +37,11 @@ CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so if HAVE_OCAML +DATA_HOOK_FILES = META *.so *.a *.cma *.cmi $(srcdir)/*.mli +if HAVE_OCAMLOPT +DATA_HOOK_FILES += *.cmx *.cmxa +endif + OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX OCAMLOPTFLAGS = $(OCAMLCFLAGS) @@ -177,7 +182,7 @@ install-data-hook: $(OCAMLFIND) install \ -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \ guestfs \ - META *.so *.a *.cma *.cmx *.cmxa *.cmi $(srcdir)/*.mli + $(DATA_HOOK_FILES) rm $(DESTDIR)$(OCAMLLIB)/guestfs/bindtests.* rm $(DESTDIR)$(OCAMLLIB)/guestfs/libguestfsocaml.a
On Fri, Feb 28, 2014 at 03:53:55PM +0100, Olaf Hering wrote:
On Fri, Feb 28, Hilko Bengen wrote:
--- builder/Makefile.am | 18 +++++++++++++- configure.ac | 2 ++ mllib/Makefile.am | 60 +++++++++++++++++++++++++++++++--------------- ocaml/Makefile.am | 28 +++++++++++++++-------
Something like this is required:
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 708b2e7..698e13a 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -37,6 +37,11 @@ CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so
if HAVE_OCAML
+DATA_HOOK_FILES = META *.so *.a *.cma *.cmi $(srcdir)/*.mli +if HAVE_OCAMLOPT +DATA_HOOK_FILES += *.cmx *.cmxa +endif + OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX OCAMLOPTFLAGS = $(OCAMLCFLAGS)
@@ -177,7 +182,7 @@ install-data-hook: $(OCAMLFIND) install \ -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \ guestfs \ - META *.so *.a *.cma *.cmx *.cmxa *.cmi $(srcdir)/*.mli + $(DATA_HOOK_FILES) rm $(DESTDIR)$(OCAMLLIB)/guestfs/bindtests.* rm $(DESTDIR)$(OCAMLLIB)/guestfs/libguestfsocaml.a
Looks reasonable to me. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
On Fri, Feb 28, 2014 at 02:35:56PM +0100, Hilko Bengen wrote:
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 5dd2c9b..708b2e7 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am [...] +# Tell version 3.79 and up of GNU make to not build goals in this +# directory in parallel. +.NOTPARALLEL:
^ This makes building the OCaml subdirectory very slow (I normally build with MAKEFLAGS=-j9). Was there a reason for adding this? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
* Richard W.M. Jones:
On Fri, Feb 28, 2014 at 02:35:56PM +0100, Hilko Bengen wrote:
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 5dd2c9b..708b2e7 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am [...] +# Tell version 3.79 and up of GNU make to not build goals in this +# directory in parallel. +.NOTPARALLEL:
^ This makes building the OCaml subdirectory very slow (I normally build with MAKEFLAGS=-j9). Was there a reason for adding this?
I think I added this because both the mlguestfs.cma and mlguestfs.cmxa targets generate libmlguestfs.a: mlguestfs.cma: libguestfsocaml.a guestfs.cmo $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmo \ -L$(top_builddir)/src/.libs -lguestfs mlguestfs.cmxa: libguestfsocaml.a guestfs.cmx $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmx \ -L$(top_builddir)/src/.libs -lguestfs As far as I know, those are the only targets that shouldn't be run parallel. I think that an extra target (mlguestfs.cmxa: mlguestfs.cma) would make the .NOTPARALLEL unnecessary. Cheers, -Hilko
On Sat, Mar 22, 2014 at 11:36:33AM +0100, Hilko Bengen wrote:
* Richard W.M. Jones:
On Fri, Feb 28, 2014 at 02:35:56PM +0100, Hilko Bengen wrote:
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 5dd2c9b..708b2e7 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am [...] +# Tell version 3.79 and up of GNU make to not build goals in this +# directory in parallel. +.NOTPARALLEL:
^ This makes building the OCaml subdirectory very slow (I normally build with MAKEFLAGS=-j9). Was there a reason for adding this?
I think I added this because both the mlguestfs.cma and mlguestfs.cmxa targets generate libmlguestfs.a:
mlguestfs.cma: libguestfsocaml.a guestfs.cmo $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmo \ -L$(top_builddir)/src/.libs -lguestfs
mlguestfs.cmxa: libguestfsocaml.a guestfs.cmx $(OCAMLMKLIB) -o mlguestfs \ $(libguestfsocaml_a_OBJECTS) guestfs.cmx \ -L$(top_builddir)/src/.libs -lguestfs
As far as I know, those are the only targets that shouldn't be run parallel.
I think that an extra target (mlguestfs.cmxa: mlguestfs.cma) would make the .NOTPARALLEL unnecessary.
Right, I remember this was a problem now. It was fixed by: https://github.com/libguestfs/libguestfs/commit/dce94f3e266ed3f1fc634a1ef695... Do you think we could re-add the stamp-file / touch $@ ? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
* Richard W.M. Jones:
I think that an extra target (mlguestfs.cmxa: mlguestfs.cma) would make the .NOTPARALLEL unnecessary.
Right, I remember this was a problem now.
It was fixed by:
https://github.com/libguestfs/libguestfs/commit/dce94f3e266ed3f1fc634a1ef695...
Do you think we could re-add the stamp-file / touch $@ ?
Sure, it would have to be modified so it still works if OCAMLOPT is not available -- that's why I made that change in the first place. Wouldn't a rule without commands such as mlguestfs.cmxa: mlguestfs.cma also prevent make from building the two targets in parallel? Cheers, -Hilko
On Sat, Mar 22, 2014 at 01:22:06PM +0100, Hilko Bengen wrote:
* Richard W.M. Jones:
I think that an extra target (mlguestfs.cmxa: mlguestfs.cma) would make the .NOTPARALLEL unnecessary.
Right, I remember this was a problem now.
It was fixed by:
https://github.com/libguestfs/libguestfs/commit/dce94f3e266ed3f1fc634a1ef695...
Do you think we could re-add the stamp-file / touch $@ ?
Sure, it would have to be modified so it still works if OCAMLOPT is not available -- that's why I made that change in the first place.
Wouldn't a rule without commands such as
mlguestfs.cmxa: mlguestfs.cma
also prevent make from building the two targets in parallel?
Doesn't that mean that if mlguestfs.cmxa is out of date, simply running the mlguestfs.cma rule will build it (which it won't)? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
* Richard W.M. Jones:
Wouldn't a rule without commands such as
mlguestfs.cmxa: mlguestfs.cma
also prevent make from building the two targets in parallel?
Doesn't that mean that if mlguestfs.cmxa is out of date, simply running the mlguestfs.cma rule will build it (which it won't)?
Not sure if I understand you. If I cause mlguestfs.cmxa to be out of date by touching guestfs.cmx, only mlguestfs.cmxa will be rebuilt. If I cause mlguestfs.cma to be out of date by touching guestfs.cmo, both mlguestfs.cma and mlguestfs.cmxa will be rebuilt. This could be fixed by using an order-only prerequisite: mlguestfs.cmxa: | mlguestfs.cma Cheers, -Hilko
On Sat, Mar 22, 2014 at 02:04:36PM +0100, Hilko Bengen wrote:
* Richard W.M. Jones:
Wouldn't a rule without commands such as
mlguestfs.cmxa: mlguestfs.cma
also prevent make from building the two targets in parallel?
Doesn't that mean that if mlguestfs.cmxa is out of date, simply running the mlguestfs.cma rule will build it (which it won't)?
Not sure if I understand you.
If I cause mlguestfs.cmxa to be out of date by touching guestfs.cmx, only mlguestfs.cmxa will be rebuilt.
If I cause mlguestfs.cma to be out of date by touching guestfs.cmo, both mlguestfs.cma and mlguestfs.cmxa will be rebuilt. This could be fixed by using an order-only prerequisite:
mlguestfs.cmxa: | mlguestfs.cma
I wanted to see what would work in practice, so I set up the following test (note you may have to adjust the MD5 hashes depending on the version of OCaml you have). Save the following as test.sh, and make it executable: ---------------------------------------------------------------------- #!/bin/bash set -e make -C ocaml clean make -C ocaml -j100 test "$(md5sum ocaml/mlguestfs.cm*)" = "e929569af895530898f9a513a9a8c8ff ocaml/mlguestfs.cma 09847aa897b230316ae61d633a151fff ocaml/mlguestfs.cmxa" ---------------------------------------------------------------------- Run: while ./test.sh >& log; do echo -n .; done This will run for some time -- indefinitely if parallel builds work. If it exits, examine the log file to see what went wrong. I tried: (1) Removing .NOTPARALLEL. This fails, as expected. (2) mlguestfs.cmxa: mlguestfs.cma -- fails (3) mlguestfs.cmxa: | mlguestfs.cma -- fails after a longer time (4) The attached patch which is derived from dce94f -- this ran without failing for 120 iterations (and still going). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
BTW I should say I don't understand *why* the simpler approach of adding the order-only dependency doesn't work ... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
* Richard W.M. Jones:
(1) Removing .NOTPARALLEL. This fails, as expected.
(2) mlguestfs.cmxa: mlguestfs.cma -- fails
(3) mlguestfs.cmxa: | mlguestfs.cma -- fails after a longer time
I find it strange that (2) and (3) fail.
(4) The attached patch which is derived from dce94f -- this ran without failing for 120 iterations (and still going).
The patch looks good to me. -Hilko
On Sun, Mar 23, 2014 at 07:22:57PM +0100, Hilko Bengen wrote:
* Richard W.M. Jones:
(1) Removing .NOTPARALLEL. This fails, as expected.
(2) mlguestfs.cmxa: mlguestfs.cma -- fails
(3) mlguestfs.cmxa: | mlguestfs.cma -- fails after a longer time
I find it strange that (2) and (3) fail.
No I don't either. Just to make sure, I reran test (3) again. See attached patch. The failure is: ocamlmklib -o mlguestfs \ libguestfsocaml_a-guestfs-c.o libguestfsocaml_a-guestfs-c-actions.o libguestfsocaml_a-utils.o guestfs.cmx \ -L../src/.libs -lguestfs File "_none_", line 1: Error: Error on dynamically loaded library: ./dllmlguestfs.so: ./dllmlguestfs.so: file too short make: *** [t/guestfs_420_log_messages.bc] Error 2 make: *** Waiting for unfinished jobs.... Warning: Element Unix.error not found make: Leaving directory `/home/rjones/d/libguestfs/ocaml' It does run for quite a few iterations before it hits this failure, so obviously the failure window is narrow.
(4) The attached patch which is derived from dce94f -- this ran without failing for 120 iterations (and still going).
The patch looks good to me.
Thanks, I think I'll push my version unless anyone can see what's wrong with the simpler version. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
On Sun, Mar 23, 2014 at 06:31:40PM +0000, Richard W.M. Jones wrote:
On Sun, Mar 23, 2014 at 07:22:57PM +0100, Hilko Bengen wrote:
* Richard W.M. Jones:
(1) Removing .NOTPARALLEL. This fails, as expected.
(2) mlguestfs.cmxa: mlguestfs.cma -- fails
(3) mlguestfs.cmxa: | mlguestfs.cma -- fails after a longer time
I find it strange that (2) and (3) fail.
No I don't either.
I meant to say: I do find it strange too. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
participants (3)
-
Hilko Bengen -
Olaf Hering -
Richard W.M. Jones