Skip to contentSkip to conversation

ocaml: Start on fixing brokenness when no ocamlopt

PATCH In review Ian Jackson 4 participants 11 messages Jan 20, 2017 – Apr 3, 2017 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover ocaml: Start on fixing brokenness when no ocamlopt

Debian jessie arm64 has Ocaml (in the package `ocaml-nox') but the package lacks ocamlopt.

This causes xen.git builds to fail. Our configure script detects that ocaml is available. Our version of m4/ocaml.m4 sort of tries to figure out what the best compiler is but only does have the job. And then our tools/ocaml/common.make unconditionally uses ocamlopt.

I am not sure exactly how to fix this (see below) but I think these two patches are an essential start:

1/2 ocaml: Copy up-to-date m4/ocaml.m4 from forge.ocamlcore 2/2 ocaml: Substitute tools/ocaml/common.make with configure

(An alternative for 1/2 would be a git merge, which would provide the docs and git history and so on - but the ocaml-autoconf README seems to expetus to copy the m4 into our own project.)

This does not actually fix the real problem. I'm unsure how to fix it properly, for the following reasons:

ocaml.m4 expects to set OCAMLC to either ocamlopt' or failing that ocamlc'. However our ocaml Makefiles seem to explicitly call $(OCAMLOPT) in some places and and $(OCAMLC) in others.

Simply changing tools/ocaml/common.make to substitute the variables from their corresponding autoconf names seems like it isn't right.

Our Makefiles explicitly call ocamlc via OCAMLC right now even when ocamlopt is available, and substituting OCAML would change those calls to OCAMLOPT. And it wouldn't help fix the actual build failure, either, because if there is no ocamlopt, the m4 doesn't provide a useful OCAMLOPT.

FYI the ocamlforge m4 comes with a pod. You can get it from
https://forge.ocamlcore.org/anonscm/git/ocaml-autoconf/ocaml-autoconf.git

I haven't copied that into xen.git in patch 1/2. Should I ? In the meantime, a formatted copy is below.

Ian.

IO::FILE=IO(0X834C450)User Contributed Perl DocumentaIO::FILE=IO(0X834C450)(1)

NAME
ocaml.m4 - Autoconf macros for OCaml

SUMMARY

        AC_PROG_OCAML
        AC_PROG_FINDLIB
        AC_PROG_OCAMLLEX
        AC_PROG_OCAMLYACC
        AC_PROG_CAMLP4
        AC_CHECK_OCAML_PKG([name])
        AC_CHECK_OCAML_MODULE(VARIABLE,NAME,MODULE,INCLUDE-PATHS)
        AC_CHECK_OCAML_WORD_SIZE

DESCRIPTION
ocaml.m4 is a file containing standard, useful autoconf macros for detecting the OCaml, findlib, OCaml packages, and so on in your autoconf-generated ./configure scripts.

To begin using these macros, you will need to copy the "ocaml.m4" file (usually located at "/usr/share/aclocal/ocaml.m4") to the autoconf macros directory in your project. Normally this is the "m4/" directory in your project, but the directory can be changed using the "AC_CONFIG_MACRO_DIR(DIR)" directive. If you have just created the "m4/" directory, then you may also need to do:

aclocal -I m4

You can then add any of the macros described below to your "configure.ac" (or "configure.in"). Almost every OCaml project should use "AC_PROG_OCAML" first and probably "AC_PROG_FINDLIB" right after it.

This manual page does not describe how to use autoconf. For that you should read the detailed autoconf info file ("info autoconf").

AC_PROG_OCAML
This macro detects which tools of the usual OCaml toolchain are available. It defines and substitutes the following variables:

OCAMLC set to the name of the bytecode compiler
(eg. "ocamlc" or "ocamlc.opt"), or "no" if no OCaml installation was found
OCAMLOPT the name of the native-code compiler, eg. "ocamlopt",
"ocamlopt.opt" or "no"
OCAMLBEST "byte" (if only the bytecode compiler is available)
or "opt" (if both bytecode and native code compilers are available)
OCAMLNATDYNLINK "yes" (if native dynlink is available) or "no"
OCAMLDEP the name of the dependency resolver, eg. "ocamldep"
OCAMLMKTOP the name of ocamlmktop
OCAMLMKLIB the name of ocamlmklib
OCAMLDOC the name of ocamldoc
OCAMLBUILD the name of ocamlbuild
OCAMLLIB the OCaml library path (eg. C</usr/lib/ocaml/>)
OCAMLVERSION the compiler version (eg. C<3.11.0>)

Detecting if OCaml is installed
Unlike old versions of these macros, "AC_PROG_OCAML" does not exit if no OCaml installation is detected. Therefore if you want to detect if OCaml is installed you have to do something like this:

AC_PROG_OCAML
if test "$OCAMLC" = "no"; then
AC_MSG_ERROR([You must install the OCaml compiler])
fi

This behaviour and usage pattern are consistent with other macros of the "AC_PROG_*") family.

Cross-compiling
If the configure script is invoked for cross-compiling then "AC_PROG_OCAML" will detect the cross-compiler versions of the OCaml compiler, eg. "OCAMLC=i686-pc-mingw32-ocamlc" etc. This happens automatically, and for most purposes you don't need to worry about it.

AC_PROG_FINDLIB
This macro checks for the presence of the ocamlfind program (part of findlib). It defines and substitutes "OCAMLFIND" to the name of the ocamlfind program, or "no" if not found.

Note that this macro does not fail if ocamlfind is not found. If you want to force the user to install findlib, you should do:

AC_PROG_FINDLIB
if test "$OCAMLFIND" = "no"; then
AC_MSG_ERROR([You must install OCaml findlib (the ocamlfind command)])
fi

See also "AC_CHECK_OCAML_PKG".

AC_PROG_OCAMLLEX
This checks for the ocamllex program and sets "OCAMLLEX" to the name of the program (eg. "ocamllex" or "ocamllex.opt"), or "no" if not found.

AC_PROG_OCAMLYACC
This checks for the ocamlyacc program and sets "OCAMLYACC" to the name of the program, or "no" if not found.

AC_PROG_CAMLP4
This checks for camlp4, and checks that the version matches the compiler version found previously. It sets "CAMLP4" to the name of the basic camlp4 program, or "no" if not found.

The macro also checks for other tools of the camlp4 suite like camlp4o, camlp4orf, etc. For each of them, a fully capitalized variable is set to the tool name (or "no" if not found); all variable are substituted for when filling .in files. The full list of tools and respective variable names is as follows:

camlp4 CAMLP4
camlp4boot CAMLP4BOOT
camlp4o CAMLP4O
camlp4of CAMLP4OF
camlp4oof CAMLP4OOF
camlp4orf CAMLP4ORF
camlp4prof CAMLP4PROF
camlp4r CAMLP4R
camlp4rf CAMLP4RF

AC_CHECK_OCAML_PKG
This is the main macro that can be used to detect the presence of OCaml findlib packages. This macro uses ocamlfind to look up findlib packages (and thus requires that findlib itself has been installed, and that the package has been properly packaged with a META file etc.) If you want to find an OCaml findlib package which hasn't been installed with findlib then you should try using "AC_CHECK_OCAML_MODULE" instead.

AC_CHECK_OCAML_PKG([name])

checks for an OCaml findlib package with the given name. If found, it defines and substitutes the variable "OCAML_PKG_name" where the "name" part is substituted for the package name by replacing all dashes with underscores.

For example,

AC_CHECK_OCAML_PKG([xml-light])

will set "OCAML_PKG_xml_light" to either "xml-light" or "no".

To have the configure script fail if a package is not installed, do:

AC_CHECK_OCAML_PKG([foo])
if test "$OCAML_PKG_foo" = "no"; then
AC_MSG_ERROR([Please install OCaml findlib module 'foo'.])
fi

In your Makefile.in, use the substitution variable in conjunction with ocamlfind, eg:

.ml.cmo:
$(OCAMLFIND) ocamlc -package @OCAML_PKG_foo@ -c $< -o $@

Note that also in the substitution variable dashes are replaced with underscores.

Checking for alternative findlib package names
In the (unlikely) case where the same library corresponds to different findlib package names on different systems, you can improve portability by checking for the alternative names passing a second argument to "AC_CHECK_OCAML_PKG":

AC_CHECK_OCAML_PKG(PKGNAME,ALTERNATIVE-NAMES)

The behaviour is the same as before if "PKGNAME" is found. Otherwise all names in "ALTERNATIVE-NAMES" are tested in turn as findlib package names. If one is found, it is set as the value set by the macro and substituted in .in files; otherwise "no" is set.

Note that the variable name is determined by "PKGNAME", while the value depends on the actual alternative name found.

For example, to detect the camlzip findlib package, either called "zip" or "camlzip", and to store the found value in the "OCAML_PKG_zip" variable you can do in your configure.ac:

AC_CHECK_OCAML_PKG(zip,camlzip)

and have a portable Makefile.in build line such as:

.ml.cmo:
$(OCAMLFIND) ocamlc -package @OCAML_PKG_zip@ -c $< -o $@

AC_CHECK_OCAML_MODULE(VARIABLE,NAME,MODULE,INCLUDE-PATHS)
"AC_CHECK_OCAML_MODULE" is the hairier alternative to "AC_CHECK_OCAML_PKG". You should always use "AC_CHECK_OCAML_PKG" and ocamlfind/findlib if possible.

The parameters are:

VARIABLE
This is the environment variable that is set. It will either be set to the include path, or to "no" if the module was not found.

NAME
This is the name of the module we are looking for. This parameter is just used for printing messages, and does not affect how the module is found.

MODULE
This should be an OCaml module name, representing the module name being looked up. You can put sub-modules here, eg. "CalendarLib.Date"

INCLUDE-PATHS
This is the default list of include directories to search, eg. "+calendar"

For example, the following code will check for the OCaml Calendar module, and will distinguish between version 1 and version 2 of this module (which have incompatible APIs).

AC_CHECK_OCAML_PKG(calendar) AC_CHECK_OCAML_MODULE(is_calendar2,calendar,[CalendarLib.Date],[+calendar])

After the above code has run, variables "OCAML_PKG_calendar" and "is_calendar2" will be set as follows:

OCAML_PKG_calendar is_calendar2 Result

yes +calendar Calendar v2 is installed
yes no Calendar v1 is installed
no no No Calendar module installed

AC_CHECK_OCAML_WORD_SIZE
This checks the word size of the OCaml compiler, and sets "OCAML_WORD_SIZE" to either 32 or 64.

SEE ALSO

       autoconf(1), <http://ocaml-autoconf.forge.ocamlcore.org>,
       <http://caml.inria.fr/>

FILES
· /usr/share/aclocal/ocaml.m4

AUTHORS
Various people have contributed to these macros over many years:

· Olivier Andrieu

· Jean-Christophe Filliatre

· Richard W.M. Jones

· Georges Mariano

· Jim Meyering

· Stefano Zacchiroli

LICENSE
Copyright X 2009 Richard W.M. Jones
Copyright X 2009 Stefano Zacchiroli
Copyright X 2000-2005 Olivier Andrieu Copyright X 2000-2005 Jean-Christophe Filliatre Copyright X 2000-2005 Georges Mariano

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

REPORTING BUGS
Please report bugs to the authors at the project page:
<http://forge.ocamlcore.org/projects/ocaml-autoconf/>, using the forge bug tracker <http://forge.ocamlcore.org/tracker/?group_id=69>.

perl v5.20.2 2017-01-20 IO::FILE=IO(0X834C450)(1)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw

PATCH 1/2 ocaml: Copy up-to-date m4/ocaml.m4 from forge.ocamlcore

From
https://forge.ocamlcore.org/anonscm/git/ocaml-autoconf/ocaml-autoconf.git
commit id a20a590beb523fb64bf087b52a883cf628256d2f

Copy ocaml.m4, and also LICENSE to m4/ocaml.m4.LICENSE. (This is a permissive licence and thus compatible with the licence of Xen.)

We mostly want this because in this version OCAMLC is set to ocamlopt where available, or ocamlc otherwise.

---
 m4/ocaml.m4         | 96 ++++++++++++++++++++++++++++++-----------------------
 m4/ocaml.m4.LICENSE | 29 ++++++++++++++++
 2 files changed, 83 insertions(+), 42 deletions(-)
 create mode 100644 m4/ocaml.m4.LICENSE
m4/ocaml.m4 +54 -42
index b067ee9..1d3b657 100644
@@ -1,6 +1,6 @@
 dnl autoconf macros for OCaml
-dnl from http://forge.ocamlcore.org/
 dnl
+dnl Copyright © 2013      Gabriel Kerneis
 dnl Copyright © 2009      Richard W.M. Jones
 dnl Copyright © 2009      Stefano Zacchiroli
 dnl Copyright © 2000-2005 Olivier Andrieu
@@ -19,7 +19,7 @@ AC_DEFUN([AC_PROG_OCAML],
      AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
      # If OCAMLLIB is set, use it
      if test "$OCAMLLIB" = ""; then
-        OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
+        OCAMLLIB=`$OCAMLC -where 2>/dev/null | tr -d '\015' || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
      else
         AC_MSG_RESULT([OCAMLLIB previously set; preserving it.])
      fi
@@ -32,15 +32,15 @@ AC_DEFUN([AC_PROG_OCAML],
      AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no])
      OCAMLBEST=byte
      if test "$OCAMLOPT" = "no"; then
