Martin Kletzander
2019-Jun-12 11:27 UTC
[Libguestfs] [libnbd PATCH] Fix building with for ocaml < 4.06.0
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- Notes: This is the simplest solution suggested to me by Rich and it works. Most of autotools are not friends with me, so the other approach I tried, with requiring at least OCaml 4.05.0, having this fix in only for OCaml < 4.06.0 and properly detecting and reporting that, was a bit ugly. You can see the configure.ac part of it here: http://ix.io/1L0o If that is preferred, then I can send that one instead. ocaml/nbd-c.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ocaml/nbd-c.h b/ocaml/nbd-c.h index 558581850807..45ae64d77209 100644 --- a/ocaml/nbd-c.h +++ b/ocaml/nbd-c.h @@ -27,6 +27,11 @@ #include <caml/memory.h> #include <caml/mlvalues.h> +// Workaround for OCaml < 4.06.0 +#ifndef Bytes_val +#define Bytes_val(x) String_val(x) +#endif + extern void libnbd_finalize (value); extern void nbd_buffer_finalize (value); -- 2.21.0
Pino Toscano
2019-Jun-12 11:53 UTC
Re: [Libguestfs] [libnbd PATCH] Fix building with for ocaml < 4.06.0
On Wednesday, 12 June 2019 13:27:34 CEST Martin Kletzander wrote:> Signed-off-by: Martin Kletzander <mkletzan@redhat.com> > --- > > Notes: > This is the simplest solution suggested to me by Rich and it works. > > Most of autotools are not friends with me, so the other approach I tried, with > requiring at least OCaml 4.05.0, having this fix in only for OCaml < 4.06.0 and > properly detecting and reporting that, was a bit ugly. > > You can see the configure.ac part of it here: http://ix.io/1L0oIt is not that bad IMHO -- just ignore the "micro" part of the version, as it not needed, and use a similar approach of libguestfs: https://github.com/libguestfs/libguestfs/blob/master/m4/guestfs-ocaml.m4#L41 -- Pino Toscano
Eric Blake
2019-Jun-12 13:02 UTC
Re: [Libguestfs] [libnbd PATCH] Fix building with for ocaml < 4.06.0
On 6/12/19 6:27 AM, Martin Kletzander wrote:> Signed-off-by: Martin Kletzander <mkletzan@redhat.com> > --- > > Notes: > This is the simplest solution suggested to me by Rich and it works. > > Most of autotools are not friends with me, so the other approach I tried, with > requiring at least OCaml 4.05.0, having this fix in only for OCaml < 4.06.0 and > properly detecting and reporting that, was a bit ugly.I prefer the lightweight approach - all the more configure.ac does is add the ability to do #ifdef-ery probing on things that don't originally come with enough #ifdef witnesses; but here, the absence of Bytes_val is all the more that you would probe for in configure.ac, making it not worth the effort to add yet another macro just to work around the problem. Which platform are you compiling on, and what OCaml version are you using? That said, I don't see any reason to not commit this patch. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Richard W.M. Jones
2019-Jun-12 21:02 UTC
Re: [Libguestfs] [libnbd PATCH] Fix building with for ocaml < 4.06.0
On Wed, Jun 12, 2019 at 01:27:34PM +0200, Martin Kletzander wrote:> Signed-off-by: Martin Kletzander <mkletzan@redhat.com> > --- > > Notes: > This is the simplest solution suggested to me by Rich and it works. > > Most of autotools are not friends with me, so the other approach I tried, with > requiring at least OCaml 4.05.0, having this fix in only for OCaml < 4.06.0 and > properly detecting and reporting that, was a bit ugly. > > You can see the configure.ac part of it here: http://ix.io/1L0o > > If that is preferred, then I can send that one instead. > > ocaml/nbd-c.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/ocaml/nbd-c.h b/ocaml/nbd-c.h > index 558581850807..45ae64d77209 100644 > --- a/ocaml/nbd-c.h > +++ b/ocaml/nbd-c.h > @@ -27,6 +27,11 @@ > #include <caml/memory.h> > #include <caml/mlvalues.h> > > +// Workaround for OCaml < 4.06.0 > +#ifndef Bytes_val > +#define Bytes_val(x) String_val(x) > +#endif > + > extern void libnbd_finalize (value); > extern void nbd_buffer_finalize (value);The configure.ac changes are a bit more complex, and this should work for versions of OCaml which have the bytes type but not this macro. OCaml 4.02 introduced the bytes type in 2014, so this (probably - I did not test) fixes things back to then. So I will push this shortly, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Martin Kletzander
2019-Jun-12 21:25 UTC
Re: [Libguestfs] [libnbd PATCH] Fix building with for ocaml < 4.06.0
On Wed, Jun 12, 2019 at 08:02:06AM -0500, Eric Blake wrote:>On 6/12/19 6:27 AM, Martin Kletzander wrote: >> Signed-off-by: Martin Kletzander <mkletzan@redhat.com> >> --- >> >> Notes: >> This is the simplest solution suggested to me by Rich and it works. >> >> Most of autotools are not friends with me, so the other approach I tried, with >> requiring at least OCaml 4.05.0, having this fix in only for OCaml < 4.06.0 and >> properly detecting and reporting that, was a bit ugly. > >I prefer the lightweight approach - all the more configure.ac does is >add the ability to do #ifdef-ery probing on things that don't originally >come with enough #ifdef witnesses; but here, the absence of Bytes_val is >all the more that you would probe for in configure.ac, making it not >worth the effort to add yet another macro just to work around the problem. > >Which platform are you compiling on, and what OCaml version are you >using? That said, I don't see any reason to not commit this patch. >Gentoo, OCaml 4.05.0 in the system, but 4.07.0 through opam. I noticed I cannot build it when I added it as a package and wanted to install it into the system.>-- >Eric Blake, Principal Software Engineer >Red Hat, Inc. +1-919-301-3226 >Virtualization: qemu.org | libvirt.org >
Maybe Matching Threads
- [libnbd PATCH] Fix building with for ocaml < 4.06.0
- [PATCH libnbd 3/7] ocaml: Remove NBD.Buffer.free function, use a free callback instead.
- [PATCH libnbd 2/2] ocaml: Remove NBD.Buffer.free function, use the completion callback instead.
- [libnbd PATCH] RFC: Add bindings for Rust language
- Re: [PATCH libnbd 0/2] Two patches to make libnbd work on FreeBSD.