[PATCH 1/3] hivex: Use OCaml bytecode compiler for caml_raise_with_args check
From: Hilko Bengen <bengen@hilluzination.de> On installations where no native OCaml compiler is available, the test program can't be compiled and so we get this message: ,---- | checking for function caml_raise_with_args... not found `---- This breaks building of the OCaml bindings. ,---- | gcc -std=gnu99 -I.. -I/usr/lib/ocaml -I../ocaml -I../lib -g -O2 -fPIC -Wall -c hivex_c.c | hivex_c.c:52: error: static declaration of 'caml_raise_with_args' follows non-static declaration | /usr/lib/ocaml/caml/fail.h:30: note: previous declaration of 'caml_raise_with_args' was here | make[2]: *** [hivex_c.o] Error 1 `---- (Successfully tested on Debian/unstable on alpha) --- configure.ac | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5805ddd..ef19543 100644 --- a/configure.ac +++ b/configure.ac @@ -192,9 +192,9 @@ if test "x$OCAMLC" != "xno"; then echo "char $f (); char foo() { return $f (); }" > conftest.c rm -f conftest_ml.ml touch conftest_ml.ml - if $OCAMLOPT -c conftest.c 2>/dev/null && \ - $OCAMLOPT -c conftest_ml.ml 2>/dev/null && \ - $OCAMLOPT conftest.o conftest_ml.cmx -o conftest 2>/dev/null ; then + if $OCAMLC -c conftest.c 2>/dev/null && \ + $OCAMLC -c conftest_ml.ml 2>/dev/null && \ + $OCAMLC conftest.o conftest_ml.cmo -o conftest 2>/dev/null ; then AC_DEFINE([HAVE_CAML_RAISE_WITH_ARGS],[1], [Defined if function caml_raise_with_args exists.]) AC_MSG_RESULT([found]) -- 1.7.5.1
From: Hilko Bengen <bengen@hilluzination.de> Only compile bytecode otherwise, avoiding ocamlfind's helpful error message "ocamlfind: Not supported in your configuration: ocamlopt" (Successfully tested on Debian/unstable on alpha) --- configure.ac | 1 + ocaml/Makefile.am | 6 +++++- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index ef19543..7e006e8 100644 --- a/configure.ac +++ b/configure.ac @@ -174,6 +174,7 @@ dnl Check for OCaml (optional, for OCaml bindings). AC_PROG_OCAML AC_PROG_FINDLIB AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLC" != "xno" -a "x$OCAMLFIND" != "xno"]) +AM_CONDITIONAL([HAVE_OCAMLOPT], [test "x$OCAMLOPT" != "xno" -a "x$OCAMLFIND" != "xno"]) if test "x$OCAMLC" != "xno"; then dnl Check if we have caml/unixsupport.h header (OCaml bindings only). diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 7412d8d..76c33b9 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -31,7 +31,11 @@ AM_CPPFLAGS = \ if HAVE_OCAML -noinst_DATA = mlhivex.cma mlhivex.cmxa META +noinst_DATA = mlhivex.cma META + +if HAVE_OCAMLOPT +noinst_DATA += mlhivex.cmxa +endif OBJS = hivex_c.o hivex.cmo XOBJS = $(OBJS:.cmo=.cmx) -- 1.7.5.1
On Thu, May 12, 2011 at 12:04:19AM +0200, bengen@hilluzination.de wrote:
From: Hilko Bengen <bengen@hilluzination.de>
Only compile bytecode otherwise, avoiding ocamlfind's helpful error message "ocamlfind: Not supported in your configuration: ocamlopt"
(Successfully tested on Debian/unstable on alpha)
The problem with this patch is that OCaml users won't get the native version. This is vital on platforms that do have the native compiler. The fix here must be to detect if the native version is available and compile it conditionally. ocaml-autoconf macros are already doing the detection, see: https://forge.ocamlcore.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=ocaml-autoco... 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 09:00:25AM +0100, Richard W.M. Jones wrote:
On Thu, May 12, 2011 at 12:04:19AM +0200, bengen@hilluzination.de wrote:
From: Hilko Bengen <bengen@hilluzination.de>
Only compile bytecode otherwise, avoiding ocamlfind's helpful error message "ocamlfind: Not supported in your configuration: ocamlopt"
(Successfully tested on Debian/unstable on alpha)
The problem with this patch is that OCaml users won't get the native version. This is vital on platforms that do have the native compiler.
The fix here must be to detect if the native version is available and compile it conditionally. ocaml-autoconf macros are already doing the detection, see:
Ignore that, I wasn't reading the end of the patch. ACK. I'll apply it upstream later today. 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/
From: Hilko Bengen <bengen@hilluzination.de> * Richard W.M. Jones:
Both size_t and int are 32 bit values. An endianess issue, maybe? I guess it might be. We're supposed to be doing le32toh / be32toh everywhere as appropriate, but we might be missing one. The code is mainly tested on little endian arches.
Found it. Now "make check" completes successfully on Sparc and PowerPC. --- lib/hivex.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/hivex.c b/lib/hivex.c index 2abd5bd..7715520 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -1062,7 +1062,7 @@ get_values (hive_h *h, hive_node_h node, size_t i; for (i = 0; i < nr_values; ++i) { - hive_node_h value = vlist->offset[i]; + hive_node_h value = le32toh (vlist->offset[i]); value += 0x1000; if (!IS_VALID_BLOCK (h, value)) { if (h->msglvl >= 2) -- 1.7.5.1
On Thu, May 12, 2011 at 12:04:20AM +0200, bengen@hilluzination.de wrote:
From: Hilko Bengen <bengen@hilluzination.de>
* Richard W.M. Jones:
Both size_t and int are 32 bit values. An endianess issue, maybe? I guess it might be. We're supposed to be doing le32toh / be32toh everywhere as appropriate, but we might be missing one. The code is mainly tested on little endian arches.
Found it.
Now "make check" completes successfully on Sparc and PowerPC. --- lib/hivex.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/hivex.c b/lib/hivex.c index 2abd5bd..7715520 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -1062,7 +1062,7 @@ get_values (hive_h *h, hive_node_h node,
size_t i; for (i = 0; i < nr_values; ++i) { - hive_node_h value = vlist->offset[i]; + hive_node_h value = le32toh (vlist->offset[i]); value += 0x1000; if (!IS_VALID_BLOCK (h, value)) { if (h->msglvl >= 2) -- 1.7.5.1
Very good catch! I'll push this later on today. 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 Thu, May 12, 2011 at 12:04:18AM +0200, bengen@hilluzination.de wrote:
From: Hilko Bengen <bengen@hilluzination.de>
On installations where no native OCaml compiler is available, the test program can't be compiled and so we get this message:
,---- | checking for function caml_raise_with_args... not found `----
This breaks building of the OCaml bindings.
,---- | gcc -std=gnu99 -I.. -I/usr/lib/ocaml -I../ocaml -I../lib -g -O2 -fPIC -Wall -c hivex_c.c | hivex_c.c:52: error: static declaration of 'caml_raise_with_args' follows non-static declaration | /usr/lib/ocaml/caml/fail.h:30: note: previous declaration of 'caml_raise_with_args' was here | make[2]: *** [hivex_c.o] Error 1 `----
(Successfully tested on Debian/unstable on alpha) --- configure.ac | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac index 5805ddd..ef19543 100644 --- a/configure.ac +++ b/configure.ac @@ -192,9 +192,9 @@ if test "x$OCAMLC" != "xno"; then echo "char $f (); char foo() { return $f (); }" > conftest.c rm -f conftest_ml.ml touch conftest_ml.ml - if $OCAMLOPT -c conftest.c 2>/dev/null && \ - $OCAMLOPT -c conftest_ml.ml 2>/dev/null && \ - $OCAMLOPT conftest.o conftest_ml.cmx -o conftest 2>/dev/null ; then + if $OCAMLC -c conftest.c 2>/dev/null && \ + $OCAMLC -c conftest_ml.ml 2>/dev/null && \ + $OCAMLC conftest.o conftest_ml.cmo -o conftest 2>/dev/null ; then AC_DEFINE([HAVE_CAML_RAISE_WITH_ARGS],[1], [Defined if function caml_raise_with_args exists.]) AC_MSG_RESULT([found]) -- 1.7.5.1
_______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
ACK. I'll push this later today. 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
participants (2)
-
bengen@hilluzination.de -
Richard W.M. Jones