-	AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
+        AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
      else
-	TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
-	if test "$TMPVERSION" != "$OCAMLVERSION" ; then
-	    AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
-	    OCAMLOPT=no
-	else
-	    OCAMLBEST=opt
-	fi
+        TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+        if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+           AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
+           OCAMLOPT=no
+        else
+           OCAMLBEST=opt
+        fi
      fi
 
      AC_SUBST([OCAMLBEST])
@@ -48,25 +48,25 @@ AC_DEFUN([AC_PROG_OCAML],
      # checking for ocamlc.opt
      AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no])
      if test "$OCAMLCDOTOPT" != "no"; then
-	TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
-	if test "$TMPVERSION" != "$OCAMLVERSION" ; then
-	    AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
-	else
-	    OCAMLC=$OCAMLCDOTOPT
-	fi
+        TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+        if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+           AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
+        else
+           OCAMLC=$OCAMLCDOTOPT
+        fi
      fi
 
      # checking for ocamlopt.opt
      if test "$OCAMLOPT" != "no" ; then
-	AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
-	if test "$OCAMLOPTDOTOPT" != "no"; then
-	   TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
-	   if test "$TMPVERSION" != "$OCAMLVERSION" ; then
-	      AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
-	   else
-	      OCAMLOPT=$OCAMLOPTDOTOPT
-	   fi
-        fi
+        AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
+        if test "$OCAMLOPTDOTOPT" != "no"; then
+           TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+           if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+              AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
+           else
+              OCAMLOPT=$OCAMLOPTDOTOPT
+           fi
+       fi
      fi
 
      AC_SUBST([OCAMLOPT])
