mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +00:00
Estimated hours taken: 6 configure.in: Rename BRANCH_DELAY_SLOT to HAVE_DELAY_SLOT. bootcheck: Add a new option, -r. If given, this makes a copy of the runtime directory instead of linking to it in stage[23]. This allows the stage[23] versions to use a different grade than stage1. Another change is that we now remake only the library and compiler dependencies, but not the profiler dependencies. binary: A shell script to find code generation and optimization bugs by performing binary search. It depends on the existence of two directories, stage2.ok and stage2.bad, containing correct and buggy versions of stage2, and tries different mixes of .c code from each until it locates the offending part of the offending .c file. Note that this script has so far been tested only in pieces. binary_step: Check whether a particular mix of .c files from the ok and bad directories is able to build a stage3 compiler. It doesn't check for differences from stage2, since stage2 is a patchwork. divide: Divide a .c file into its parts. assemble: Assemble a .c file, with the specified parts coming from the .c file in stage2.bad and the others from stage2.ok. NOTE: these scripts require some other auxiliary scripts. I will put these into /usr/local/contrib when it is created on cyclone. In the meantime, they are in ~zs/bin/script.
251 lines
4.8 KiB
Bash
Executable File
251 lines
4.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
usage="\
|
|
Usage: $0 [options]
|
|
Options:
|
|
-h, --help
|
|
Display this usage message.
|
|
-j <num-jobs>, --jobs <num-jobs>
|
|
Run using <num-jobs> different parallel processes.
|
|
-m <mmake-args>, --mmake-args <mmake-args>
|
|
Pass <mmake-args> as options to \`mmake'.
|
|
"
|
|
|
|
jfactor=
|
|
mmake_opts=""
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
|
|
-h|--help)
|
|
echo "$usage"
|
|
exit 0 ;;
|
|
|
|
-j|--jobs)
|
|
jfactor="-j$2"; shift ;;
|
|
-j*)
|
|
jfactor="-j` expr $1 : '-j\(.*\)' `" ;;
|
|
--jobs*)
|
|
jfactor="--jobs` expr $1 : '--jobs\(.*\)' `" ;;
|
|
|
|
-m|--mmake)
|
|
mmake_opts="$mmake_opts $2"; shift ;;
|
|
|
|
--)
|
|
shift; break ;;
|
|
-*)
|
|
echo "$0: unknown option \`$1'" 1>&2
|
|
echo "$usage" 1>&2
|
|
exit 1 ;;
|
|
*)
|
|
break ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
root=`/bin/pwd`
|
|
|
|
if test -d stage2.ok -a -d stage2.bad
|
|
then
|
|
echo "stage2.ok and stage2.bad both present"
|
|
else
|
|
echo "at least one of stage2.ok and stage2.bad is missing"
|
|
exit 1
|
|
fi
|
|
|
|
[ -d stage2 ] || mkdir stage2
|
|
/bin/rm -fr stage2/*
|
|
cd stage2
|
|
mkdir compiler
|
|
cd compiler
|
|
ln -s ../../compiler/*.m .
|
|
ln -s ../../compiler/Mmake* .
|
|
cd ..
|
|
mkdir library
|
|
cd library
|
|
ln -s ../../library/*.m .
|
|
ln -s ../../library/*.nl .
|
|
ln -s ../../library/Mmake* .
|
|
ln -s ../../library/library.init .
|
|
cd ..
|
|
ln -s ../runtime .
|
|
ln -s ../boehm_gc .
|
|
ln -s ../doc .
|
|
ln -s ../scripts .
|
|
ln -s ../util .
|
|
ln -s ../profiler .
|
|
ln -s ../Mmake* .
|
|
ln -s ../conf* .
|
|
rm -f config*.log
|
|
cd ..
|
|
|
|
# We don't copy the .d files. This prevents mmake from trying to remake any
|
|
# of the .c and .o files, which we provide in the form they should be used.
|
|
|
|
# cp stage2.ok/library/*.d stage2/library
|
|
cp stage2.ok/library/*.dep stage2/library
|
|
cp stage2.ok/library/*.int stage2/library
|
|
cp stage2.ok/library/*.int2 stage2/library
|
|
cp stage2.ok/library/*.date stage2/library
|
|
# cp stage2.ok/compiler/*.d stage2/compiler
|
|
cp stage2.ok/compiler/*.dep stage2/compiler
|
|
cp stage2.ok/compiler/*.int stage2/compiler
|
|
cp stage2.ok/compiler/*.int2 stage2/compiler
|
|
cp stage2.ok/compiler/*.date stage2/compiler
|
|
|
|
# See if the stage2.bad library works
|
|
|
|
cp stage2.bad/library/*.[co] stage2/library
|
|
cp stage2.ok/compiler/*.[co] stage2/compiler
|
|
|
|
if ./binary_step $jfactor -m "$mmake_opts"
|
|
then
|
|
problemdir=compiler
|
|
else
|
|
problemdir=library
|
|
fi
|
|
|
|
echo "problem seems to be in the $problemdir directory"
|
|
|
|
# start out with all files in stage2 coming from stage2.ok
|
|
|
|
cp stage2.ok/library/*.[co] stage2/library
|
|
|
|
# find the set of candidate modules
|
|
|
|
cd stage2/$problemdir
|
|
allfiles=`sub X.c X *.c`
|
|
cd ../..
|
|
|
|
doubtful="$allfiles"
|
|
tested=`half $doubtful`
|
|
knowngood=
|
|
|
|
while test "$tested" != ""
|
|
do
|
|
# at this point, all the files in stage2 should be from stage2.ok
|
|
|
|
echo "doubtful modules: $doubtful"
|
|
echo "testing modules: $tested"
|
|
|
|
for module in $tested
|
|
do
|
|
cp stage2.bad/$problemdir/$module.[co] stage2/$problemdir
|
|
done
|
|
|
|
if ./binary_step $jfactor -m "$mmake_opts"
|
|
then
|
|
echo "test succeeded"
|
|
knowngood="$knowngood $tested"
|
|
newdoubtful=""
|
|
for module in $doubtful
|
|
do
|
|
if not appears $module $tested
|
|
then
|
|
newdoubtful="$newdoubtful $module"
|
|
fi
|
|
done
|
|
doubtful="$newdoubtful"
|
|
lasttest=success
|
|
else
|
|
echo "test failed"
|
|
doubtful="$tested"
|
|
lasttest=failure
|
|
fi
|
|
|
|
for module in $tested
|
|
do
|
|
cp stage2.ok/$problemdir/$module.[co] stage2/$problemdir
|
|
done
|
|
|
|
tested=`half $doubtful`
|
|
if test "$tested" = "" -a "$lasttest" = success
|
|
then
|
|
tested="$doubtful"
|
|
fi
|
|
done
|
|
|
|
if test "$doubtful = ""
|
|
then
|
|
echo "cannot find the problem; all modules seem ok"
|
|
exit 1
|
|
fi
|
|
|
|
module="$doubtful"
|
|
arg $module
|
|
|
|
echo "there is a problem in $problemdir/$module"
|
|
echo "the modules known to be ok are: $knowngood"
|
|
echo
|
|
|
|
okcnt=`egrep '^END_MODULE' stage2.ok/$problemdir/$module.c | wc -l`
|
|
badcnt=`egrep '^END_MODULE' stage2.bad/$problemdir/$module.c | wc -l`
|
|
|
|
if test $okcnt -ne $badcnt
|
|
then
|
|
echo "the two versions of the problem module"
|
|
echo "differ in the number of C modules they have"
|
|
echo "ok version: $okcnt vs bad version: $badcnt"
|
|
exit 1
|
|
fi
|
|
|
|
for dir in ok bad
|
|
do
|
|
cd stage2.$dir/$problemdir
|
|
../../divide $module.c $okcnt
|
|
cd ../..
|
|
done
|
|
|
|
doubtful=
|
|
i=0
|
|
while test $i -le $okcnt
|
|
do
|
|
doubtful="$doubtful $i"
|
|
i=`expr $i + 1`
|
|
done
|
|
|
|
tested=`half $doubtful`
|
|
knowngood=
|
|
|
|
while test "$tested" != ""
|
|
do
|
|
echo "doubtful: $doubtful"
|
|
echo "testing: $tested"
|
|
|
|
./assemble $problemdir $module $okcnt $tested
|
|
cd stage2/$problemdir
|
|
/bin/rm $module.o
|
|
mmake $module.o
|
|
cd ../..
|
|
|
|
if ./binary_step $jfactor -m "$mmake_opts"
|
|
then
|
|
echo "test succeeded"
|
|
knowngood="$knowngood $tested"
|
|
newdoubtful=""
|
|
for part in $doubtful
|
|
do
|
|
if not appears $part $tested
|
|
then
|
|
newdoubtful="$newdoubtful $part"
|
|
fi
|
|
done
|
|
doubtful="$newdoubtful"
|
|
lasttest=success
|
|
else
|
|
echo "test failed"
|
|
doubtful="$tested"
|
|
lasttest=failure
|
|
fi
|
|
|
|
tested=`half $doubtful`
|
|
if test "$tested" = "" -a "$lasttest" = success
|
|
then
|
|
tested="$doubtful"
|
|
fi
|
|
done
|
|
|
|
echo "there is a problem in $problemdir/$module.c.part.$doubtful"
|
|
echo "the parts known to be ok are: $knowngood"
|
|
exit 0
|