Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Add support for OCaml 4.06 and 4.07 #205

Merged
merged 3 commits into from
Dec 27, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ sudo: required
env:
- OCAML_VERSION=4.04
- OCAML_VERSION=4.05
- OCAML_VERSION=4.06
- OCAML_VERSION=4.07
3 changes: 2 additions & 1 deletion mirage-xen-ocaml.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ depends: [
"ocamlfind" {build}
"ocaml-src"
"ocamlbuild" {build}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Extraneous blank line.

]
available: [ocaml-version >= "4.04.2" & ocaml-version <= "4.05.0" & os = "linux"]
available: [ocaml-version >= "4.04.2" & ocaml-version <= "4.07.1" & os = "linux"]
80 changes: 71 additions & 9 deletions xen-ocaml/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ armv*)
;;
esac

# These are needed by https://github.com/ocaml/ocaml/blob/4.07.1/byterun/caml/stack.h
case `uname -m` in
armv*)
TARGET_ARCH="arm"
;;
i386|i486|i586|i686)
TARGET_ARCH="i386"
;;
x86_64)
TARGET_ARCH="amd64"
;;
*)
echo Unsupported architecture
exit 1
;;
esac

# This extra flag only needed for gcc 4.8+
GCC_MVER2=`gcc -dumpversion | cut -f2 -d.`
if [ $GCC_MVER2 -ge 8 ]; then
Expand All @@ -40,30 +57,75 @@ rm -rf ocaml-src
cp -r `ocamlfind query ocaml-src` ocaml-src
chmod -R u+w ocaml-src

echo Detected OCaml version `ocamlopt -version`
case `ocamlopt -version` in
OCAMLOPT_VERSION=$(ocamlopt -version)
echo Detected OCaml version $OCAMLOPT_VERSION
case $OCAMLOPT_VERSION in
4.04.2)
echo Applying OCaml 4.04 config
cp config/version-404.h ocaml-src/byterun/caml/version.h
BIGARRAY_OBJ="mmap_unix.o"
S_H_LOCATION="ocaml-src/config/"
BIGARRAY_OBJ="bigarray_stubs.o mmap_unix.o"
;;
4.05.*)
echo Applying OCaml 4.05 config
cp config/version-405.h ocaml-src/byterun/caml/version.h
BIGARRAY_OBJ="mmap_unix.o"
S_H_LOCATION="ocaml-src/config/"
BIGARRAY_OBJ="bigarray_stubs.o mmap_unix.o"
CFLAGS="-D__ANDROID__ $CFLAGS"
;;
4.06.0)
echo Applying OCaml 4.06.0 config
cp config/version-4060.h ocaml-src/byterun/caml/version.h
S_H_LOCATION="ocaml-src/byterun/caml/"
BIGARRAY_OBJ="bigarray_stubs.o mmap.o mmap_ba.o"
CFLAGS="-D__ANDROID__ $CFLAGS"
;;
4.06.*)
echo Applying OCaml 4.06.1 config
cp config/version-4061.h ocaml-src/byterun/caml/version.h
S_H_LOCATION="ocaml-src/byterun/caml/"
BIGARRAY_OBJ="bigarray_stubs.o mmap.o mmap_ba.o"
CFLAGS="-D__ANDROID__ $CFLAGS"
;;
4.07.0)
echo Applying OCaml 4.07.0 config
cp config/version-4070.h ocaml-src/byterun/caml/version.h
S_H_LOCATION="ocaml-src/byterun/caml/"
BIGARRAY_OBJ="mmap.o mmap_ba.o"
CFLAGS="-D__ANDROID__ $CFLAGS"
;;
4.07.*)
echo Applying OCaml 4.07.1 config
cp config/version-4071.h ocaml-src/byterun/caml/version.h
S_H_LOCATION="ocaml-src/byterun/caml/"
BIGARRAY_OBJ="mmap.o mmap_ba.o"
CFLAGS="-D__ANDROID__ $CFLAGS"
;;
*)
echo unsupported OCaml version `ocamlopt -version`
echo unsupported OCaml version $OCAMLOPT_VERSION
exit 1
;;
esac

cd ocaml-src && ./configure && cd ..
cp config/s.h ocaml-src/config/
cp config/s.h $S_H_LOCATION

cd ocaml-src

# cd byterun && make BYTECCCOMPOPTS="${CFLAGS}" BYTECCCOMPOPTS="${CFLAGS}" libcamlrun.a && cd ..
cd asmrun && make -j${NJOBS} UNIX_OR_WIN32=unix NATIVECCCOMPOPTS="-DNATIVE_CODE ${CFLAGS}" NATIVECCPROFOPTS="-DNATIVE_CODE ${CFLAGS}" libasmrun.a && cd ..

