Richard W.M. Jones
2017-Nov-14 18:02 UTC
[Libguestfs] [PATCH v2] daemon: Use a configure-time test to find the best OCaml
v1 was here: https://www.redhat.com/archives/libguestfs/2017-November/msg00068.html v1 -> v2: - Use a configure-time test. Rich.
Richard W.M. Jones
2017-Nov-14 18:02 UTC
[Libguestfs] [PATCH v2] daemon: Use a configure-time test to find the best OCaml runtime.
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]) fi OCAML_PKG_gettext=no -- 2.13.2
Pino Toscano
2017-Nov-15 16:42 UTC
Re: [Libguestfs] [PATCH v2] daemon: Use a configure-time test to find the best OCaml runtime.
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
Apparently Analagous Threads
- [PATCH v2] daemon: Use a configure-time test to find the best OCaml
- [PATCH] daemon: Link daemon to -lasmrun_pic.
- [PATCH v2 3/3] daemon: Restore PCRE regular expressions in OCaml code.
- Re: [PATCH v2 00/23] Reimplement many daemon APIs in OCaml.
- [PATCH 02/27] daemon: Allow parts of the daemon and APIs to be written in OCaml.