@@ -74,6 +74,18 @@ AC_DEFUN([AC_PROG_OCAML],
 
   AC_SUBST([OCAMLC])
 
+  # checking for native dynlink
+  AC_MSG_CHECKING([for dynlink.cmxa])
+  if test -f "$OCAMLLIB/dynlink.cmxa" ; then
+     OCAMLNATDYNLINK=yes
+     AC_MSG_RESULT([yes])
+  else
+     OCAMLNATDYNLINK=no
+     AC_MSG_RESULT([no])
+  fi
+
+  AC_SUBST([OCAMLNATDYNLINK])
+
   # checking for ocaml toplevel
   AC_CHECK_TOOL([OCAML],[ocaml],[no])
 
@@ -99,10 +111,10 @@ AC_DEFUN([AC_PROG_OCAMLLEX],
   # checking for ocamllex
   AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no])
   if test "$OCAMLLEX" != "no"; then
-    AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
-    if test "$OCAMLLEXDOTOPT" != "no"; then
-	OCAMLLEX=$OCAMLLEXDOTOPT
-    fi
+     AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
+     if test "$OCAMLLEXDOTOPT" != "no"; then
+        OCAMLLEX=$OCAMLLEXDOTOPT
+     fi
   fi
   AC_SUBST([OCAMLLEX])
 ])