case $OCAMLOPT_VERSION in
4.04.2|4.05.*)
cd asmrun && make -j${NJOBS} UNIX_OR_WIN32=unix NATIVECCCOMPOPTS="-DNATIVE_CODE ${CFLAGS}" NATIVECCPROFOPTS="-DNATIVE_CODE ${CFLAGS}" libasmrun.a && cd ..
;;
4.06.*|4.07.*)
cd asmrun && make -j${NJOBS} UNIX_OR_WIN32=unix CPPFLAGS="-DNATIVE_CODE ${CFLAGS} -I../byterun -DTARGET_${TARGET_ARCH}" NATIVECCPROFOPTS="-DNATIVE_CODE ${CFLAGS}" libasmrun.a && cd ..
;;
*)
echo unsupported OCaml version $OCAMLOPT_VERSION
exit 1
;;
esac
CFLAGS="$CFLAGS -I../../byterun"
cd otherlibs/bigarray && make CFLAGS="${CFLAGS}" bigarray_stubs.o ${BIGARRAY_OBJ}
ar rcs ../../libxenotherlibs.a bigarray_stubs.o ${BIGARRAY_OBJ}
cd otherlibs/bigarray && make CFLAGS="${CFLAGS} -I../unix -DIN_OCAML_BIGARRAY" ${BIGARRAY_OBJ}
ar rcs ../../libxenotherlibs.a ${BIGARRAY_OBJ}
6 changes: 6 additions & 0 deletions xen-ocaml/config/version-4060.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define OCAML_VERSION_MAJOR 4
#define OCAML_VERSION_MINOR 6
#define OCAML_VERSION_PATCHLEVEL 0
#undef OCAML_VERSION_ADDITIONAL
#define OCAML_VERSION 40600
#define OCAML_VERSION_STRING "4.06.0"
6 changes: 6 additions & 0 deletions xen-ocaml/config/version-4061.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define OCAML_VERSION_MAJOR 4
#define OCAML_VERSION_MINOR 6
#define OCAML_VERSION_PATCHLEVEL 1
#undef OCAML_VERSION_ADDITIONAL
#define OCAML_VERSION 40601
#define OCAML_VERSION_STRING "4.06.1"
6 changes: 6 additions & 0 deletions xen-ocaml/config/version-4070.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define OCAML_VERSION_MAJOR 4
#define OCAML_VERSION_MINOR 7
#define OCAML_VERSION_PATCHLEVEL 0
#undef OCAML_VERSION_ADDITIONAL
#define OCAML_VERSION 40700
#define OCAML_VERSION_STRING "4.07.0"
6 changes: 6 additions & 0 deletions xen-ocaml/config/version-4071.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define OCAML_VERSION_MAJOR 4
#define OCAML_VERSION_MINOR 7
#define OCAML_VERSION_PATCHLEVEL 1
#undef OCAML_VERSION_ADDITIONAL
#define OCAML_VERSION 40701
#define OCAML_VERSION_STRING "4.07.1"
4 changes: 2 additions & 2 deletions xen-ocaml/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ else
fi

PUBLIC_INCLUDES="alloc.h callback.h config.h custom.h fail.h hash.h intext.h \
memory.h misc.h mlvalues.h printexc.h signals.h compatibility.h"
io.h memory.h misc.h mlvalues.h printexc.h signals.h compatibility.h"
if [ -e ../tools/cleanup-header ]; then
for i in ${PUBLIC_INCLUDES}; do
sed -f ../tools/cleanup-header $HEADERS_SRC/$i > $idir/caml/$i
done
cd ../otherlibs/bigarray
sed -f ../../tools/cleanup-header bigarray.h > $idir/caml/bigarray.h
else
for i in ${PUBLIC_INCLUDES} bigarray.h; do
for i in ${PUBLIC_INCLUDES} bigarray.h s.h m.h; do
cp ${HEADERS_SRC}/$i $idir/caml/$i
done
fi
11 changes: 10 additions & 1 deletion xen-posix/src/mini_libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ int printf(const char *fmt, ...)
return 1;
}

int vfprintf(void *stream UNUSED, const char *fmt, va_list ap)
{
va_list args;
va_copy(args, ap);
print(0, fmt, args);
va_end(args);
return 1;
}

int fflush (void * stream UNUSED)
{
return 0;
Expand Down Expand Up @@ -243,7 +252,7 @@ unsupported_function_log(char *, if_indextoname, (char *) NULL);
unsupported_function_log(struct if_nameindex *, if_nameindex, (struct if_nameindex *) NULL);
unsupported_function_crash(if_freenameindex);

/* Linuxish abi for the Caml runtime, don't support
/* Linuxish abi for the Caml runtime, don't support
Log, and return an error code if possible. If it is not possible
to inform the application of an error, then crash instead!
*/
Expand Down