Files
mercury/tools/test_mercury
Julien Fischer 667a00f86d Update the test_mercury script.
tools/test_mercury:
    Build the source distribution in the hlc.gc.pregen grade.

    Force the LLDS base grade for the source distribution to be none
    rather than asm_fast.  The latter was causing problems when
    generating the C files on Mac OS X (or anything else on which
    asm_fast doesn't work).
2013-04-29 13:40:43 +10:00

1265 lines
44 KiB
Bash
Executable File

#!/bin/sh
#---------------------------------------------------------------------------#
# vim: ts=4 sw=4 et
#---------------------------------------------------------------------------#
# Copyright (C) 1996-2001 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#---------------------------------------------------------------------------#
# This script is used to run the nightly tests.
# It is invoked from the `run_test' script.
# NOTE: when adding a new host you need to add a symbolic link from
# $TOPDIR/public/test_mercury/test_dirs to the actual build directory.
echo "test_mercury starting at `date`" 1>&2
case $# in
6) HOST=$1; ARCH=$2; FULLARCH=$3; BRANCH=$4; C_COMPILER=$5; USE_MMC_MAKE=$6 ;;
5) HOST=$1; ARCH=$2; FULLARCH=$3; BRANCH=$4; C_COMPILER=$5; USE_MMC_MAKE="" ;;
*) echo "Usage: $0 host arch fullarch branch c_compiler use_mmc_make" 1>&2; exit 1 ;;
esac
if test -d /home/mercury/public/.
then
TOPDIR=/home/mercury/public
PATH="$HOME/bin/$ARCH`awk '/^[^#]/{printf ":%s",$0;}' $TOPDIR/cron/.path`"
PATH="$TOPDIR/mercury-latest/$FULLARCH/bin:$PATH"
PATH="/home/$HOST/public/mercury-latest/$FULLARCH/bin:$PATH"
PATH="$TOPDIR/autoconf-2.13/$FULLARCH/bin:$PATH"
PATH="$TOPDIR/autoconf-2.52/$FULLARCH/bin:$PATH"
PATH="$TOPDIR/$FULLARCH:$PATH"
PATH="$TOPDIR/$FULLARCH/bin:$PATH"
PATH="$TOPDIR/$HOST:$PATH"
# generate_index_html needs to be in our PATH too
PATH="$TOPDIR/test_mercury/scripts:$PATH"
else
case "$HOST" in
eris)
HOME=/Users/mercury/mercury
;;
esac
TOPDIR=$HOME/public
PATH=$TOPDIR/mercury-latest/$FULLARCH/bin:$PATH
PATH="$TOPDIR/$FULLARCH:$PATH"
PATH="$TOPDIR/$HOST:$PATH"
fi
case $HOST in mundula)
PATH="/usr/local/apps/ssh-1.2.32/bin:$PATH"
;;
esac
PATH="$PATH:/usr/bin"
export PATH
# Use NFS if we can, for the machines over at EE use ssh and
# otherwise use anonymous CVS (pserver).
CVSROOT=/home/mercury/mercury1/repository
if test -d $CVSROOT/.
then
:
else
case "$HOST" in
eris|bob)
CVSROOT=":ext:mercury@cvs.mercury.csse.unimelb.edu.au:$CVSROOT"
;;
*)
CVSROOT=":pserver:guest@cvs.mercury.csse.unimelb.edu.au:$CVSROOT"
;;
esac
fi
export CVSROOT
# Tell gcc to use /tmp, not /usr/tmp
TMPDIR=/tmp
export TMPDIR
# Ensure that files are only writeable by user mercury, not group mercury.
# This is in part to ensure that people don't unintentionally install
# libraries over the installation we perform here.
umask 022
# Stop looping tests after 5 minutes of CPU time.
# Also allow tests to use up to about 250 Mb of memory
# (Most of it should build fine with 128 Mb,
# but building the --split-c-files versions of
# the libraries needs more, at least for dec-alpha-osf*.)
# On Cygwin ulimit doesn't work properly, so don't use it.
case $HOST in
*) ulimit -S -t 300
ulimit -S -d 250000
;;
esac
# directories to use
TESTDIR=$TOPDIR/test_mercury
HOSTDIR=$TESTDIR/test_dirs/$HOST
DIR=$HOSTDIR/build.$BRANCH.$C_COMPILER
# Set-up the class path needed for java testing.
CLASSPATH=$DIR/mercury/java:.
export CLASSPATH
# Host to use to build the release of the day source distribution
# for the mercury-compiler, mercury-tests, and mercury-extras distributions.
ROTD_HOST=carlton
# Host to use to build the release of the day mercury-gcc source distribution.
# We don't currently test the gcc backend.
# GCC_ROTD_HOST=
set_status () {
case "$*" in
"tests in grade asm_fast.agc"* | "tests in grade hlc_nest"*)
# These grades have known bugs which mean that they
# do not pass all of the tests. So we do not fail
# if we get errors in those grades.
echo "** Error in $* (expected)"
;;
*)
status=1;
echo "** Error in $*"
;;
esac
}
#-----------------------------------------------------------------------------#
#
# We set the following variables according to which
# branch we're testing.
#
# BRANCH:
# An abstract name for the branch, i.e. `0.10' or `latest'.
# This is not the same as the branch name used by CVS.
#
# TEST_ID:
# A name that identifies the version being tested.
# This should include all the relevant test
# parameters, e.g. BRANCH, HOST, C_COMPILER.
#
# INSTALL_DIR_NAME:
# The name of the directory in which to install this branch.
# (Not the full path, just the final directory name.)
# More generally used for naming stuff related to this branch.
#
# FTP_DIR_NAME:
# The name of the directory in which to put the source & binary
# distributions for this branch, on the ftp and web sites.
# (Not the full path, just the final directory name.)
#
# CHECKOUT_OPTS:
# Options to pass to cvs checkout.
#
# BASE_TAG_NAME:
# The name on which to base the cvs tag names that we add.
# We add cvs tags of the form
# `stable-$BASE_TAG_NAME-$fullname_tag' and
# `unstable-$BASE_TAG_NAME-$fullname_tag'
# for the unstable (passed bootcheck, but not tests)
# and stable (pass both bootcheck and tests) versions respectively.
#
# RELEASE_VERSION:
# The name to give this version.
#
# RELEASE_VERSION_PATTERN:
# A pattern used to delete earlier versions which
# this version will replace, if it builds successfully.
# This should usually be the same as $RELEASE_VERSION,
# but with `*' instead of $DATE.
#
# NOTE: for beta releases you also need to set the value of
# NEXT_BETA_VERSION in w3/RELEASE_INFO.
INSTALL_DIR_NAME=mercury-$BRANCH
DATE=`date '+%Y-%m-%d'`
case $BRANCH in
latest)
CHECKOUT_OPTS=-A
BASE_TAG_NAME=rotd
FTP_DIR_NAME=rotd
RELEASE_VERSION=rotd-$DATE
RELEASE_VERSION_PATTERN=rotd-*
;;
12.08)
# This is for the 12.08 betas.
CHECKOUT_OPTS=-rversion-12_08-branch
BASE_TAG_NAME=version-12_08-branch
FTP_DIR_NAME=12.08-beta
RELEASE_VERSION=12.08-beta-$DATE
RELEASE_VERSION_PATTERN=12.08-beta-*
;;
# This is for the 12.08 release.
#
#CHECKOUT_OPTS=-rversion-12_08
#BASE_TAG_NAME=version-12_08
#FTP_DIR_NAME=12.08
#RELEASE_VERSION=12.08
#RELEASE_VERSION_PATTERN=12.08*
#;;
esac
case "$C_COMPILER" in
gcc)
TEST_ID=$BRANCH.$HOST
TEST_ERROR_FILE="$TESTDIR/logs/test-$BRANCH-$HOST.test_errs"
FAILED_TESTS_FILE="$TESTDIR/logs/test-$BRANCH-$HOST.failed_tests"
;;
*)
TEST_ID=$BRANCH.$HOST.$C_COMPILER
TEST_ERROR_FILE="$TESTDIR/logs/test-$BRANCH-$HOST-$C_COMPILER.test_errs"
FAILED_TESTS_FILE="$TESTDIR/logs/test-$BRANCH-$HOST-$C_COMPILER.failed_tests"
;;
esac
rm -f $TEST_ERROR_FILE $FAILED_TESTS_FILE
#-----------------------------------------------------------------------------#
use_cp_opt=""
# EXTRA_INSTALL_MCFLAGS can be used to customise INSTALL_MCFLAGS
EXTRA_INSTALL_MCFLAGS=""
# The same is true for EXTRA_TEST_MCFLAGS, EXTRA_INSTALL_CFLAGS and
# EXTRA_TEST_CFLAGS
EXTRA_TEST_MCFLAGS=""
EXTRA_INSTALL_CFLAGS=""
EXTRA_TEST_CFLAGS=""
case $HOST in
# test things at different optimization levels...
$ROTD_HOST)
OPTIMIZE="-O5 --intermodule-optimization"
;;
saturn)
OPTIMIZE="-O5 --intermodule-optimization"
;;
neptune)
OPTIMIZE="-O4"
;;
apollo)
OPTIMIZE="-O3 --intermodule-optimization"
;;
goofy)
OPTIMIZE="-O2 --intermodule-optimization"
;;
mundula)
OPTIMIZE=-O2; use_cp_opt="--use-cp"
# On mundroo, "mkdir -p scripts" aborts
# if scripts is a symbolic link to a directory.
;;
taura)
OPTIMIZE="-O5 --intermodule-optimization"
# Set --profile-for-implicit-parallelism so that the deep profiling
# version of the standard library is suitable for Paul's implicit
# parallelism work. This is not enabled by default because it enables
# inlining which is confusing for programmers using the deep profiler.
EXTRA_INSTALL_MCFLAGS="--profile-for-implicit-parallelism"
EXTRA_TEST_MCFLAGS="--profile-for-implicit-parallelism"
# Exercise handwritten assembler in runtime/mercury_atomic_ops.h that
# is usually unused with GCC versions >= 4.1
EXTRA_INSTALL_CFLAGS="-DMR_AVOID_COMPILER_INTRINSICS=1"
EXTRA_TEST_CFLAGS="-DMR_AVOID_COMPILER_INTRINSICS=1"
;;
goliath)
OPTIMIZE="-O5 --intermodule-optimization"
;;
carlton)
OPTIMIZE="-O5 --intermodule-optimization"
;;
bob)
OPTIMIZE="-O2"
;;
esac
# On some systems, the file system we're using does not support links.
# On systems running Cygwin use the following: LN="cp -r"; LN_S="cp -r"
case $HOST in
*) LN="ln"; LN_S="ln -s" ;;
esac
# Flags for building the compiler.
INSTALL_MCFLAGS="$OPTIMIZE --opt-space $EXTRA_INSTALL_MCFLAGS"
INSTALL_MGNUCFLAGS=""
INSTALL_CFLAGS="$EXTRA_INSTALL_CFLAGS"
INSTALL_MLFLAGS=""
# Flags for running the tests.
TEST_MCFLAGS="$OPTIMIZE --opt-space $EXTRA_TEST_MCFLAGS"
TEST_MGNUCFLAGS=""
TEST_CFLAGS="$EXTRA_TEST_CFLAGS"
TEST_MLFLAGS=""
case $FULLARCH in
i*86-*-linux*|i*86-*-freebsd*|i*86-*-solaris2.*)
# On x86 Unix, we need to set the following flags to enable
# shared libraries (and we need to use shared libraries to
# avoid running out of disk space...)
TEST_MCFLAGS="$TEST_MCFLAGS --mercury-linkage shared --linkage shared --pic-reg"
TEST_MGNUCFLAGS="$TEST_MGNUCFLAGS --pic-reg"
TEST_MLFLAGS="$TEST_MLFLAGS --shared"
;;
*)
# On other platforms shared libraries is the default
;;
esac
# This list of hosts for which we install into /home/$HOST rather than
# /home/mercury should match the corresponding list in run_all_tests_from_cron.
# So if you modify this list of hosts, you need to also modify
# run_all_tests_from_cron.
case $HOST in
saturn|neptune|goofy|taura|bob|goliath|carlton)
INSTALL_DIR=/home/$HOST/public/$INSTALL_DIR_NAME/$FULLARCH
;;
# The actual architecture string for eris has the version appended to it, but
# that will change with every OS update so we don't include it here.
eris)
INSTALL_DIR=/Users/mercury/mercury/public/$INSTALL_DIR_NAME/x86_64-apple-darwin
;;
*)
INSTALL_DIR=$TOPDIR/$INSTALL_DIR_NAME/$FULLARCH
;;
esac
case "$C_COMPILER" in
gcc) ;;
*) INSTALL_DIR="$INSTALL_DIR-$C_COMPILER" ;;
esac
BETA_FTPHOST=ftp.mercury.csse.unimelb.edu.au
BETA_FTPDIR=/local/ftp/pub/mercury/beta-releases/$FTP_DIR_NAME
BETA_WEBDIR_TOP=/home/mercury/public/installed_w3/download/files
BETA_WEBDIR=$BETA_WEBDIR_TOP/beta-releases/$FTP_DIR_NAME
STABLE=$HOSTDIR/$INSTALL_DIR_NAME-stable
UNSTABLE=$HOSTDIR/$INSTALL_DIR_NAME-unstable
PATH="$INSTALL_DIR/bin:$PATH"
# $PARALLEL: flag to pass to GNU make for parallel make
#
PARALLEL=
case $HOST in
saturn|goofy|taura) PARALLEL="-j2" ;;
apollo|eris) PARALLEL="-j3" ;;
goliath|carlton) PARALLEL="-j4" ;;
*) PARALLEL= ;;
esac
# Version of the mercury compiler to use for bootstrapping
# Normally we use the compiler from same location that we will install in.
# But occasionally this setting will get overridden below.
case $BRANCH in
*)
if test -x $INSTALL_DIR/bin/mercury_compile
then
BOOTSTRAP_MERCURY_COMPILER=$INSTALL_DIR/bin/mercury_compile
fi
;;
esac
# df (disk free) command
DF=df
case $HOST in
mundula) DF="df -k" ;;
esac
#-----------------------------------------------------------------------------#
# Check we've got a reasonable amount of free disk space -- no point
# starting if we'll only run out of disk space.
test -d $DIR || mkdir -p $DIR
FREE=`$DF $DIR | awk '
NR == 2 && NF > 4 { print $4; exit; }
NR == 3 { print $3; }
'`
if test "$FREE" -lt 10000
then
echo "Insufficient disk space on $DIR" 1>&2
$DF $DIR
exit 1
fi
#-----------------------------------------------------------------------------#
# To make sure we don't try to run two tests in parallel,
# we use a lock file in the test directory.
lockfile=$HOSTDIR/lockfile
if test -f $lockfile
then
echo "Directory $HOSTDIR is locked:" 1>&2
cat $lockfile 1>&2
echo "Perhaps the previous test is still running?" 1>&2
echo "(Remove $lockfile manually if necessary.)" 1>&2
exit 1
fi
trap 'rm -f $lockfile; exit 1' 1 2 3 13 15
trap 'exit_status=$?; rm -f $lockfile; exit $exit_status' 0
echo $HOST > $lockfile
ulimit -a > $HOSTDIR/ulimit
env > $HOSTDIR/env
#-----------------------------------------------------------------------------#
status=0
#-----------------------------------------------------------------------------#
# NOTE: in order to make all of the machines useful for day-to-day work
# the set of grades installed should include asm_fast.gc, hlc.gc,
# a debugging grade and a trailing grade.
case $HOST in
saturn)
# XXX Avoid useing gcc 4.2 as the standard lib triggers
# an internal error in that in asm_fast.gc.decldebug. (Bug #124).
CONFIG_OPTS="--with-cc=/usr/bin/gcc-4.3"
INSTALL_LIBGRADES="asm_fast.gc \
asm_fast.par.gc \
asm_fast.gc.decldebug \
asm_fast.gc.profdeep \
asm_fast.gc.stseg \
asm_fast.par.gc.stseg \
asm_fast.gc.stseg.trseg \
asm_fast.gc.tsc.debug \
hlc.gc \
hlc.gc.trseg \
asm_fast"
;;
apollo)
INSTALL_LIBGRADES="asm_fast.gc \
asm_fast.gc.trseg \
asm_fast.gc.trseg.stseg \
asm_fast.gc.trseg.debug \
asm_fast.par.gc \
asm_fast.par.gc.stseg \
hlc.gc \
hlc.gc.trseg \
hlc.par.gc \
hlc.par.gc.trseg"
;;
neptune)
CONFIG_OPTS="--with-cc=/usr/bin/gcc-4.1"
INSTALL_LIBGRADES="asm_fast.gc \
asm_fast.gc.trseg \
asm_fast.gc.trseg.debug \
asm_fast.gc.trseg.profdeep \
reg.gc \
reg.gc.trseg \
hlc.gc \
hlc.gc.trseg \
hlc.par.gc.trseg \
hl_nest.gc \
hlc_nest.gc"
;;
goofy)
DEFAULT_GRADE="hlc.gc"
export DEFAULT_GRADE
INSTALL_GRADE="hlc.gc"
CONFIG_OPTS="--with-cc=/usr/bin/gcc-4.1"
INSTALL_LIBGRADES="hlc.gc \
asm_fast.gc \
asm_fast.gc.prof \
asm_fast.gc.memprof \
asm_fast.gc.mm \
asm_fast.gc.trseg \
asm_fast.gc.rbmm \
hlc.par.gc \
hlc.gc.trseg \
hl.gc \
hl.par.gc"
;;
eris)
# The asm_fast grades don't (yet) work on Darwin.
# XXX The reg grades cause heap exhaustion on Mac OS 10.6.
# XXX compilation of the debug grades is very slow with
# Mac OS 10.6 an gcc 4.2 - it is disabled for now.
#
CONFIG_OPTS=""
DEFAULT_GRADE="hlc.gc"
export DEFAULT_GRADE
INSTALL_GRADE="hlc.gc"
INSTALL_LIBGRADES="hlc.gc \
hlc.gc.trseg \
hlc.gc.trseg.ll_debug \
hlc.gc.trseg.prof \
hlc.gc.trseg.memprof \
none.gc \
none.gc.trseg \
hl.gc \
hlc.par.gc \
none.par.gc \
hl.par.gc \
java \
csharp"
;;
taura)
CONFIG_OPTS=""
INSTALL_LIBGRADES="asm_fast.gc \
asm_fast.gc.stseg \
asm_fast.par.gc \
asm_fast.par.gc.stseg \
asm_fast.par.gc.stseg.threadscope \
asm_fast.gc.debug \
asm_fast.gc.debug.trseg \
asm_fast.gc.decldebug \
asm_fast.gc.profdeep \
asm_jump.gc \
hlc.gc \
hlc.gc.trseg"
# asm_fast.gc.tsw.debug \
# asm_fast.gc.mmos \
# asm_fast.gc.mmos.debug \
;;
goliath)
CONFIG_OPTS="--with-cc=/usr/bin/gcc-4.1"
INSTALL_LIBGRADES="asm_fast.gc \
hlc.gc \
hlc.gc.trseg \
hlc.gc.trseg.prof \
hlc.gc.trseg.memprof \
hlc.gc.trseg.ll_debug \
asm_fast.gc.tr \
asm_fast.par.gc \
asm_fast.gc.trseg \
asm_fast.gc.trseg.debug \
asm_fast.gc.trseg.profdeep \
java"
;;
bob)
# bob (a VM on spelter) is used by the G12 group for doing builds of
# the MiniZinc distribution. We only need to install the grades that
# are required for that.
CONFIG_OPTS=""
INSTALL_LIBGRADES="asm_fast.gc \
hlc.gc \
hlc.gc.trseg"
;;
*)
CONFIG_OPTS=""
;;
esac
# The deep profiler needs to be included in the source distribution.
#
case $HOST in $ROTD_HOST)
CONFIG_OPTS="$CONFIG_OPTS --enable-deep-profiler=$TOPDIR/installed_w3/cgi-bin"
if test "$INSTALL_LIBGRADES" != ""; then
INSTALL_LIBGRADES="$INSTALL_LIBGRADES asm_fast.gc.profdeep"
fi
;;
esac
#-----------------------------------------------------------------------------#
# Sometimes, bootstrapping problems mean that we need to install
# even if the bootstrap check failed.
# In such cases, set install_anyway to true,
# and if the install should be done from the stage 1 directory,
# also set install_anyway_stage1 to true.
#
# XXX there are currently some bugs with installing from the stage 1 directory:
# if the compilation options are not the same for stage 1 and stage 2,
# it installs from stage 1 using stage 2 compilation options,
# but does not remake the dependencies properly.
install_anyway=false
install_anyway_stage1=false
#-----------------------------------------------------------------------------#
: clean up any directories from previous test runs
cd $HOSTDIR
rm -rf build.*/mercury
rm -rf build.*/tests
rm -rf build.*/mercury-cvs
rm -rf build.*/mercury-gcc
# Note that we do NOT want to clean out the GCC directory,
# because checking out the GCC sources from the FSF's repository in
# California takes a *long* time and a *lot* of network bandwidth,
# and we're currently using a fixed snapshot anyway, so we don't
# bother to check it out at all.
### rm -rf build.*/gcc
#-----------------------------------------------------------------------------#
: checkout sources and run bootcheck
echo "test_mercury starting cvs checkout at `date`" 1>&2
set -x # trace execution
: checkout the sources
cd $DIR || { false; exit 1; }
# We need to manually remove this copy of dl.m to avoid spurious cvs
# conflicts when switching between the 0.10 branch (where it is in cvs)
# and the main branch (where it is generated automatically).
rm -f mercury/extras/dynamic_linking/dl.m
cvs checkout $CHECKOUT_OPTS mercury tests || { false; exit 1; }
case "$C_COMPILER" in
asm)
with_asm=true
;;
*)
case $HOST in
*) with_asm=false ;;
esac
;;
esac
case "$with_asm" in
true)
# Check out the Mercury gcc back-end interface sources
cvs checkout $CHECKOUT_OPTS mercury-gcc || { false; exit 1; }
# Check out the main gcc sources.
# See <http://gcc.gnu.org/cvs.html>.
#
# Once the gcc sources have been checked out here,
# the Mercury autoconfiguration script should find them
# automatically, so we don't need to bother explicitly
# passing `--enable-gcc-back-end' to configure.
#
# Note that the `cvs login' command, namely
# `cvs -d :pserver:anoncvs@gcc.gnu.org:/cvs/gcc login'
# must be done manually, since there is no easy way to pass
# the password (`anoncvs') from a script.
# Once it is done once, it will be saved in the user's
# ~/.cvspass file, so it doesn't need to be done again.
#
# This is commented out, to save bandwidth,
# since currently we're using a fixed snapshot
# (`-r gcc_3_2_release') anyway.
# Perhaps this should eventually change to use
# `-r gcc_latest_snapshot'.
date
#cvs -d :pserver:anoncvs@gcc.gnu.org:/cvs/gcc -z 9 \
# checkout -r gcc_3_2_release gcc || { false; exit 1; }
#date
# Link the Mercury gcc back-end interface sources
# into the appropriate place in the gcc sources
pwd
(cd gcc/gcc && rm -f mercury && \
ln -s ../../mercury-gcc mercury) \
|| { false; exit 1; }
# Now configure and build the gcc directory.
# The gcc cvs repository includes some automatically
# generated files; we need to touch them here before
# running configure.
# XXX We should perhaps also do `make distclean' before
# configure.
(cd gcc &&
contrib/gcc_update --touch &&
sh configure --enable-languages=mercury &&
make) || set_status "gcc checkout"
date
;;
esac
: make sure the installation directory exists
test -d $INSTALL_DIR || mkdir -p $INSTALL_DIR
: update the VERSION file to specify the version we are building
sed "s/VERSION=.*/VERSION=$RELEASE_VERSION/" \
mercury/VERSION > mercury/VERSION.new
mv mercury/VERSION.new mercury/VERSION
: bootstrap the compiler up to stage 3 and check that the results match
case "$BOOTSTRAP_MERCURY_COMPILER" in
"") ;;
*) MERCURY_COMPILER=$BOOTSTRAP_MERCURY_COMPILER
export MERCURY_COMPILER
;;
esac
cd mercury || { false; exit 1; }
# if [ -s tools/list.$HOST ]; then
# tools/expand_params `tools/cur_param tools $HOST` > Mmake.params
# else
echo "MC = ../scripts/mmc" > Mmake.params
echo "EXTRA_MCFLAGS = $INSTALL_MCFLAGS" >> Mmake.params
echo "EXTRA_MGNUCFLAGS = $INSTALL_MGNUCFLAGS" >> Mmake.params
echo "EXTRA_CFLAGS = $INSTALL_CFLAGS" >> Mmake.params
echo "EXTRA_MLFLAGS = $INSTALL_MLFLAGS" >> Mmake.params
case "$INSTALL_GRADE" in
"") ;;
*) echo "GRADE = $INSTALL_GRADE" >> Mmake.params
;;
esac
# fi
# We allow "asm" as a special value for the C_COMPILER
# variable; it means to build with `--target asm'.
# $CC holds the name of the real C compiler.
case "$C_COMPILER" in
asm)
CC=gcc
target_opts="--target asm"
;;
*)
CC="$C_COMPILER"
target_opts=""
;;
esac
export CC
MMAKE="mmake $USE_MMC_MAKE"
if test "$INSTALL_LIBGRADES" != ""
then
echo "$INSTALL_LIBGRADES" > .enable_lib_grades
fi
# XXX Darwin attachs an underscore to the names of exported symbols, so the
# namespace cleanliness check will fail if we perform it on that platform.
namespace_opt=""
case "$HOST" in
eris)
namespace_opt="--no-check-namespace"
;;
esac
# XXX building the depend target in parallel sometimes fails so we don't
# do that at the moment - it's probably not worth doing anyway.
#
aclocal -I m4 || { false; exit 1; }
autoconf || { false; exit 1; }
rm -f config.cache
./configure --prefix=$INSTALL_DIR $CONFIG_OPTS || { false; exit 1; }
$MMAKE $target_opts depend || { false; exit 1; }
$MMAKE $target_opts realclean MMAKEFLAGS=$PARALLEL || { false; exit 1; }
./configure --prefix=$INSTALL_DIR $CONFIG_OPTS || { false; exit 1; }
$MMAKE $target_opts depend || { false; exit 1; }
version=`$MMAKE $target_opts version` || { false; exit 1; }
fullarch=`$MMAKE $target_opts fullarch` || { false; exit 1; }
tools/bootcheck $USE_MMC_MAKE $use_cp_opt $target_opts \
--keep-objs --copy-runtime $namespace_opt \
--no-test-suite $PARALLEL || $install_anyway || { false; exit 1; }
cd .. || { false; exit 1; }
#-----------------------------------------------------------------------------#
# Tests can fail if linked against an old library, and compiled
# with a new compiler, so we'll install the libraries first (so
# long as we bootcheck), then run all the tests in all the grades.
#
# Eventually, when we add more support for building multiple grades,
# we can test in all grades _before_ installing, but presently this
# is quite difficult.
: install the compiler
echo "test_mercury starting installation at `date`" 1>&2
echo "current directory `pwd`" 1>&2
case $status in 0)
case $install_anyway_stage1 in
false) cd mercury/stage2 || { false; exit 1; }
# we need to use the stage1 compiler to do the install
MERCURY_COMPILER=$DIR/mercury/compiler/mercury_compile
export MERCURY_COMPILER
;;
true) cd mercury || { false; exit 1; } ;;
esac
# Make a backup copy of the current installation which we will restore
# if the new installation fails. Note that we use `cp' here and not `mv',
# since later commands will still want to use the current installation.
BACKUP_DIR=`dirname $INSTALL_DIR`/mercury_install_backup
mkdir -p $BACKUP_DIR
cp -rf $INSTALL_DIR/* $BACKUP_DIR
# Previously we had lots of special case code here for installing on
# IRIX systems. We don't currently have any IRIX boxes, and this
# code was a bit of a pain to maintain. If we ever get an IRIX box
# again, look back in the CVS archives for version 1.114 to see
# the necessary code.
# Note that we don't pass $target_opts when doing `mmake install_grades';
# that wouldn't work, since many of the grades can only be built with
# `--target c'.
$MMAKE $target_opts install_main MMAKEFLAGS=$PARALLEL || \
set_status "install_main"
$MMAKE install_grades MMAKEFLAGS=$PARALLEL || \
set_status "install_grades"
case $install_anyway_stage1 in
false) cd ../.. || set_status "cd ../.." ;;
true) cd .. || set_status "cd .." ;;
esac
test -d $TESTDIR/logs || mkdir -p $TESTDIR/logs
case $status in
0)
date >> $TESTDIR/logs/install."$TEST_ID"
rm -f $TESTDIR/logs/install-failed."$TEST_ID"
;;
*)
date >> $TESTDIR/logs/install-failed."$TEST_ID"
# restore the previous installation
rm -rf $INSTALL_DIR
mv $BACKUP_DIR $INSTALL_DIR
;;
esac
esac
#-----------------------------------------------------------------------------#
# The stage2 compiler got installed, so we don't need to set
# MERCURY_COMPILER now.
# In fact, we should unset it, so it isn't set to something
# inappropriate by some other part of this script.
# Instead we just need to make sure that the compiler that we
# just installed is first in the PATH.
# From here-on in, we use the compiler that we just built and
# installed, not the bootstrap compiler.
unset MERCURY_COMPILER
PATH="$INSTALL_DIR/bin:$PATH"
GRADES="`(cd $DIR/mercury && $MMAKE echo_libgrades)`"
#-----------------------------------------------------------------------------#
: create distribution
echo "test_mercury starting to create distribution at `date`" 1>&2
case $HOST in $ROTD_HOST)
# The tests on $ROTD_HOST are run with `--intermodule-optimization', so we
# need to do a `mmake realclean' before building the C files for the source
# distribution. The extra compilation time for `--intermodule-optimization'
# is probably not acceptable for the source distribution.
#
# We specify the base grade to be asm_fast in order to ensure that the C
# files in the distribution are built in a low-level C grade.
# We use asm_fast rather than none or reg because the configure script
# will prefer the use of the hlc grades if they are the base grade.
#
# --smart-indexing is disabled for the source distribution because we
# currently generate non-portable code for some types of switches when
# it is enabled. (See bug #115 for further details -- it should be re-enbled
# once bug #115 has been fixed.)
#
# See above for an explanation of why we handle aclocal like this.
#
case $BRANCH in
latest)
ACLOCAL_CMD="aclocal -I m4"
;;
*)
ACLOCAL_CMD="true"
;;
esac
{ cd $DIR/mercury &&
$MMAKE realclean MMAKEFLAGS=$PARALLEL &&
(cd $DIR/tests &&
$MMAKE realclean MMAKEFLAGS=$PARALLEL) &&
: > Mmake.params &&
rm -f so_locations &&
rm -f .enable_lib_grades &&
$ACLOCAL_CMD &&
# The cache variable settings can be replaced by --pregenerated-dist.
autoconf &&
mercury_cv_low_tag_bits=2 \
mercury_cv_bits_per_word=32 \
mercury_cv_unboxed_floats=no \
sh configure --with-llds-base-grade=none --prefix=$INSTALL_DIR &&
$MMAKE MMAKEFLAGS="GRADE=hlc.gc.pregen EXTRA_MCFLAGS='-O5 --opt-space --cross-compiling --no-smart-indexing' $PARALLEL" tar &&
cd .. &&
rm -f $UNSTABLE/* &&
cp mercury/NEWS $UNSTABLE/mercury-NEWS-$version-unstable.txt &&
cp mercury/INSTALL $UNSTABLE/mercury-INSTALL-$version-unstable.txt &&
mv mercury-compiler-$version.tar.gz \
$UNSTABLE/mercury-compiler-$version-unstable.tar.gz &&
mv mercury-extras-$version.tar.gz \
$UNSTABLE/mercury-extras-$version-unstable.tar.gz &&
mv mercury-tests-$version.tar.gz \
$UNSTABLE/mercury-tests-$version-unstable.tar.gz
} || set_status "making source distribution"
# Later parts of this script assume that we've already run configure,
# so we need to redo that.
cd $DIR/mercury && sh configure --prefix=$INSTALL_DIR
cd $DIR
;;
esac
case $HOST in $GCC_ROTD_HOST)
# Build the mercury-gcc source distribution.
cd $DIR &&
rm -f mercury-gcc/stage[1-4] \
mercury-gcc/include \
mercury-gcc/mercury \
mercury-gcc/*.o &&
mv mercury-gcc mercury-gcc-$version &&
rm -f $UNSTABLE/mercury-gcc-$RELEASE_VERSION_PATTERN.tar.gz &&
tar -cf - mercury-gcc-$version | gzip -9 \
> $UNSTABLE/mercury-gcc-$version.tar.gz &&
mv mercury-gcc-$version mercury-gcc &&
true
;;
esac
#-----------------------------------------------------------------------------#
: run the regression tests on the installed compiler
cd tests || { false; exit 1; }
echo "test_mercury running tests in grades $GRADES" 1>&2
for grade in $GRADES
do
case $grade in
erlang*|java*|csharp*)
continue
;;
esac
echo "test_mercury starting tests for grade $grade at `date`" 1>&2
MERCURY_SUPPRESS_STACK_TRACE=yes
export MERCURY_SUPPRESS_STACK_TRACE
case $BRANCH in
*)
$MMAKE GRADE="$grade" \
EXTRA_MCFLAGS="$TEST_MCFLAGS" \
EXTRA_CFLAGS="$TEST_CFLAGS" \
EXTRA_MGNUCFLAGS="$TEST_MGNUCFLAGS" \
EXTRA_MLFLAGS="$TEST_MLFLAGS" \
$PARALLEL runtests || \
set_status "tests in grade $grade"
if test -f runtests.errs
then
touch $TEST_ERROR_FILE
cat runtests.errs >> $TEST_ERROR_FILE
fi
;;
esac
case $grade in
*.memprof*)
# We need to set LD_BIND_NOW=1
# for profiling on DEC Alpha.
(cd benchmarks &&
touch poly.m &&
$MMAKE poly.depend &&
$MMAKE poly \
GRADE="$grade" \
EXTRA_MCFLAGS="$TEST_MCFLAGS" \
EXTRA_MGNUCFLAGS="$TEST_MGNUCFLAGS" \
EXTRA_CFLAGS="$TEST_CFLAGS" \
EXTRA_MLFLAGS="$TEST_MLFLAGS" &&
LD_BIND_NOW=1 ./poly > poly.$grade.out &&
case $grade in
*hl*)
# For --high-level-code, we need to
# pass --no-demangle to mprof.
mprof --no-demangle -v -m -c \
> poly.$grade.mprof 2>&1 &&
{ diff -u poly.mprof-exp2 poly.$grade.mprof || true; }
;;
*)
mprof -v -m -c > poly.$grade.mprof 2>&1 &&
{ diff -u poly.mprof-exp poly.$grade.mprof || true; }
;;
esac &&
cp Prof.CallPair poly.$grade.CallPair &&
cp Prof.MemoryWords poly.$grade.MemoryWords &&
cp Prof.MemoryCells poly.$grade.MemoryCells &&
cp Prof.Decl poly.$grade.Decl) ||
set_status "benchmarks/poly in grade *.memprof*"
;;
esac
echo "test_mercury finished tests for grade $grade at `date`" 1>&2
done
if test -s $TEST_ERROR_FILE
then
fgrep "FAILED TEST" $TEST_ERROR_FILE > $FAILED_TESTS_FILE
fi
echo "test_mercury finished tests at `date`" 1>&2
cd ..
#-----------------------------------------------------------------------------#
: update the unstable release
case $HOST in $ROTD_HOST)
if test -s $TEST_ERROR_FILE
then
{ cat $FAILED_TESTS_FILE;
echo "";
echo "Test logs for the failed test cases:";
echo "";
cat $TEST_ERROR_FILE;
} > $UNSTABLE/mercury-test-failures-$version-unstable.txt
else
rm -f $UNSTABLE/mercury-test-failures-$version-unstable.txt
fi &&
ssh $BETA_FTPHOST "\
[ -d $BETA_FTPDIR ] || mkdir $BETA_FTPDIR" &&
scp $UNSTABLE/mercury-*-$version-unstable.* \
$BETA_FTPHOST:$BETA_FTPDIR &&
ssh $BETA_FTPHOST "\
echo $version > $BETA_FTPDIR/latest-unstable-version" &&
([ -d $BETA_WEBDIR ] || mkdir $BETA_WEBDIR) &&
cp $UNSTABLE/mercury-*-$version-unstable.* $BETA_WEBDIR &&
echo $version > $BETA_WEBDIR/latest-unstable-version \
|| set_status "copying ROTD"
;;
esac
case $HOST in $GCC_ROTD_HOST)
ssh $BETA_FTPHOST "\
[ -d $BETA_FTPDIR ] || mkdir $BETA_FTPDIR
rm -f \
$BETA_FTPDIR/mercury-gcc-$RELEASE_VERSION_PATTERN-unstable.tar.gz" &&
scp $UNSTABLE/mercury-gcc-$version.tar.gz \
$BETA_FTPHOST:$BETA_FTPDIR/mercury-gcc-$version-unstable.tar.gz &&
([ -d $BETA_WEBDIR ] || mkdir $BETA_WEBDIR) &&
rm -f $BETA_WEBDIR/mercury-gcc-$RELEASE_VERSION_PATTERN-unstable.tar.gz &&
cp $UNSTABLE/mercury-gcc-$version.tar.gz \
$BETA_WEBDIR/mercury-gcc-$version-unstable.tar.gz \
|| set_status "copying mercury-gcc ROTD"
;;
esac
#-----------------------------------------------------------------------------#
: build the binary distribution
echo "test_mercury starting to create binary distribution at `date`" 1>&2
# For the Linux systems, we need to distinguish them based
# on the version of GNU libc.
# Also we distinguish them based on what optimization level
# they were compiled with.
case $HOST in
saturn)
fullname=x86_64-unknown-linux-gnu-libc2.7-gnu-O2-intermod
;;
neptune)
fullname=x86_64-unknown-linux-gnu-libc2.9-gnu-O4
;;
goofy)
fullname=x86_64-unknown-linux-gnu-libc2.9-gnu-O2-intermod-hlc
;;
*)
fullname=$fullarch
;;
esac
case "$C_COMPILER" in
gcc) ;;
*) fullname="$fullname-$C_COMPILER" ;;
esac
# cvs does not allow `.' or space in tag names, so we use `_' instead
fullname_tag=`echo $fullname | tr ' .' __`
# On murlibobo building the binary distribution takes a lot of CPU time.
case $HOST in
*) ulimit -S -t unlimited ;;
esac
{
cd $DIR/mercury &&
$MMAKE bindist &&
cd .. &&
{ [ -d $UNSTABLE ] || mkdir $UNSTABLE; } &&
rm -f $UNSTABLE/mercury-*.$fullname.tar.gz &&
rm -f $UNSTABLE/mercury-*.$fullname.txt &&
cp mercury/NEWS $UNSTABLE/mercury-NEWS-$version.$fullname.txt &&
cp mercury/bindist/bindist.INSTALL \
$UNSTABLE/mercury-INSTALL-$version.$fullname.txt &&
if test -s $TEST_ERROR_FILE
then
{ cat $FAILED_TESTS_FILE;
echo "";
echo "Test logs for the failed test cases:";
echo "";
cat $TEST_ERROR_FILE;
} > $UNSTABLE/mercury-test-failures-$version.$fullname.txt
else
rm -f $UNSTABLE/mercury-test-failures-$version.$fullname.txt
fi &&
mv mercury/mercury-$version.$fullarch.tar.gz \
$UNSTABLE/mercury-$version.$fullname.tar.gz
} || set_status "creating binary distribution"
case $status in
0) {
cd $DIR &&
{ test -d $STABLE || mkdir $STABLE; } &&
rm -f $STABLE/mercury*-$RELEASE_VERSION_PATTERN.$fullname.tar.gz &&
rm -f $STABLE/mercury*-$RELEASE_VERSION_PATTERN.$fullname.txt &&
$LN $UNSTABLE/mercury-$version.$fullname.tar.gz \
$STABLE/mercury-$version.$fullname.tar.gz &&
$LN $UNSTABLE/mercury-NEWS-$version.$fullname.txt \
$STABLE/mercury-NEWS-$version.$fullname.txt &&
$LN $UNSTABLE/mercury-INSTALL-$version.$fullname.txt \
$STABLE/mercury-INSTALL-$version.$fullname.txt &&
ssh $BETA_FTPHOST "\
[ -d $BETA_FTPDIR ] || mkdir $BETA_FTPDIR
rm -f \
$BETA_FTPDIR/mercury-$RELEASE_VERSION_PATTERN.$fullname.tar.gz \
$BETA_FTPDIR/mercury*-$RELEASE_VERSION_PATTERN.$fullname.txt" &&
scp $STABLE/mercury*-$version.$fullname.* $BETA_FTPHOST:$BETA_FTPDIR
} || set_status "copying binary distribution"
;;
esac
echo "test_mercury finished binary distribution at `date`" 1>&2
#-----------------------------------------------------------------------------#
case $status in
0)
: if we get this far, then it worked.
test -d $TESTDIR/logs || mkdir -p $TESTDIR/logs
date >> $TESTDIR/logs/success."$TEST_ID"
case $HOST in $ROTD_HOST)
cd $DIR &&
# Delete older stable versions that this one replaces
rm -f $STABLE/mercury-*-$RELEASE_VERSION_PATTERN[0-9].tar.gz &&
rm -f $STABLE/mercury-*-$RELEASE_VERSION_PATTERN[0-9].txt &&
rm -f $STABLE/mercury-*-$version.tar.gz &&
rm -f $STABLE/mercury-*-$version.txt &&
$LN $UNSTABLE/mercury-compiler-$version-unstable.tar.gz \
$STABLE/mercury-compiler-$version.tar.gz &&
$LN $UNSTABLE/mercury-extras-$version-unstable.tar.gz \
$STABLE/mercury-extras-$version.tar.gz &&
$LN $UNSTABLE/mercury-tests-$version-unstable.tar.gz \
$STABLE/mercury-tests-$version.tar.gz &&
$LN $UNSTABLE/mercury-NEWS-$version-unstable.txt \
$STABLE/mercury-NEWS-$version.txt &&
$LN $UNSTABLE/mercury-INSTALL-$version-unstable.txt \
$STABLE/mercury-INSTALL-$version.txt &&
ssh $BETA_FTPHOST "\
[ -d $BETA_FTPDIR ] || mkdir $BETA_FTPDIR
rm -f $BETA_FTPDIR/mercury-*-$RELEASE_VERSION_PATTERN[0-9].tar.gz \
$BETA_FTPDIR/mercury-*-$version.tar.gz \
$BETA_FTPDIR/mercury-*-$RELEASE_VERSION_PATTERN[0-9].txt \
$BETA_FTPDIR/mercury-*-$version.txt &&
$LN $BETA_FTPDIR/mercury-compiler-$version-unstable.tar.gz \
$BETA_FTPDIR/mercury-compiler-$version.tar.gz &&
$LN $BETA_FTPDIR/mercury-extras-$version-unstable.tar.gz \
$BETA_FTPDIR/mercury-extras-$version.tar.gz &&
$LN $BETA_FTPDIR/mercury-tests-$version-unstable.tar.gz \
$BETA_FTPDIR/mercury-tests-$version.tar.gz &&
$LN $BETA_FTPDIR/mercury-NEWS-$version-unstable.txt \
$BETA_FTPDIR/mercury-NEWS-$version.txt &&
$LN $BETA_FTPDIR/mercury-INSTALL-$version-unstable.txt \
$BETA_FTPDIR/mercury-INSTALL-$version.txt &&
echo $version > $BETA_FTPDIR/latest-stable-version" &&
rm -f $BETA_WEBDIR/mercury-compiler-$RELEASE_VERSION_PATTERN[0-9].tar.gz &&
rm -f $BETA_WEBDIR/mercury-extras-$RELEASE_VERSION_PATTERN[0-9].tar.gz &&
rm -f $BETA_WEBDIR/mercury-tests-$RELEASE_VERSION_PATTERN[0-9].tar.gz &&
rm -f $BETA_WEBDIR/mercury-NEWS-$RELEASE_VERSION_PATTERN[0-9].txt &&
rm -f $BETA_WEBDIR/mercury-INSTALL-$RELEASE_VERSION_PATTERN[0-9].txt &&
$LN $BETA_WEBDIR/mercury-compiler-$version-unstable.tar.gz \
$BETA_WEBDIR/mercury-compiler-$version.tar.gz &&
$LN $BETA_WEBDIR/mercury-extras-$version-unstable.tar.gz \
$BETA_WEBDIR/mercury-extras-$version.tar.gz &&
$LN $BETA_WEBDIR/mercury-tests-$version-unstable.tar.gz \
$BETA_WEBDIR/mercury-tests-$version.tar.gz &&
$LN $BETA_WEBDIR/mercury-NEWS-$version-unstable.txt \
$BETA_WEBDIR/mercury-NEWS-$version.txt &&
$LN $BETA_WEBDIR/mercury-INSTALL-$version-unstable.txt \
$BETA_WEBDIR/mercury-INSTALL-$version.txt &&
echo $version > $BETA_WEBDIR/latest-stable-version
;;
esac || set_status "updating stable mercury source distribution"
case $HOST in $GCC_ROTD_HOST)
cd $DIR &&
# Delete older stable versions that this one replaces
rm -f $STABLE/mercury-gcc-$RELEASE_VERSION_PATTERN[0-9].tar.gz &&
rm -f $STABLE/mercury-gcc-$version.tar.gz &&
$LN $UNSTABLE/mercury-gcc-$version.tar.gz \
$STABLE/mercury-gcc-$version.tar.gz &&
ssh $BETA_FTPHOST "\
[ -d $BETA_FTPDIR ] || mkdir $BETA_FTPDIR
rm -f $BETA_FTPDIR/mercury-gcc-$RELEASE_VERSION_PATTERN[0-9].tar.gz \
$BETA_FTPDIR/mercury-gcc-$version.tar.gz &&
$LN $BETA_FTPDIR/mercury-gcc-$version-unstable.tar.gz \
$BETA_FTPDIR/mercury-gcc-$version.tar.gz" &&
rm -f $BETA_WEBDIR/mercury-gcc-$RELEASE_VERSION_PATTERN[0-9].tar.gz &&
$LN $BETA_WEBDIR/mercury-gcc-$version-unstable.tar.gz \
$BETA_WEBDIR/mercury-gcc-$version.tar.gz
;;
esac || set_status "updating stable mercury-gcc source distribution"
;;
*)
;;
esac
# Now rebuild the index files on the WWW site.
case $HOST in
$ROTD_HOST)
echo "test_mercury generating www index files, starting at `date`" 1>&2
(
cd $BETA_WEBDIR_TOP &&
generate_index_html
) || set_status "generating www index"
echo "test_mercury generating www index files, finished at `date`" 1>&2
;;
*)
;;
esac
# Now rebuild the index files on the FTP site.
echo "test_mercury generating ftp index files, starting at `date`" 1>&2
ssh $BETA_FTPHOST "\
PATH=/home/mercury/public/cron/scripts:\$PATH &&
export PATH &&
( [ -d $BETA_FTPDIR ] || mkdir $BETA_FTPDIR ) &&
cd $BETA_FTPDIR &&
generate_index_html" || set_status "generating ftp index"
echo "test_mercury generating ftp index files, finished at `date`" 1>&2
: check for success
case $status in
0)
echo "Installation directory: $INSTALL_DIR" 1>&2
echo "test_mercury exiting successfully at `date`" 1>&2
true
exit 0
;;
*)
: one or more tests failed
echo "some tests failed" 1>&2
echo "test_mercury exiting unsuccessfully at `date`" 1>&2
false
exit 1
;;
esac
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#