@@ -123,7 +135,7 @@ AC_DEFUN([AC_PROG_CAMLP4],
   if test "$CAMLP4" != "no"; then
      TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
      if test "$TMPVERSION" != "$OCAMLVERSION" ; then
-	AC_MSG_RESULT([versions differs from ocamlc])
+        AC_MSG_RESULT([versions differs from ocamlc])
         CAMLP4=no
      fi
   fi
@@ -173,15 +185,15 @@ AC_DEFUN([AC_CHECK_OCAML_PKG],
   found=no
   for pkg in $1 $2 ; do
     if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
-      AC_MSG_RESULT([found])
-      AS_TR_SH([OCAML_PKG_$1])=$pkg
-      found=yes
-      break
+       AC_MSG_RESULT([found])
+       AS_TR_SH([OCAML_PKG_$1])=$pkg
+       found=yes
+       break
     fi
   done
   if test "$found" = "no" ; then
-    AC_MSG_RESULT([not found])
-    AS_TR_SH([OCAML_PKG_$1])=no
+     AC_MSG_RESULT([not found])
+     AS_TR_SH([OCAML_PKG_$1])=no
   fi
 
   AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
@@ -198,16 +210,16 @@ EOF
   unset found
   for $1 in $$1 $4 ; do
     if $OCAMLC -c -I "$$1" conftest.ml >&5 2>&5 ; then
-      found=yes
-      break
+       found=yes
+       break
     fi
   done
 
   if test "$found" ; then
-    AC_MSG_RESULT([$$1])
+     AC_MSG_RESULT([$$1])
   else
-    AC_MSG_RESULT([not found])
-    $1=no
+     AC_MSG_RESULT([not found])
+     $1=no
   fi
   AC_SUBST([$1])
 ])
@@ -220,7 +232,7 @@ AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
   AC_MSG_CHECKING([for OCaml compiler word size])
   cat > conftest.ml <<EOF
   print_endline (string_of_int Sys.word_size)
-  EOF
+EOF
   OCAML_WORD_SIZE=`$OCAML conftest.ml`
   AC_MSG_RESULT([$OCAML_WORD_SIZE])
   AC_SUBST([OCAML_WORD_SIZE])
m4/ocaml.m4.LICENSE new file +29 -0
new file mode 100644
index 0000000..d4d3d16
@@ -0,0 +1,29 @@
+Copyright © 2013      Gabriel Kerneis
+Copyright © 2009      Richard W.M. Jones
+Copyright © 2009      Stefano Zacchiroli
+Copyright © 2000-2005 Olivier Andrieu
+Copyright © 2000-2005 Jean-Christophe Filliâtre
+Copyright © 2000-2005 Georges Mariano
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+* The names of the contributors may not be used to endorse or promote
+products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

PATCH 2/2 ocaml: Substitute tools/ocaml/common.make with configure

In reply to Ian Jackson

Rename tools/ocaml/common.make to .in, and add it to the list of files to generate. Add it to .gitignore.

---
 .gitignore                 |  1 +
 tools/configure.ac         |  1 +
 tools/ocaml/common.make    | 22 ----------------------
 tools/ocaml/common.make.in | 22 ++++++++++++++++++++++
 4 files changed, 24 insertions(+), 22 deletions(-)
 delete mode 100644 tools/ocaml/common.make
 create mode 100644 tools/ocaml/common.make.in
.gitignore +1 -0
index 01ad29e..ce4dc7b 100644
@@ -37,6 +37,7 @@ config.status
 config.cache
 config/Toplevel.mk
 config/Paths.mk
