[PATCH] Don't rely on OCaml native compiler for tests
This should make it possible to build useful OCaml bindings on architectures other than i386 and amd64 (Debian bug #589809). --- ocaml/Makefile.am | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index b3f5e14..b9451e3 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -46,7 +46,7 @@ hivex_c.o: hivex_c.c $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $< TESTS_ENVIRONMENT = \ - LD_LIBRARY_PATH=$(top_builddir)/lib/.libs \ + LD_LIBRARY_PATH=$(top_builddir)/lib/.libs:$(top_builddir)/ocaml \ $(VG) TESTS = \ @@ -59,33 +59,33 @@ TESTS = \ t/hivex_300_fold noinst_DATA += $(TESTS) -t/hivex_005_load: t/hivex_005_load.cmx mlhivex.cmxa +t/hivex_005_load: t/hivex_005_load.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@ -t/hivex_010_open: t/hivex_010_open.cmx mlhivex.cmxa +t/hivex_010_open: t/hivex_010_open.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@ -t/hivex_020_root: t/hivex_020_root.cmx mlhivex.cmxa +t/hivex_020_root: t/hivex_020_root.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@ -t/hivex_100_errors: t/hivex_100_errors.cmx mlhivex.cmxa +t/hivex_100_errors: t/hivex_100_errors.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@ -t/hivex_110_gc_handle: t/hivex_110_gc_handle.cmx mlhivex.cmxa +t/hivex_110_gc_handle: t/hivex_110_gc_handle.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@ -t/hivex_200_write: t/hivex_200_write.cmx mlhivex.cmxa +t/hivex_200_write: t/hivex_200_write.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@ -t/hivex_300_fold: t/hivex_300_fold.cmx mlhivex.cmxa +t/hivex_300_fold: t/hivex_300_fold.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@ # Need to rebuild the tests from source if the main library has # changed at all, otherwise we get inconsistent assumptions. -- 1.7.4.4
On Mon, May 09, 2011 at 09:08:17AM +0200, Hilko Bengen wrote:
This should make it possible to build useful OCaml bindings on architectures other than i386 and amd64 (Debian bug #589809). --- ocaml/Makefile.am | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index b3f5e14..b9451e3 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -46,7 +46,7 @@ hivex_c.o: hivex_c.c $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $<
TESTS_ENVIRONMENT = \ - LD_LIBRARY_PATH=$(top_builddir)/lib/.libs \ + LD_LIBRARY_PATH=$(top_builddir)/lib/.libs:$(top_builddir)/ocaml \ $(VG)
TESTS = \ @@ -59,33 +59,33 @@ TESTS = \ t/hivex_300_fold noinst_DATA += $(TESTS)
-t/hivex_005_load: t/hivex_005_load.cmx mlhivex.cmxa +t/hivex_005_load: t/hivex_005_load.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
-t/hivex_010_open: t/hivex_010_open.cmx mlhivex.cmxa +t/hivex_010_open: t/hivex_010_open.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
-t/hivex_020_root: t/hivex_020_root.cmx mlhivex.cmxa +t/hivex_020_root: t/hivex_020_root.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
-t/hivex_100_errors: t/hivex_100_errors.cmx mlhivex.cmxa +t/hivex_100_errors: t/hivex_100_errors.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
-t/hivex_110_gc_handle: t/hivex_110_gc_handle.cmx mlhivex.cmxa +t/hivex_110_gc_handle: t/hivex_110_gc_handle.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
-t/hivex_200_write: t/hivex_200_write.cmx mlhivex.cmxa +t/hivex_200_write: t/hivex_200_write.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
-t/hivex_300_fold: t/hivex_300_fold.cmx mlhivex.cmxa +t/hivex_300_fold: t/hivex_300_fold.cmo mlhivex.cma mkdir -p t - $(OCAMLFIND) ocamlopt -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cmxa $< -o $@ + $(OCAMLFIND) ocamlc -cclib -L$(top_builddir)/lib/.libs -I . -package unix -linkpkg mlhivex.cma $< -o $@
# Need to rebuild the tests from source if the main library has # changed at all, otherwise we get inconsistent assumptions. -- 1.7.4.4
ACK -- I'll push this later today. 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 Xen guests. http://et.redhat.com/~rjones/virt-p2v
I pushed this, and also the Python/configure patch. 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://et.redhat.com/~rjones/virt-df/
* Richard W.M. Jones:
I pushed this, and also the Python/configure patch.
Uh-oh, I mede a mistake there. The tests get built if I have libhivex.so.0 somewhere in the system path, but the version in ../lib/.libs is not found. ,---- | gcc -std=gnu99 -I.. -I/usr/lib/ocaml -I../ocaml -I../lib -g -O2 -fPIC -Wall -c hivex_c.c | ocamlfind ocamlc -package unix -c hivex.mli -o hivex.cmi | ocamlfind ocamlc -package unix -c hivex.ml -o hivex.cmo | ocamlmklib -o mlhivex hivex_c.o hivex.cmo -L../lib/.libs -lhivex | ocamlfind ocamlopt -package unix -c hivex.ml -o hivex.cmx | ocamlmklib -o mlhivex hivex_c.o hivex.cmx -L../lib/.libs -lhivex | cd .. && /bin/bash ./config.status ocaml/META | config.status: creating ocaml/META | ocamlfind ocamlc -package unix -c t/hivex_005_load.ml -o t/hivex_005_load.cmo | mkdir -p t | ocamlfind ocamlc -cclib -L../lib/.libs -I . -package unix -linkpkg mlhivex.cma t/hivex_005_load.cmo -o t/hivex_005_load | File "_none_", line 1, characters 0-1: | Error: Error on dynamically loaded library: ./dllmlhivex.so: libhivex.so.0: cannot open shared object file: No such file or directory `---- -Hilko
On Tue, May 10, 2011 at 12:47:06PM +0200, Hilko Bengen wrote:
* Richard W.M. Jones:
I pushed this, and also the Python/configure patch.
Uh-oh, I mede a mistake there.
The tests get built if I have libhivex.so.0 somewhere in the system path, but the version in ../lib/.libs is not found.
Shouldn't there always be a version in libs/.libs? Surely it has just been built by 'make' ... 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://et.redhat.com/~rjones/virt-top
* Richard W.M. Jones:
On Tue, May 10, 2011 at 12:47:06PM +0200, Hilko Bengen wrote:
* Richard W.M. Jones:
I pushed this, and also the Python/configure patch.
Uh-oh, I mede a mistake there.
The tests get built if I have libhivex.so.0 somewhere in the system path, but the version in ../lib/.libs is not found.
Shouldn't there always be a version in libs/.libs? Surely it has just been built by 'make' ...
Yes, a fresh version of libhivex.so.0 can be found in lib/.libs, but as it seems that ocamlc (or some other responsible component) does not look there. ,---- | hivex.git $ ls lib/.libs/ | libhivex.a libhivex.lai libhivex.so.0 libhivex_la-hivex.o | libhivex.la libhivex.so libhivex.so.0.0.0 | hivex.git $ cd ocaml | ocaml $ make | gcc -std=gnu99 -I.. -I/usr/lib/ocaml -I../ocaml -I../lib -g -O2 -fPIC -Wall -c hivex_c.c | ocamlfind ocamlc -package unix -c hivex.mli -o hivex.cmi | ocamlfind ocamlc -package unix -c hivex.ml -o hivex.cmo | ocamlmklib -o mlhivex hivex_c.o hivex.cmo -L../lib/.libs -lhivex | ocamlfind ocamlopt -package unix -c hivex.ml -o hivex.cmx | ocamlmklib -o mlhivex hivex_c.o hivex.cmx -L../lib/.libs -lhivex | cd .. && /bin/bash ./config.status ocaml/META | config.status: creating ocaml/META | ocamlfind ocamlc -package unix -c t/hivex_005_load.ml -o t/hivex_005_load.cmo | mkdir -p t | ocamlfind ocamlc -cclib -L../lib/.libs -I . -package unix -linkpkg mlhivex.cma t/hivex_005_load.cmo -o t/hivex_005_load | File "_none_", line 1, characters 0-1: | Error: Error on dynamically loaded library: ./dllmlhivex.so: libhivex.so.0: cannot open shared object file: No such file or directory | make: *** [t/hivex_005_load] Error 2 | ocaml $ `---- However, if I proveide the "ocamlfind ocamlc" call with a LD_LIBRARY_PATH, this works: ,---- | ocaml $ ocamlfind ocamlc -cclib -L../lib/.libs -I . -package unix -linkpkg mlhivex.cma t/hivex_005_load.cmo -o t/hivex_005_load | File "_none_", line 1, characters 0-1: | Error: Error on dynamically loaded library: ./dllmlhivex.so: libhivex.so.0: cannot open shared object file: No such file or directory | ocaml $ LD_LIBRARY_PATH=../lib/.libs ocamlfind ocamlc -cclib -L../lib/.libs -I . -package unix -linkpkg mlhivex.cma t/hivex_005_load.cmo -o t/hivex_005_load | ocaml $ `---- Should this be the only way to get the test programs compiled in-tree? I have experimented with passing "-dllpath ../lib/.libs" to the "ocamlmklib" calls, but that hasn't worked, either. -Hilko
On 05/10/2011 07:59 PM, Hilko Bengen wrote:
* Richard W.M. Jones:
On Tue, May 10, 2011 at 12:47:06PM +0200, Hilko Bengen wrote:
* Richard W.M. Jones:
I pushed this, and also the Python/configure patch.
Uh-oh, I mede a mistake there.
The tests get built if I have libhivex.so.0 somewhere in the system path, but the version in ../lib/.libs is not found.
Shouldn't there always be a version in libs/.libs? Surely it has just been built by 'make' ...
Yes, a fresh version of libhivex.so.0 can be found in lib/.libs, but as it seems that ocamlc (or some other responsible component) does not look there.
,---- | hivex.git $ ls lib/.libs/ | libhivex.a libhivex.lai libhivex.so.0 libhivex_la-hivex.o | libhivex.la libhivex.so libhivex.so.0.0.0 | hivex.git $ cd ocaml | ocaml $ make | gcc -std=gnu99 -I.. -I/usr/lib/ocaml -I../ocaml -I../lib -g -O2 -fPIC -Wall -c hivex_c.c | ocamlfind ocamlc -package unix -c hivex.mli -o hivex.cmi | ocamlfind ocamlc -package unix -c hivex.ml -o hivex.cmo | ocamlmklib -o mlhivex hivex_c.o hivex.cmo -L../lib/.libs -lhivex | ocamlfind ocamlopt -package unix -c hivex.ml -o hivex.cmx | ocamlmklib -o mlhivex hivex_c.o hivex.cmx -L../lib/.libs -lhivex | cd .. && /bin/bash ./config.status ocaml/META | config.status: creating ocaml/META | ocamlfind ocamlc -package unix -c t/hivex_005_load.ml -o t/hivex_005_load.cmo | mkdir -p t | ocamlfind ocamlc -cclib -L../lib/.libs -I . -package unix -linkpkg mlhivex.cma t/hivex_005_load.cmo -o t/hivex_005_load | File "_none_", line 1, characters 0-1: | Error: Error on dynamically loaded library: ./dllmlhivex.so: libhivex.so.0: cannot open shared object file: No such file or directory
Try: $(LIBTOOL) --mode=execute -dlopen ../lib/libhivex.la $(OCAMLFIND) ... 'make check' appears to do that already automatically, so t/hivex_005_load runs correctly too. Best regards, --Edwin
* Török Edwin:
Try: $(LIBTOOL) --mode=execute -dlopen ../lib/libhivex.la $(OCAMLFIND) ...
'make check' appears to do that already automatically, so t/hivex_005_load runs correctly too.
This works for me. Great, thank you! "make check", at least when it is called from within the ocaml subdirectory, just sets LD_LIBRARY_PATH. Which comes pretty close to what libtool would do, I suppose. This seems to be defined by setting TESTS_ENVIRONMENT. BTW, can someone tell me what the meaning of $(VG) right there? Since the test programs are already listed, I have replaced the individual "t/hivex_*_*" lines with this: ,---- | t/%: t/%.cmo mlhivex.cma | $(LIBTOOL) --mode=execute -dlopen $(top_builddir)/lib/libhivex.la \ | $(OCAMLFIND) ocamlc -dllpath $(abs_builddir) -package unix -linkpkg \ | mlhivex.cma $< -o $@ `---- And it still builds and the tests run fine, at least on my amd64 Debian/unstable workstation. Running the failing command under ltrace reveals that ocamlc uses dlopen() to open dllmlhivex.so which is referenced by mlhivex.cma. Then it uses dlsym(), apparently in order to verify that some symbols can be resolved. This fails if libhivex.so.0 cannot be found, because dllmlhivex.so depends on it. Ah well, it seems I just got some steps closer to understanding how autofoo and the OCaml toolchain operate. Cheers, -Hilko
On Tue, May 10, 2011 at 11:54:27PM +0200, Hilko Bengen wrote:
* Török Edwin:
Try: $(LIBTOOL) --mode=execute -dlopen ../lib/libhivex.la $(OCAMLFIND) ...
'make check' appears to do that already automatically, so t/hivex_005_load runs correctly too.
This works for me. Great, thank you!
"make check", at least when it is called from within the ocaml subdirectory, just sets LD_LIBRARY_PATH. Which comes pretty close to what libtool would do, I suppose.
This seems to be defined by setting TESTS_ENVIRONMENT. BTW, can someone tell me what the meaning of $(VG) right there?
It's so you can do: make VG=valgrind check
Since the test programs are already listed, I have replaced the individual "t/hivex_*_*" lines with this:
,---- | t/%: t/%.cmo mlhivex.cma | $(LIBTOOL) --mode=execute -dlopen $(top_builddir)/lib/libhivex.la \ | $(OCAMLFIND) ocamlc -dllpath $(abs_builddir) -package unix -linkpkg \ | mlhivex.cma $< -o $@ `----
And it still builds and the tests run fine, at least on my amd64 Debian/unstable workstation.
Running the failing command under ltrace reveals that ocamlc uses dlopen() to open dllmlhivex.so which is referenced by mlhivex.cma. Then it uses dlsym(), apparently in order to verify that some symbols can be resolved. This fails if libhivex.so.0 cannot be found, because dllmlhivex.so depends on it.
Ah well, it seems I just got some steps closer to understanding how autofoo and the OCaml toolchain operate.
Do you have a suggested patch? This all works fine for me (even on Debian) so I don't understand what the exact problem was. 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://et.redhat.com/~rjones/virt-top
On Thu, May 12, 2011 at 10:53:27AM +0100, Richard W.M. Jones wrote:
Do you have a suggested patch? This all works fine for me (even on Debian) so I don't understand what the exact problem was.
Alright, now I *do* see the problem, if I don't have the hivex library already installed on the system. I pushed the following patch which is based on your suggestion: http://git.annexia.org/?p=hivex.git;a=commitdiff;h=2cf6eef8ff7b7ab642943e671... (The patch didn't make it into 1.2.6 unfortunately) 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://et.redhat.com/~rjones/virt-df/
participants (3)
-
Hilko Bengen -
Richard W.M. Jones -
Török Edwin