|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC] ocaml: Fix compile with ocaml 4.06, use unsafe strings
Use autoconf to test if ocaml version >= 4.02
If so, use -unsafe-string for ocamlopt and ocamlc
Bytes & safe-string were introduced in ocaml 4.02 (2015-07-27)
With ocaml 4.06, -safe-string is now default
This separates the types bytes (mutable string) and string
ocaml 4.06 throws errors in compiling:
/build/xen/src/xen-4.10.0/tools/ocaml/libs/xc
File "xenctrl.ml", line 295, characters 44-45:
Error: This expression has type bytes but an expression was expected of type
string
File "xenctrl.ml", line 296, characters 25-26:
Error: This expression has type bytes but an expression was expected of type
string
/build/xen/src/xen-4.10.0/tools/ocaml/libs/xb
File "xb.ml", line 88, characters 46-47:
Error: This expression has type bytes but an expression was expected of type
string
With the safe-string changes, Unix.write and Unix.read use bytes, not string
val write : file_descr -> bytes -> int -> int -> int
File "xb.ml", line 152, characters 19-22:
Error: This expression has type string but an expression was expected of type
bytes
String.blit
val blit : string -> int -> bytes -> int -> int -> unit
There may be other locations
Signed-off-by: John Thomson <git@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
---
config/Tools.mk.in | 1 +
tools/configure.ac | 7 +++++++
tools/ocaml/common.make | 6 ++++--
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/config/Tools.mk.in b/config/Tools.mk.in
index 0f79f4e0c2..d4f5bb5d38 100644
--- a/config/Tools.mk.in
+++ b/config/Tools.mk.in
@@ -50,6 +50,7 @@ GIT_HTTP := @githttp@
# Optional components
XENSTAT_XENTOP := @monitors@
OCAML_TOOLS := @ocamltools@
+OCAML_UNSAFE_STRING := @ocaml_unsafe_string@
FLASK_POLICY := @xsmpolicy@
CONFIG_OVMF := @ovmf@
CONFIG_ROMBIOS := @rombios@
diff --git a/tools/configure.ac b/tools/configure.ac
index d1a3a78d87..30964e4a41 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -299,6 +299,13 @@ AS_IF([test "x$ocamltools" = "xy"], [
AC_MSG_ERROR([Your version of OCaml: $OCAMLVERSION is not
supported])])
ocamltools="n"
])
+ AX_COMPARE_VERSION([$OCAMLVERSION], [ge], [4.02.0], [
+ ocaml_unsafe_string="-unsafe-string"
+ AC_SUBST(ocaml_unsafe_string)
+ AC_MSG_WARN([Your version of OCaml: $OCAMLVERSION requires
compiling xen libraries with -unsafe-string])
+ ], [
+ ocaml_unsafe_string=""
+ ])
])
])
diff --git a/tools/ocaml/common.make b/tools/ocaml/common.make
index d5478f626f..d7fb80e728 100644
--- a/tools/ocaml/common.make
+++ b/tools/ocaml/common.make
@@ -11,9 +11,11 @@ OCAMLFIND ?= ocamlfind
CFLAGS += -fPIC -Werror -I$(shell ocamlc -where)
+OCAML_UNSAFE_STRING ?=
+
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
+OCAMLOPTFLAGS = $(OCAMLOPTFLAG_G) -ccopt "$(LDFLAGS)" -dtypes $(OCAMLINCLUDE)
-cc $(CC) -w F -warn-error F $(OCAML_UNSAFE_STRING)
+OCAMLCFLAGS += -g $(OCAMLINCLUDE) -w F -warn-error F $(OCAML_UNSAFE_STRING)
VERSION := 4.1
--
2.16.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |