[Libguestfs] [PATCH] Fix building on architectures where ocamlopt is not available

Richard W.M. Jones rjones at redhat.com
Sun Mar 23 17:10:06 UTC 2014


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
-------------- next part --------------
>From 5773df6d5367a7a98b474de02b527a09606f139f Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones at redhat.com>
Date: Sun, 23 Mar 2014 16:31:10 +0000
Subject: [PATCH] ocaml: Enable parallel builds.

This reintroduces commit dce94f3e266ed3f1fc634a1ef6953f2db1510963.
---
 ocaml/Makefile.am | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index 7c8e515..ee5a241 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -54,15 +54,25 @@ 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.
 
-mlguestfs.cma: libguestfsocaml.a guestfs.cmo
+CLEANFILES += stamp-mlguestfs
+
+mlguestfs.cma mlguestfs.cmxa: stamp-mlguestfs
+
+guestfs_cmm = guestfs.cmo
+if HAVE_OCAMLOPT
+guestfs_cmm += guestfs.cmx
+endif
+
+stamp-mlguestfs: libguestfsocaml.a $(guestfs_cmm)
 	$(OCAMLMKLIB) -o mlguestfs \
 	  $(libguestfsocaml_a_OBJECTS) guestfs.cmo \
 	  -L$(top_builddir)/src/.libs -lguestfs
-
-mlguestfs.cmxa: libguestfsocaml.a guestfs.cmx
+if HAVE_OCAMLOPT
 	$(OCAMLMKLIB) -o mlguestfs \
 	  $(libguestfsocaml_a_OBJECTS) guestfs.cmx \
 	  -L$(top_builddir)/src/.libs -lguestfs
+endif
+	touch $@
 
 libguestfsocaml_a_CPPFLAGS = \
 	-DGUESTFS_PRIVATE=1 \
@@ -189,7 +199,3 @@ 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:
-- 
1.8.5.3



More information about the Libguestfs mailing list