1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
#!/bin/sh
#
# A program to prepare batches of versions of the compiler.
#
# The control and output files are all in the subdirectory batch.
# The control files are $batch.MCFLAGS and possibly $batch.CFLAGS,
# $batch.GRADE, and/or $batch.MMAKE, where $batch is the last argument
# of makebatch. $batch.CFLAGS, $batch.GRADE and $batch.MMAKE are consulted
# if they exist.
#
# The control files $batch.MCFLAGS, $batch.CFLAGS and $batch.GRADE must have
# the same number of lines. Each line corresponds to a version of the compiler
# that is built with the MCFLAGS, EXTRA_CFLAGS and GRADE make variables
# being set from that line.
#
# The control file $batch.MMAKE contains an Mmakefile fragment that is
# included in the parameters of all the versions being built.
#
# The output goes in $batch.mercury_compile.$n.gz; the sizes of the versions
# are put in $batch.sizes. If a bootcheck fails, the bootcheck output goes
# in $batch.out.$n; the compiler will be thrown away unless the -f flag is
# given.
#
# The file $batch.checkpoint records which version is to be built next.
# Reinvoking makebatch while this file exists will cause it to start from
# that version. When makebatch exits normally, it removes the file to indicate
# completion.
usage="Usage: makebatch [-jN] [-fot] batchname"
jfactor=-j1
runtests=""
objects=""
failed="notwanted"
while test $# -gt 0
do
case $1 in
-f|--failed-compilers)
failed="wanted" ;;
-j|--jobs)
jfactor="-j$2" ; shift ;;
-j*)
jfactor="-j` expr $1 : '-j\(.*\)' `" ;;
--jobs*)
jfactor="--jobs` expr $1 : '--jobs\(.*\)' `" ;;
-o|--object-files)
objects="-k" ;;
-t|--no-test-suite)
runtests="-t" ;;
-*) echo "$0: unknown option \`$1'" 2>&1
echo $usage
exit 1 ;;
*) break ;;
esac
shift
done
if test $# != 1
then
echo $usage
exit 1
fi
batch=$1
if test ! -r batch/$batch.MCFLAGS
then
echo "batch/$batch.MCFLAGS does not exist or is not readable"
exit 1
fi
if test -r batch/$batch.CFLAGS
then
needcflags=true
else
needcflags=false
fi
if test -r batch/$batch.GRADE
then
needgrade=true
else
needgrade=false
fi
if test -r batch/$batch.MMAKE
then
needmmake=true
else
needmmake=false
fi
if test -f Mmake.stage.params
then
echo moving Mmake.stage.params to Mmake.stage.params.$$
mv Mmake.stage.params Mmake.stage.params.$$
fi
if test -r batch/$batch.checkpoint
then
n=`cat batch/$batch.checkpoint`
else
n=1
cat /dev/null > batch/$batch.sizes
fi
maxn=`wc -l < batch/$batch.MCFLAGS`
while test $n -le $maxn
do
if $needmmake
then
cp batch/$batch.MMAKE Mmake.stage.params
else
cat < /dev/null > Mmake.stage.params
fi
mcflags=`awk "NR == $n" batch/$batch.MCFLAGS`
echo "EXTRA_MCFLAGS = $mcflags" >> Mmake.stage.params
if $needcflags
then
cflags=`awk "NR == $n" batch/$batch.CFLAGS`
echo "EXTRA_CFLAGS = $cflags" >> Mmake.stage.params
fi
if $needgrade
then
grade=`awk "NR == $n" batch/$batch.GRADE`
echo "GRADE = $grade" >> Mmake.stage.params
fi
cp Mmake.stage.params batch/$batch.params.$n
echo starting bootcheck of version $n
if tools/bootcheck -r $jfactor $runtests $objects > batch/$batch.out.$n 2>&1
then
echo bootcheck of version $n succeeded
echo bootcheck succeeded > batch/$batch.out.$n
mv stage2/compiler/mercury_compile batch/$batch.mercury_compile.$n
echo -n "batch/$batch.mercury_compile.$n " >> batch/$batch.sizes
size batch/$batch.mercury_compile.$n | tail -1 >> batch/$batch.sizes
/bin/rm -f batch/$batch.mercury_compile.$n.gz > /dev/null 2>&1
gzip batch/$batch.mercury_compile.$n
else
if test "$failed" = "wanted"
then
if test -x stage2/compiler/mercury_compile
then
echo bootcheck of version $n failed but produced compiler
mv stage2/compiler/mercury_compile batch/$batch.mercury_compile.$n
size batch/$batch.mercury_compile.$n | tail -1 >> batch/$batch.sizes
/bin/rm -f batch/$batch.mercury_compile.$n.gz > /dev/null 2>&1
gzip batch/$batch.mercury_compile.$n
else
echo bootcheck of version $n failed and did not produce compiler
fi
else
echo bootcheck of version $n failed
fi
fi
if test "$objects" = "-k"
then
echo saving object files
mkdir -p batch/objs/$batch.library.$n
/bin/rm -fr batch/objs/$batch.library.$n/*
cp stage2/library/*.o batch/objs/$batch.library.$n
gzip batch/objs/$batch.library.$n/*
mkdir -p batch/objs/$batch.compiler.$n
/bin/rm -fr batch/objs/$batch.compiler.$n/*
cp stage2/compiler/*.o batch/objs/$batch.compiler.$n
gzip batch/objs/$batch.compiler.$n/*
fi
n=`expr $n + 1`
echo $n > batch/$batch.checkpoint
done
/bin/rm -f batch/$batch.checkpoint
if test -f Mmake.stage.params.$$
then
echo moving Mmake.stage.params.$$ to Mmake.stage.params
mv Mmake.stage.params.$$ Mmake.stage.params
fi
exit 0
|