[Libguestfs] [PATCH v2] daemon: Use a configure-time test to find the best OCaml runtime.
Pino Toscano
ptoscano at redhat.com
Wed Nov 15 16:42:02 UTC 2017
On Tuesday, 14 November 2017 19:02:51 CET Richard W.M. Jones wrote:
> In OCaml 4.06 we need to link to daemon to libasmrun_pic.a (the OCaml
> runtime linked with -fPIC). Otherwise you will see many errors like
> this:
>
> /usr/bin/ld: /usr/lib64/ocaml/libasmrun.a(startup_aux.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib64/ocaml/libasmrun.a(startup.o): relocation R_X86_64_32S against symbol `caml_data_segments' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib64/ocaml/libasmrun.a(fail.o): relocation R_X86_64_32 against symbol `caml_exn_Failure' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib64/ocaml/libasmrun.a(roots.o): relocation R_X86_64_32 against symbol `caml_frametable' can not be used when making a shared object; recompile with -fPIC
>
> This commit use a configure-time test to find the best OCaml runtime.
> ---
> daemon/Makefile.am | 2 --
> m4/guestfs-ocaml.m4 | 26 ++++++++++++++++++++++++++
> 2 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/daemon/Makefile.am b/daemon/Makefile.am
> index af3184d3e..27630d2bc 100644
> --- a/daemon/Makefile.am
> +++ b/daemon/Makefile.am
> @@ -328,10 +328,8 @@ OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
>
> if !HAVE_OCAMLOPT
> OBJECTS = $(BOBJECTS)
> -CAMLRUN = camlrun
> else
> OBJECTS = $(XOBJECTS)
> -CAMLRUN = asmrun
> endif
> OCAML_LIBS = \
> -lmlpcre \
> diff --git a/m4/guestfs-ocaml.m4 b/m4/guestfs-ocaml.m4
> index 54ad355cd..3f78d1fb3 100644
> --- a/m4/guestfs-ocaml.m4
> +++ b/m4/guestfs-ocaml.m4
> @@ -85,6 +85,32 @@ if test "x$enable_daemon" = "xyes"; then
> if test "x$OCAML_PKG_hivex" = "xno"; then
> AC_MSG_ERROR([the OCaml module 'hivex' is required])
> fi
> +
> + dnl Check which OCaml runtime to link the daemon again.
> + dnl We can't use AC_CHECK_LIB here unfortunately because
> + dnl the other symbols are resolved by OCaml itself.
> + AC_MSG_CHECKING([which OCaml runtime we should link the daemon with])
> + if test "x$OCAMLOPT" != "xno"; then
> + for f in asmrun_pic asmrun; do
> + if test -f "$OCAMLLIB/lib$f.a"; then
> + CAMLRUN=$f
> + break
> + fi
> + done
> + else
> + for f in camlrun; do
> + if test -f "$OCAMLLIB/lib$f.a"; then
> + CAMLRUN=$f
> + break
> + fi
> + done
> + fi
> + if test "x$CAMLRUN" != "x"; then
> + AC_MSG_RESULT([$CAMLRUN])
> + else
> + AC_MSG_ERROR([could not find or link to libasmrun or libcamlrun])
> + fi
> + AC_SUBST([CAMLRUN])
LGTM.
Thanks,
--
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20171115/cdd886eb/attachment.sig>
More information about the Libguestfs
mailing list