+tools/ocaml/common.make
 
 build-*
 dist/*
tools/configure.ac +1 -0
index 873e18d..ca855f6 100644
@@ -7,6 +7,7 @@ AC_INIT([Xen Hypervisor Tools], m4_esyscmd([../version.sh ../xen/Makefile]),
 AC_CONFIG_SRCDIR([libxl/libxl.c])
 AC_CONFIG_FILES([
 ../config/Tools.mk
+ocaml/common.make
 hotplug/FreeBSD/rc.d/xencommons
 hotplug/FreeBSD/rc.d/xendriverdomain
 hotplug/Linux/init.d/sysconfig.xencommons
tools/ocaml/common.make deleted +0 -22
deleted file mode 100644
index d5478f6..0000000
@@ -1,22 +0,0 @@
-include $(XEN_ROOT)/tools/Rules.mk
-
-CC ?= gcc
-OCAMLOPT ?= ocamlopt
-OCAMLC ?= ocamlc
-OCAMLMKLIB ?= ocamlmklib
-OCAMLDEP ?= ocamldep
-OCAMLLEX ?= ocamllex
-OCAMLYACC ?= ocamlyacc
-OCAMLFIND ?= ocamlfind
-
-CFLAGS += -fPIC -Werror -I$(shell ocamlc -where)
-
-OCAMLOPTFLAG_G := $(shell $(OCAMLOPT) -h 2>&1 | sed -n 's/^  *\(-g\) .*/\1/p')
-OCAMLOPTFLAGS = $(OCAMLOPTFLAG_G) -ccopt "$(LDFLAGS)" -dtypes $(OCAMLINCLUDE) -cc $(CC) -w F -warn-error F
-OCAMLCFLAGS += -g $(OCAMLINCLUDE) -w F -warn-error F
-
-VERSION := 4.1
-
-OCAMLDESTDIR ?= $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir)
-
-o= >[email protected] && mv -f [email protected] $@
tools/ocaml/common.make.in new file +22 -0
new file mode 100644
index 0000000..d5478f6
@@ -0,0 +1,22 @@
+include $(XEN_ROOT)/tools/Rules.mk
+
+CC ?= gcc
+OCAMLOPT ?= ocamlopt
+OCAMLC ?= ocamlc
+OCAMLMKLIB ?= ocamlmklib
+OCAMLDEP ?= ocamldep
+OCAMLLEX ?= ocamllex
+OCAMLYACC ?= ocamlyacc
+OCAMLFIND ?= ocamlfind
+
+CFLAGS += -fPIC -Werror -I$(shell ocamlc -where)
+
+OCAMLOPTFLAG_G := $(shell $(OCAMLOPT) -h 2>&1 | sed -n 's/^  *\(-g\) .*/\1/p')
+OCAMLOPTFLAGS = $(OCAMLOPTFLAG_G) -ccopt "$(LDFLAGS)" -dtypes $(OCAMLINCLUDE) -cc $(CC) -w F -warn-error F
+OCAMLCFLAGS += -g $(OCAMLINCLUDE) -w F -warn-error F
+
+VERSION := 4.1
+
+OCAMLDESTDIR ?= $(DESTDIR)$(shell $(OCAMLFIND) printconf destdir)
+
+o= >[email protected] && mv -f [email protected] $@
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#3 lore raw
In reply to Ian Jackson

Ian Jackson writes ("[PATCH 0/2] ocaml: Start on fixing brokenness when no ocamlopt"):

Quoted 2 lines

