[libnbd PATCH] build: Fix OCaml build on Fedora 29
Once ocamlfind is installed, 'make' failed for me with: ocamlfind ocamlc -g -annot -safe-string -warn-error CDEFLMPSUVYZX+52-3 -ccopt '-gdwarf' -package unix -c NBD.ml -o NBD.cmo File "NBD.ml", line 1: Error: Could not find the .cmi file for interface NBD.mli. make[2]: *** [Makefile:823: NBD.cmo] Error 2 I'm not positive that this is the perfect fix, but it at least got the build working for me, and copies from idioms in nbdkit/plugins/ocaml/Makefile.am. --- ocaml/Makefile.am | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 0d876bb..557151c 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -32,6 +32,11 @@ if HAVE_OCAML OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)' OCAMLPACKAGES = -package unix +NBD.cmi: NBD.mli + $(OCAMLC) -c $< -o $@ + +NBD.cmo: NBD.cmi + noinst_DATA = mlnbd.cma META if HAVE_OCAMLOPT noinst_DATA += mlnbd.cmxa -- 2.20.1
On Sat, Jun 15, 2019 at 04:56:37PM -0500, Eric Blake wrote:
Once ocamlfind is installed, 'make' failed for me with:
ocamlfind ocamlc -g -annot -safe-string -warn-error CDEFLMPSUVYZX+52-3 -ccopt '-gdwarf' -package unix -c NBD.ml -o NBD.cmo File "NBD.ml", line 1: Error: Could not find the .cmi file for interface NBD.mli. make[2]: *** [Makefile:823: NBD.cmo] Error 2
I'm not positive that this is the perfect fix, but it at least got the build working for me, and copies from idioms in nbdkit/plugins/ocaml/Makefile.am. --- ocaml/Makefile.am | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 0d876bb..557151c 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -32,6 +32,11 @@ if HAVE_OCAML OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)' OCAMLPACKAGES = -package unix
+NBD.cmi: NBD.mli + $(OCAMLC) -c $< -o $@
I thnk this line should be: $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ otherwise you are dropping warning flags. However I don't know why this should be necessary because in subdir-rules.mk we have: %.cmi: $(srcdir)/%.mli $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ Maybe $(srcdir)/ confuses make because ./NBD.mli is not textually the same as NBD.mli? (The use of $(srcdir) was an attempt to make it work in split source/binary builds.)
+NBD.cmo: NBD.cmi
While correct, this line really shouldn't be necessary since ocaml/.depend already has the same line. In libguestfs we do some complex rewriting of .depend files (see libguestfs.git/ocaml-dep.sh.in) because the raw output of ocamldep doesn't really work well with autotools. I tried to avoid doing the same thing in libnbd, but perhaps it's really necessary after all ... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com 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
On 6/17/19 8:01 AM, Richard W.M. Jones wrote:
On Sat, Jun 15, 2019 at 04:56:37PM -0500, Eric Blake wrote:
Once ocamlfind is installed, 'make' failed for me with:
ocamlfind ocamlc -g -annot -safe-string -warn-error CDEFLMPSUVYZX+52-3 -ccopt '-gdwarf' -package unix -c NBD.ml -o NBD.cmo File "NBD.ml", line 1: Error: Could not find the .cmi file for interface NBD.mli. make[2]: *** [Makefile:823: NBD.cmo] Error 2
I'm not positive that this is the perfect fix, but it at least got the build working for me, and copies from idioms in nbdkit/plugins/ocaml/Makefile.am. --- ocaml/Makefile.am | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 0d876bb..557151c 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -32,6 +32,11 @@ if HAVE_OCAML OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)' OCAMLPACKAGES = -package unix
+NBD.cmi: NBD.mli + $(OCAMLC) -c $< -o $@
I thnk this line should be:
$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
otherwise you are dropping warning flags.
However I don't know why this should be necessary because in subdir-rules.mk we have:
%.cmi: $(srcdir)/%.mli $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
Maybe $(srcdir)/ confuses make because ./NBD.mli is not textually the same as NBD.mli? (The use of $(srcdir) was an attempt to make it work in split source/binary builds.)
I'll have to dig around in the make manual for what the correct usage should be. It's obvious from my failure that make was not computing the dependency, even though we think it should have been. It may take me a while as it's not yet my highest priority (I at least have enough of a hack to get the .cmi file built now, so it is no longer blocking me from testing other things). I also want to play with VPATH builds at some point, but again, not yet.
+NBD.cmo: NBD.cmi
While correct, this line really shouldn't be necessary since ocaml/.depend already has the same line.
In libguestfs we do some complex rewriting of .depend files (see libguestfs.git/ocaml-dep.sh.in) because the raw output of ocamldep doesn't really work well with autotools. I tried to avoid doing the same thing in libnbd, but perhaps it's really necessary after all ...
Rich.
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
participants (2)
-
Eric Blake -
Richard W.M. Jones