mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-22 21:03:53 +00:00
Estimated hours taken: 0.1 bootcheck: Link a smaller number of modules at a time to the stage2 directories. This ought to fix the problem with muse's argument vector overflowing. test_mercury: Fix a comment.
313 lines
6.4 KiB
Bash
Executable File
313 lines
6.4 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'.
|
|
-o <filename>, --output-file <filename>
|
|
Output results to <filename>.
|
|
-r, --copy-runtime
|
|
Copy the runtime directory instead of linking it.
|
|
-2, --keep-stage-2
|
|
Don't rebuild the stage 2 directory from scratch after
|
|
building stage 1. Instead use the existing stage 2 directory.
|
|
-3, --keep-stage-3
|
|
Don't rebuild the stage 3 directory from scratch after
|
|
building stage 1. Instead use the existing stage 3 directory.
|
|
"
|
|
|
|
jfactor=""
|
|
mmake_opts="-k"
|
|
outfile=""
|
|
copy_runtime=false
|
|
keep_stage_2=false
|
|
keep_stage_3=false
|
|
|
|
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 ;;
|
|
|
|
-o|--output-file)
|
|
outfile="$2"; shift ;;
|
|
-o*)
|
|
outfile="` expr $1 : '-o\(.*\)' `"; ;;
|
|
|
|
-r|--copy-runtime)
|
|
copy_runtime=true ;;
|
|
|
|
-2|--keep-stage-2)
|
|
keep_stage_2=true ;;
|
|
|
|
-3|--keep-stage-3)
|
|
keep_stage_3=true ;;
|
|
|
|
--)
|
|
shift; break ;;
|
|
-*)
|
|
echo "$0: unknown option \`$1'" 1>&2
|
|
echo "$usage" 1>&2
|
|
exit 1 ;;
|
|
*)
|
|
break ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ $# -ne 0 ]; then
|
|
echo "$0: unexpected argument(s) \`$*'" 1>&2
|
|
echo "$usage" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "starting at `date`"
|
|
|
|
root=`/bin/pwd`
|
|
PATH=$root/tools:$PATH
|
|
export PATH
|
|
|
|
set -x
|
|
|
|
if mmake $mmake_opts MMAKEFLAGS=$jfactor all
|
|
then
|
|
echo "building of stage 1 successful"
|
|
else
|
|
echo "building of stage 1 not successful"
|
|
exit 1
|
|
fi
|
|
|
|
root=`/bin/pwd`
|
|
|
|
# the stage 1 compiler is copied to allow it to be worked on
|
|
# in parallel with the bootcheck itself.
|
|
|
|
[ -d stage1 ] || mkdir stage1
|
|
|
|
cp compiler/mercury_compile stage1
|
|
MERCURY_COMPILER=$root/stage1/mercury_compile
|
|
export MERCURY_COMPILER
|
|
MERCURY_INT_DIR=$root/stage2/library
|
|
export MERCURY_INT_DIR
|
|
|
|
# .pp files are not necessary
|
|
|
|
[ -d stage2 ] || mkdir stage2
|
|
$keep_stage_2 || /bin/rm -fr stage2/*
|
|
set +x
|
|
echo linking stage 2... 1>&2
|
|
cd stage2
|
|
mkdir compiler
|
|
cd compiler
|
|
# Break up the links into several chunks.
|
|
# This is needed to cope with small limits on the size of argument vectors.
|
|
ln -s $root/compiler/[a-h]*.m .
|
|
ln -s $root/compiler/[i-s]*.m .
|
|
ln -s $root/compiler/[t-z]*.m .
|
|
cp $root/compiler/Mmake* .
|
|
cd $root/stage2
|
|
mkdir library
|
|
cd library
|
|
ln -s $root/library/[a-l]*.m .
|
|
ln -s $root/library/[m-z]*.m .
|
|
# ln -s $root/library/*.nl .
|
|
cp $root/library/Mmake* .
|
|
ln -s $root/library/library.init .
|
|
cd $root/stage2
|
|
if test "$copy_runtime" = "true"
|
|
then
|
|
mkdir runtime
|
|
cd runtime
|
|
ln -s $root/runtime/*.h .
|
|
ln -s $root/runtime/*.c .
|
|
ln -s $root/runtime/*.mod .
|
|
ln -s $root/runtime/*.in .
|
|
cp $root/runtime/Mmake* .
|
|
ln -s $root/runtime/machdeps .
|
|
cd $root/stage2
|
|
else
|
|
ln -s $root/runtime .
|
|
fi
|
|
ln -s $root/boehm_gc .
|
|
ln -s $root/doc .
|
|
ln -s $root/scripts .
|
|
ln -s $root/util .
|
|
ln -s $root/profiler .
|
|
ln -s $root/conf* .
|
|
rm -f config*.log
|
|
cp $root/Mmake* .
|
|
if test -f $root/Mmake.stage.params
|
|
then
|
|
/bin/rm -f Mmake.params
|
|
cp $root/Mmake.stage.params Mmake.params
|
|
fi
|
|
cd $root
|
|
|
|
set -x
|
|
|
|
if (cd stage2 ; mmake $mmake_opts $jfactor runtime)
|
|
then
|
|
echo "building of stage 2 runtime successful"
|
|
else
|
|
echo "building of stage 2 runtime not successful"
|
|
exit 1
|
|
fi
|
|
|
|
if (cd stage2 ; mmake $mmake_opts depend_library depend_compiler)
|
|
then
|
|
echo "building of stage 2 dependencies successful"
|
|
else
|
|
echo "building of stage 2 dependencies not successful"
|
|
exit 1
|
|
fi
|
|
|
|
MMAKE_VPATH=.
|
|
export MMAKE_VPATH
|
|
MMAKE_DIR=$root/scripts
|
|
export MMAKE_DIR
|
|
|
|
# the `RM_C=:' ensures that the `.c' files do not get deleted
|
|
|
|
if (cd stage2/library ; mmake $mmake_opts $jfactor RM_C=: libmercury)
|
|
then
|
|
echo "building of stage 2 library successful"
|
|
else
|
|
echo "building of stage 2 library not successful"
|
|
exit 1
|
|
fi
|
|
|
|
if (cd stage2/compiler ; mmake $mmake_opts $jfactor RM_C=: mercury_compile)
|
|
then
|
|
echo "building of stage 2 compiler successful"
|
|
else
|
|
echo "building of stage 2 compiler not successful"
|
|
exit 1
|
|
fi
|
|
|
|
unset MMAKE_VPATH
|
|
unset MMAKE_DIR
|
|
|
|
if (cd stage2 ; mmake $mmake_opts $jfactor all)
|
|
then
|
|
echo "building of stage 2 successful"
|
|
else
|
|
echo "building of stage 2 not successful"
|
|
exit 1
|
|
fi
|
|
|
|
MERCURY_COMPILER=$root/stage2/compiler/mercury_compile
|
|
export MERCURY_COMPILER
|
|
MERCURY_INT_DIR=$root/stage3/library
|
|
export MERCURY_INT_DIR
|
|
|
|
# .pp files are not necessary
|
|
|
|
[ -d stage3 ] || mkdir stage3
|
|
$keep_stage_3 || /bin/rm -fr stage3/*
|
|
echo linking stage 3... 1>&2
|
|
set +x
|
|
cd stage3
|
|
mkdir compiler
|
|
cd compiler
|
|
# Break up the links into several chunks.
|
|
# This is needed to cope with small limits on the size of argument vectors.
|
|
ln -s $root/compiler/[a-h]*.m .
|
|
ln -s $root/compiler/[i-s]*.m .
|
|
ln -s $root/compiler/[t-z]*.m .
|
|
cp $root/compiler/Mmake* .
|
|
cd $root/stage3
|
|
mkdir library
|
|
cd library
|
|
ln -s $root/library/[a-l]*.m .
|
|
ln -s $root/library/[m-z]*.m .
|
|
# ln -s $root/library/*.nl .
|
|
cp $root/library/Mmake* .
|
|
ln -s $root/library/library.init .
|
|
cd $root/stage3
|
|
ln -s $root/boehm_gc .
|
|
ln -s $root/doc .
|
|
ln -s $root/runtime .
|
|
ln -s $root/scripts .
|
|
ln -s $root/util .
|
|
ln -s $root/profiler .
|
|
ln -s $root/conf* .
|
|
rm -f config*.log
|
|
cp $root/Mmake* .
|
|
if test -f $root/Mmake.stage.params
|
|
then
|
|
/bin/rm -f Mmake.params
|
|
ln -s $root/Mmake.stage.params Mmake.params
|
|
fi
|
|
cd $root
|
|
set -x
|
|
|
|
if (cd stage3 ; mmake $mmake_opts depend_library depend_compiler)
|
|
then
|
|
echo "building of stage 3 dependencies successful"
|
|
else
|
|
echo "building of stage 3 dependencies not successful"
|
|
exit 1
|
|
fi
|
|
|
|
MMAKE_VPATH=.
|
|
export MMAKE_VPATH
|
|
MMAKE_DIR=$root/scripts
|
|
export MMAKE_DIR
|
|
|
|
if (cd stage3/library ; mmake $mmake_opts $jfactor cs)
|
|
then
|
|
echo "building of stage 3 library successful"
|
|
else
|
|
echo "building of stage 3 library not successful"
|
|
exit 1
|
|
fi
|
|
|
|
if (cd stage3/compiler ; mmake $mmake_opts $jfactor cs)
|
|
then
|
|
echo "building of stage 3 compiler successful"
|
|
else
|
|
echo "building of stage 3 compiler not successful"
|
|
exit 1
|
|
fi
|
|
|
|
exit_status=0
|
|
|
|
exec 3>&1 # save stdout in fd 3
|
|
if [ -n "$outfile" ]
|
|
then
|
|
exec > "$outfile" # redirect stdout to $outfile
|
|
fi
|
|
|
|
for dir in library compiler; do
|
|
for file in stage2/$dir/*.c; do
|
|
diff -u $file stage3/$dir/`basename $file` ||
|
|
exit_status=1
|
|
done
|
|
done
|
|
|
|
exec >&3 # restore stdout from fd 3
|
|
if [ $exit_status -ne 0 ]; then
|
|
echo "error - stage 2 and stage 3 differ!"
|
|
else
|
|
echo "stage 2 and stage 3 compare ok"
|
|
fi
|
|
|
|
echo "finishing at `date`"
|
|
exit $exit_status
|