Debian jessie arm64 has Ocaml (in the package `ocaml-nox') but the package lacks ocamlopt.

...

Quoted 2 lines

This does not actually fix the real problem. I'm unsure how to fix it properly, for the following reasons:

Can I have some input from ocaml folks ?

The first ARM64 boxes in the Xen Project test lab are in principle now online, but this bug is stopping osstest actually getting as far as trying to boot Xen.

Quoted 13 lines

ocaml.m4 expects to set OCAMLC to either ocamlopt' or failing that ocamlc'. However our ocaml Makefiles seem to explicitly call $(OCAMLOPT) in some places and and $(OCAMLC) in others.

Simply changing tools/ocaml/common.make to substitute the variables from their corresponding autoconf names seems like it isn't right.

Our Makefiles explicitly call ocamlc via OCAMLC right now even when ocamlopt is available, and substituting OCAML would change those calls to OCAMLOPT. And it wouldn't help fix the actual build failure, either, because if there is no ocamlopt, the m4 doesn't provide a useful OCAMLOPT.

Quoted 5 lines

FYI the ocamlforge m4 comes with a pod. You can get it from
https://forge.ocamlcore.org/anonscm/git/ocaml-autoconf/ocaml-autoconf.git

I haven't copied that into xen.git in patch 1/2. Should I ? In the meantime, a formatted copy is below.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 7 lines · Ian Jackson

Ian Jackson writes ("[PATCH 0/2] ocaml: Start on fixing brokenness when no ocamlopt"):

Quoted 2 lines

Debian jessie arm64 has Ocaml (in the package `ocaml-nox') but the package lacks ocamlopt.

...

Quoted 12 lines
Quoted 2 lines

This does not actually fix the real problem. I'm unsure how to fix it properly, for the following reasons:

Can I have some input from ocaml folks ?

The first ARM64 boxes in the Xen Project test lab are in principle now online, but this bug is stopping osstest actually getting as far as trying to boot Xen.

Quoted 3 lines

ocaml.m4 expects to set OCAMLC to either ocamlopt' or failing that ocamlc'. However our ocaml Makefiles seem to explicitly call $(OCAMLOPT) in some places and and $(OCAMLC) in others.

I’m terrible at reading m4 and am really bad with autoconf so I may have got this wrong but does it set OCAMLC to ocamlopt or ocamlc.opt? Where

ocamlc: outputs bytecode, and is a bytecode executable itself ocamlc.opt: outputs bytecode, and is a native code executable itself ocamlopt: outputs native code, and is a bytecode executable itself ocamlopt.opt: outputs native code, and is a native code executable itself

Both ocamlc and ocamlc.opt should be interchangeable: same command-line arguments, exactly the same output. Same for ocamlopt and ocamlopt.opt.

I _think_ the m4 is looking for ocamlc.opt because it’s an optimised native (therefore faster) version of ocamlc. It should be fine to set OCAMLC to either.

The tools/ocaml/Makefile.rules does contain rules for both bytecode outputs (e.g. *.cmo *.cma) and native code outputs (*.cmx *.cmxa). I believe *.cmi can be created by either ocamlc (ocamlc.opt) or ocamlopt (ocamlopt.opt).

I’m a bit suspicious of the tools/ocaml/xenstored/Makefile where it refers directly to *.cmxa files which are native-code only— I don’t see how that could work for bytecode outputs.

Do you have a link to the build failure?

Thanks,
Dave

Quoted 10 lines
Quoted 10 lines

Simply changing tools/ocaml/common.make to substitute the variables from their corresponding autoconf names seems like it isn't right.

Our Makefiles explicitly call ocamlc via OCAMLC right now even when ocamlopt is available, and substituting OCAML would change those calls to OCAMLOPT. And it wouldn't help fix the actual build failure, either, because if there is no ocamlopt, the m4 doesn't provide a useful OCAMLOPT.

Quoted 8 lines
Quoted 5 lines

FYI the ocamlforge m4 comes with a pod. You can get it from
https://forge.ocamlcore.org/anonscm/git/ocaml-autoconf/ocaml-autoconf.git

I haven't copied that into xen.git in patch 1/2. Should I ? In the meantime, a formatted copy is below.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw

Hi,

Quoted 39 lines · David Scott
Quoted 7 lines · Ian Jackson

Ian Jackson writes ("[PATCH 0/2] ocaml: Start on fixing brokenness when no ocamlopt"):

Quoted 2 lines

Debian jessie arm64 has Ocaml (in the package `ocaml-nox') but the package lacks ocamlopt.

...

Quoted 12 lines
Quoted 2 lines

This does not actually fix the real problem. I'm unsure how to fix it properly, for the following reasons:

Can I have some input from ocaml folks ?

The first ARM64 boxes in the Xen Project test lab are in principle now online, but this bug is stopping osstest actually getting as far as trying to boot Xen.

Quoted 3 lines

ocaml.m4 expects to set OCAMLC to either ocamlopt' or failing that ocamlc'. However our ocaml Makefiles seem to explicitly call $(OCAMLOPT) in some places and and $(OCAMLC) in others.

I’m terrible at reading m4 and am really bad with autoconf so I may have got this wrong but does it set OCAMLC to ocamlopt or ocamlc.opt? Where

ocamlc: outputs bytecode, and is a bytecode executable itself ocamlc.opt: outputs bytecode, and is a native code executable itself ocamlopt: outputs native code, and is a bytecode executable itself ocamlopt.opt: outputs native code, and is a native code executable itself

Both ocamlc and ocamlc.opt should be interchangeable: same command-line arguments, exactly the same output. Same for ocamlopt and ocamlopt.opt.

I _think_ the m4 is looking for ocamlc.opt because it’s an optimised native (therefore faster) version of ocamlc. It should be fine to set OCAMLC to either.

The tools/ocaml/Makefile.rules does contain rules for both bytecode outputs (e.g. *.cmo *.cma) and native code outputs (*.cmx *.cmxa). I believe *.cmi can be created by either ocamlc (ocamlc.opt) or ocamlopt (ocamlopt.opt).

Quoted 5 lines

I’m a bit suspicious of the tools/ocaml/xenstored/Makefile where it refers directly to *.cmxa files which are native-code only— I don’t see how that could work for bytecode outputs.

Do you have a link to the build failure?

Here a link for the build failure:

http://logs.test-lab.xenproject.org/osstest/logs/105644/build-arm64/5.ts-xen-build.log

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#6 lore raw

Hi,

Ping? As Ian mentioned earlier, without this series it is not possible to build Xen tools for ARM64 in osstest.

Cheers,

Quoted 54 lines · Julien Grall

Hi,

Quoted 39 lines · David Scott
Quoted 7 lines · Ian Jackson

Ian Jackson writes ("[PATCH 0/2] ocaml: Start on fixing brokenness when no ocamlopt"):

Quoted 2 lines

Debian jessie arm64 has Ocaml (in the package `ocaml-nox') but the package lacks ocamlopt.

...

Quoted 12 lines
Quoted 2 lines

This does not actually fix the real problem. I'm unsure how to fix it properly, for the following reasons:

Can I have some input from ocaml folks ?

The first ARM64 boxes in the Xen Project test lab are in principle now online, but this bug is stopping osstest actually getting as far as trying to boot Xen.

Quoted 3 lines

ocaml.m4 expects to set OCAMLC to either ocamlopt' or failing that ocamlc'. However our ocaml Makefiles seem to explicitly call $(OCAMLOPT) in some places and and $(OCAMLC) in others.

I’m terrible at reading m4 and am really bad with autoconf so I may have got this wrong but does it set OCAMLC to ocamlopt or ocamlc.opt? Where

ocamlc: outputs bytecode, and is a bytecode executable itself ocamlc.opt: outputs bytecode, and is a native code executable itself ocamlopt: outputs native code, and is a bytecode executable itself ocamlopt.opt: outputs native code, and is a native code executable itself

Both ocamlc and ocamlc.opt should be interchangeable: same command-line arguments, exactly the same output. Same for ocamlopt and ocamlopt.opt.

I _think_ the m4 is looking for ocamlc.opt because it’s an optimised native (therefore faster) version of ocamlc. It should be fine to set OCAMLC to either.

The tools/ocaml/Makefile.rules does contain rules for both bytecode outputs (e.g. *.cmo *.cma) and native code outputs (*.cmx *.cmxa). I believe *.cmi can be created by either ocamlc (ocamlc.opt) or ocamlopt (ocamlopt.opt).

Quoted 5 lines

I’m a bit suspicious of the tools/ocaml/xenstored/Makefile where it refers directly to *.cmxa files which are native-code only— I don’t see how that could work for bytecode outputs.

Do you have a link to the build failure?

Here a link for the build failure:

http://logs.test-lab.xenproject.org/osstest/logs/105644/build-arm64/5.ts-xen-build.log

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#7 lore raw

(Resending the e-mail due to SMTP issue)

Quoted 76 lines · Julien Grall

Hi,

Ping? As Ian mentioned earlier, without this series it is not possible to build Xen tools for ARM64 in osstest.

Cheers,

Quoted 67 lines · Julien Grall

Hi,

Quoted 49 lines · David Scott
Quoted 9 lines

On 24 Jan 2017, at 11:35, Ian Jackson <[email protected]> wrote:

Ian Jackson writes ("[PATCH 0/2] ocaml: Start on fixing brokenness when no ocamlopt"):

Quoted 2 lines

Debian jessie arm64 has Ocaml (in the package `ocaml-nox') but the package lacks ocamlopt.

...

Quoted 12 lines
Quoted 2 lines

This does not actually fix the real problem. I'm unsure how to fix it properly, for the following reasons:

Can I have some input from ocaml folks ?

The first ARM64 boxes in the Xen Project test lab are in principle now online, but this bug is stopping osstest actually getting as far as trying to boot Xen.

Quoted 3 lines

ocaml.m4 expects to set OCAMLC to either ocamlopt' or failing that ocamlc'. However our ocaml Makefiles seem to explicitly call $(OCAMLOPT) in some places and and $(OCAMLC) in others.

I’m terrible at reading m4 and am really bad with autoconf so I may have got this wrong but does it set OCAMLC to ocamlopt or ocamlc.opt? Where

ocamlc: outputs bytecode, and is a bytecode executable itself ocamlc.opt: outputs bytecode, and is a native code executable itself ocamlopt: outputs native code, and is a bytecode executable itself ocamlopt.opt: outputs native code, and is a native code executable itself

Both ocamlc and ocamlc.opt should be interchangeable: same command-line
arguments, exactly the same output. Same for ocamlopt and ocamlopt.opt.

I _think_ the m4 is looking for ocamlc.opt because it’s an optimised native
(therefore faster) version of ocamlc. It should be fine to set OCAMLC
to either.

The tools/ocaml/Makefile.rules does contain rules for both bytecode outputs
(e.g. *.cmo *.cma) and native code outputs (*.cmx *.cmxa). I believe *.cmi
can be created by either ocamlc (ocamlc.opt) or ocamlopt (ocamlopt.opt).

Quoted 7 lines

I’m a bit suspicious of the tools/ocaml/xenstored/Makefile where it refers
directly to *.cmxa files which are native-code only— I don’t see how that
could work for bytecode outputs.

Do you have a link to the build failure?

Here a link for the build failure:

http://logs.test-lab.xenproject.org/osstest/logs/105644/build-arm64/5.ts-xen-build.log

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#10 lore raw

Re: ARM64 hardware in osstest (WAS: [PATCH 0/2] ocaml: Start on fixing brokenness when no ocamlopt)

In reply to a message not in the archive

Hi. Christian Lindig of Citrix has been looking into our ARM64 ocaml build problem. See attached mail from him.

(NB: xen-devel added to CC list.)

Quoted 5 lines · Christian

My short-term strategy would be to exclude the ocaml xenstored on architectures that don’t support the native code OCaml compiler. This does not exclude ARM64 in general because the OCaml native code compiler is available for ARM64 - maybe just not on the release that is being used for tests - I haven’t looked into this.

Thanks for the investigation.

Indeed, we are running our tests on Debian jessie, which has only the bytecode compiler for ocaml on arm64. In the general case, until we get a better solution, given that some versions of some operating systems have only the bytecode compiler, I think would we need to exclude the ocaml xenstored on _operating systems_ that don't have the native code ocaml compiler.

This ought to be done automatically by our configure script. Currently the configure script detects that there is "some ocaml support" and then tries to use the native compiler.

Christian, can you advise what the correct test should be to check whether the native code compiler is available ? I can then try to make a patch to our autoconfery, and maybe you would be able to review it. Or if you prefer to make that patch I'd be happy to review it of course.

Quoted 5 lines

In the long run I would suggest to simplify the build process of the OCaml part by using OCamlbuild and (possibly) Oasis which leads to a much simpler specification of the build targets and would cleanly support compiling for bytecode and native binaries, if this is possible at all.

That sounds nice.

But I think we have probably passed the point in this Xen release where we want to make such a change to the build system. I'll let Julien (Xen Project release manager) decide on that for sure, but I think this probably ought to be a post-4.9 task.

Regards,
Ian.

Hi Ian,

Please feel free to share this with the Xen maintainers. I’ve looked into tools/ocaml/xenstored and why this does not compile with only the OCaml byte code compiler available - as it is on ARM64:

* The configure process detects correctly when the native code compiler in unavailable - good.
* Makefiles, however, request unconditionally native code libraries (*.cmxa) in LIBS, which are part of the default “all” target.

eventchn/Makefile:LIBS = xeneventchn.cma xeneventchn.cmxa mmap/Makefile:LIBS = xenmmap.cma xenmmap.cmxa xb/Makefile:LIBS = xenbus.cma xenbus.cmxa xc/Makefile:LIBS = xenctrl.cma xenctrl.cmxa xentoollog/Makefile:LIBS = xentoollog.cma xentoollog.cmxa xl/Makefile:LIBS = xenlight.cma xenlight.cmxa xs/Makefile:LIBS = xenstore.cma xenstore.cmxa

This triggers rules to compile code to native code, which in the absence of the native code compiler fails. I haven’t looked further - maybe it is possible to make this work with byte code only but it will only compound to the already pretty complicated Makefiles.

My short-term strategy would be to exclude the ocaml xenstored on architectures that don’t support the native code OCaml compiler. This does not exclude ARM64 in general because the OCaml native code compiler is available for ARM64 - maybe just not on the release that is being used for tests - I haven’t looked into this.

In the long run I would suggest to simplify the build process of the OCaml part by using OCamlbuild and (possibly) Oasis which leads to a much simpler specification of the build targets and would cleanly support compiling for bytecode and native binaries, if this is possible at all.

Cheers

— Christian

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw

Re: ARM64 hardware in osstest (WAS: [PATCH 0/2] ocaml: Start on fixing brokenness when no ocamlopt)

Quoted 8 lines · Ian Jackson

Christian, can you advise what the correct test should be to check whether the native code compiler is available ? I can then try to make a patch to our autoconfery, and maybe you would be able to review it. Or if you prefer to make that patch I'd be happy to review it of course.

Native code compilation is available when either ocamlopt or ocamlopt.opt is in the PATH. The byte code compilers are ocamlc and ocamlc.opt and at least one of them should be in the PATH. This should be easy to check with autoconf. This assumes that the compiler installation is otherwise reasonable such that autoconf does not have to check for all other tools that compilation depends on. While it is conceivable that only the native code compilers are available and not the byte code compilers, I would not plan for that.

The difference between {ocamlc,ocamlopt}.opt and {ocamlc,ocamlopt} is that the .opt compilers are themselves native binaries but they create the same code - so ocamlopt and ocamlopt.opt will create the same native binary but the .opt variant is compiling code a bit quicker.

I’ll try to get byte-code-only compilation of xenstored to work and would be happy if you would improve the autoconf part.

Cheers

— Christian
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#12 lore raw

Re: ARM64 hardware in osstest (WAS: [PATCH 0/2] ocaml: Start on fixing brokenness when no ocamlopt)

In reply to Ian Jackson

Hi Ian,

Quoted 12 lines · Ian Jackson

Hi. Christian Lindig of Citrix has been looking into our ARM64 ocaml build problem. See attached mail from him.

(NB: xen-devel added to CC list.)

Quoted 5 lines · Christian

My short-term strategy would be to exclude the ocaml xenstored on architectures that don’t support the native code OCaml compiler. This does not exclude ARM64 in general because the OCaml native code compiler is available for ARM64 - maybe just not on the release that is being used for tests - I haven’t looked into this.

Quoted 8 lines

Thanks for the investigation.

Indeed, we are running our tests on Debian jessie, which has only the bytecode compiler for ocaml on arm64. In the general case, until we get a better solution, given that some versions of some operating systems have only the bytecode compiler, I think would we need to exclude the ocaml xenstored on _operating systems_ that don't have the native code ocaml compiler.

This sounds a good solution for Xen 4.9.

Quoted 17 lines

This ought to be done automatically by our configure script. Currently the configure script detects that there is "some ocaml support" and then tries to use the native compiler.

Christian, can you advise what the correct test should be to check whether the native code compiler is available ? I can then try to make a patch to our autoconfery, and maybe you would be able to review it. Or if you prefer to make that patch I'd be happy to review it of course.

Quoted 5 lines

In the long run I would suggest to simplify the build process of the OCaml part by using OCamlbuild and (possibly) Oasis which leads to a much simpler specification of the build targets and would cleanly support compiling for bytecode and native binaries, if this is possible at all.

Quoted 6 lines

That sounds nice.

But I think we have probably passed the point in this Xen release where we want to make such a change to the build system. I'll let Julien (Xen Project release manager) decide on that for sure, but I think this probably ought to be a post-4.9 task.

I agree here. The code freeze is at the end of the week and I would avoid to change the build system too much.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel