Add script to test the bootstrap on Inria's CI

master
Sébastien Hinderer 2018-06-01 14:51:42 +02:00
parent 809b72540f
commit 3e085186a7
2 changed files with 337 additions and 0 deletions

247
tools/ci/inria/bootstrap Executable file
View File

@ -0,0 +1,247 @@
#!/bin/sh
#**************************************************************************
#* *
#* OCaml *
#* *
#* Damien Doligez, projet Gallium, INRIA Rocquencourt *
#* *
#* Copyright 2014 Institut National de Recherche en Informatique et *
#* en Automatique. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************
# This script is run on Inria's continuous-integration servers to make sure
# it is possible to bootstrap the compiler.
# To know the slave's architecture, this script looks at the OCAML_ARCH
# environment variable. For a given node NODe, this variable can be defined
# in Jenkins at the following address:
# https://ci.inria.fr/ocaml/computer/NODE/configure
# Other environments variables that are honored:
# OCAML_CONFIGURE_OPTIONS additional options for configure
# OCAML_JOBS number of jobs to run in parallel (make -j)
# Command-line arguments:
# -conf configure-option add configure-option to configure cmd line
# -patch1 file-name apply patch with -p1
# -no-native do not build "opt" and "opt.opt"
# -jNN pass "-jNN" option to make for parallel builds
error () {
echo "$1" >&2
exit 3
}
arch_error() {
configure_url="https://ci.inria.fr/ocaml/computer/${NODE_NAME}/configure"
msg="Unknown architecture. Make sure the OCAML_ARCH environemnt"
msg="$msg variable has been defined."
msg="$msg\nSee ${configure_url}"
error "$msg"
}
# Kill a task on Windows
# Errors are ignored
kill_task()
{
task=$1
taskkill /f /im ${task} /t || true
}
quote1 () {
printf "'%s'" "`printf %s "$1" | sed -e "s/'/'\\\\\\\\''/g"`";
}
# Functions used to modify the source code
change_exe_magic_number() {
old=`./byterun/ocamlrun -M`
new="$1"
echo Changing executable magic number from ${old} to ${new}
# Change magic number in byterun/caml/exec.h
sed -i 's/\x23define \+EXEC_MAGIC \+\x22'${old}'\x22/#define EXEC_MAGIC "'${new}'"/' byterun/caml/exec.h
# Change magic number in utils/config.mlp
sed -i 's/let \+exec_magic_number \+= \+\x22'${old}'\x22/let exec_magic_number = "'${new}'"/' utils/config.mlp
}
remove_primitive()
{
echo Removing the \'sinh\' primitive
patch -p1 < tools/ci/inria/remove-sinh-primitive.patch
}
#########################################################################
# be verbose
set -x
#########################################################################
# Save the current directory (on cygwin, /etc/profile changes it)
jenkinsdir="$(pwd)"
echo jenkinsdir=${jenkinsdir}
#########################################################################
# If we are called from a Windows batch script, we must set up the
# Unix environment variables (e.g. PATH).
case "${OCAML_ARCH}" in
bsd|macos|linux) ;;
cygwin|mingw|mingw64)
. /etc/profile
. "$HOME/.profile"
;;
msvc)
. /etc/profile
. "$HOME/.profile"
. "$HOME/.msenv32"
;;
msvc64)
. /etc/profile
. "$HOME/.profile"
. "$HOME/.msenv64"
;;
*) arch_error;;
esac
#########################################################################
# be considerate towards other potential users of the test machine
case "${OCAML_ARCH}" in
bsd|macos|linux) renice 10 $$ ;;
esac
# be verbose and stop on error
set -ex
#########################################################################
# set up variables
# default values
make=make
instdir="$HOME/ocaml-tmp-install"
configure=unix
confoptions="${OCAML_CONFIGURE_OPTIONS}"
make_native=true
cleanup=false
check_make_alldepend=false
dorebase=false
jobs=''
case "${OCAML_ARCH}" in
bsd) make=gmake ;;
macos) ;;
linux)
check_make_alldepend=true
;;
cygwin)
cleanup=true
check_make_alldepend=true
dorebase=true
;;
mingw)
instdir='C:/ocamlmgw'
configure=nt
cleanup=true
check_make_alldepend=true
;;
mingw64)
instdir='C:/ocamlmgw64'
configure=nt
cleanup=true
check_make_alldepend=true
;;
msvc)
instdir='C:/ocamlms'
configure=nt
cleanup=true
;;
msvc64)
instdir='C:/ocamlms64'
configure=nt
cleanup=true
;;
*) arch_error;;
esac
# Make sure two builds won't use the same install directory
instdir="$instdir-$$"
case "${OCAML_JOBS}" in
[1-9]|[1-9][0-9]) jobs="-j${OCAML_JOBS}" ;;
esac
#########################################################################
# On Windows, cleanup processes that may remain from previous run
if $cleanup; then
tasks="tee ocamlrun program ocamltest ocamltest.opt"
for task in ${tasks}; do kill_task ${task}.exe; done
fi
#########################################################################
# Go to the right directory
pwd
cd "$jenkinsdir"
#########################################################################
# parse optional command-line arguments (has to be done after the "cd")
while [ $# -gt 0 ]; do
case $1 in
-conf) confoptions="$confoptions `quote1 "$2"`"; shift;;
-patch1) patch -f -p1 <"$2"; shift;;
-no-native) make_native=false;;
-j[1-9]|-j[1-9][0-9]) jobs="$1";;
*) error "unknown option $1";;
esac
shift
done
#########################################################################
# Do the work
# Tell gcc to use only ASCII in its diagnostic outputs.
export LC_ALL=C
$make -s distclean || :
# `make distclean` does not clean the files from previous versions that
# are not produced by the current version, so use `git clean` in addition.
git clean -f -d -x
# Also make a hard reset
git reset --hard HEAD
case $configure in
unix)
if $flambda; then
confoptions="$confoptions -flambda -with-flambda-invariants"
fi
eval "./configure -prefix '$instdir' $confoptions"
;;
nt)
cp config/m-nt.h byterun/caml/m.h
cp config/s-nt.h byterun/caml/s.h
cp config/Makefile.${OCAML_ARCH} config/Makefile
sed -i "s%PREFIX=\(.\+\)%PREFIX=${instdir}%" config/Makefile
sed -i 's%RUNTIMED=.\+%RUNTIMED=true%' config/Makefile
if $flambda; then
sed -i 's%FLAMBDA=.\+%FLAMBDA=true%' config/Makefile
fi
;;
*) error "internal error";;
esac
$make world
change_exe_magic_number "CI-bootstrap"
remove_primitive
$make coreall
$make bootstrap

View File

@ -0,0 +1,90 @@
The patch below removes the 'sinh' primitive from the OCaml runtime
and standard library.
It is used on Inria's CI to make sure the bootstrap procedure works.
diff --git a/byterun/floats.c b/byterun/floats.c
index 7e98f473d..792196a4e 100644
--- a/byterun/floats.c
+++ b/byterun/floats.c
@@ -536,11 +536,6 @@ CAMLprim value caml_sin_float(value f)
return caml_copy_double(sin(Double_val(f)));
}
-CAMLprim value caml_sinh_float(value f)
-{
- return caml_copy_double(sinh(Double_val(f)));
-}
-
CAMLprim value caml_cos_float(value f)
{
return caml_copy_double(cos(Double_val(f)));
diff --git a/otherlibs/threads/stdlib.ml b/otherlibs/threads/stdlib.ml
index a2d2c8590..3587ce1ab 100644
--- a/otherlibs/threads/stdlib.ml
+++ b/otherlibs/threads/stdlib.ml
@@ -139,8 +139,6 @@ external log10 : float -> float = "caml_log10_float" "log10"
external log1p : float -> float = "caml_log1p_float" "caml_log1p"
[@@unboxed] [@@noalloc]
external sin : float -> float = "caml_sin_float" "sin" [@@unboxed] [@@noalloc]
-external sinh : float -> float = "caml_sinh_float" "sinh"
- [@@unboxed] [@@noalloc]
external sqrt : float -> float = "caml_sqrt_float" "sqrt"
[@@unboxed] [@@noalloc]
external tan : float -> float = "caml_tan_float" "tan" [@@unboxed] [@@noalloc]
diff --git a/stdlib/float.ml b/stdlib/float.ml
index 3cd010062..8ae9e3ba8 100644
--- a/stdlib/float.ml
+++ b/stdlib/float.ml
@@ -69,8 +69,6 @@ external hypot : float -> float -> float
= "caml_hypot_float" "caml_hypot" [@@unboxed] [@@noalloc]
external cosh : float -> float = "caml_cosh_float" "cosh"
[@@unboxed] [@@noalloc]
-external sinh : float -> float = "caml_sinh_float" "sinh"
- [@@unboxed] [@@noalloc]
external tanh : float -> float = "caml_tanh_float" "tanh"
[@@unboxed] [@@noalloc]
external ceil : float -> float = "caml_ceil_float" "ceil"
diff --git a/stdlib/float.mli b/stdlib/float.mli
index f7b4cd8d6..64e4497c2 100644
--- a/stdlib/float.mli
+++ b/stdlib/float.mli
@@ -196,10 +196,6 @@ external cosh : float -> float = "caml_cosh_float" "cosh"
[@@unboxed] [@@noalloc]
(** Hyperbolic cosine. Argument is in radians. *)
-external sinh : float -> float = "caml_sinh_float" "sinh"
-[@@unboxed] [@@noalloc]
-(** Hyperbolic sine. Argument is in radians. *)
-
external tanh : float -> float = "caml_tanh_float" "tanh"
[@@unboxed] [@@noalloc]
(** Hyperbolic tangent. Argument is in radians. *)
diff --git a/stdlib/stdlib.ml b/stdlib/stdlib.ml
index 05dfe9e8a..a185daaa8 100644
--- a/stdlib/stdlib.ml
+++ b/stdlib/stdlib.ml
@@ -135,8 +135,6 @@ external log10 : float -> float = "caml_log10_float" "log10"
external log1p : float -> float = "caml_log1p_float" "caml_log1p"
[@@unboxed] [@@noalloc]
external sin : float -> float = "caml_sin_float" "sin" [@@unboxed] [@@noalloc]
-external sinh : float -> float = "caml_sinh_float" "sinh"
- [@@unboxed] [@@noalloc]
external sqrt : float -> float = "caml_sqrt_float" "sqrt"
[@@unboxed] [@@noalloc]
external tan : float -> float = "caml_tan_float" "tan" [@@unboxed] [@@noalloc]
diff --git a/stdlib/stdlib.mli b/stdlib/stdlib.mli
index d6cea652f..ccca2e124 100644
--- a/stdlib/stdlib.mli
+++ b/stdlib/stdlib.mli
@@ -460,10 +460,6 @@ external cosh : float -> float = "caml_cosh_float" "cosh"
[@@unboxed] [@@noalloc]
(** Hyperbolic cosine. Argument is in radians. *)
-external sinh : float -> float = "caml_sinh_float" "sinh"
- [@@unboxed] [@@noalloc]
-(** Hyperbolic sine. Argument is in radians. *)
-
external tanh : float -> float = "caml_tanh_float" "tanh"
[@@unboxed] [@@noalloc]
(** Hyperbolic tangent. Argument is in radians. *)