Files
mercury/tools/bootcheck
Zoltan Somogyi 8a0ceb49aa This checkin has several major purposes, set out in the sections below,
Estimated hours taken: 240

This checkin has several major purposes, set out in the sections below,
all connected with the implementation of the new debugger command set.

DOCUMENT NEW DEBUG COMMAND SET

doc/user_guide.texi:
	Add a new section on the debugger. The description of the commands
	is complete, but some of the background sections, and the section
	about how to build debuggable executables, are not yet done.

	Update the documentation of the tracing options.

doc/generate_mdb_doc:
	A new shell script that automatically converts some of the new
	sections of the user guide into the online documentation of the
	debugger.

doc/mdb_categories:
	The fixed initial part of the online documentation.

doc/Mmakefile:
	Add rules for creating mdb_doc, the file that is the online
	documentation of the debugger, and for installing it together
	with mdbrc.

Mmake.common.in:
	Define INSTALL_DOC_DIR for doc/Mmakefile.

scripts/mdbrc.in:
	A debugger command script that reads in the online documentation
	and then defines some standard aliases.

configure.in:
	Define the variable that scripts/mdb.in and scripts/mdbrc.in use
	to find the right files, and get configure to perform the
	substitutions.

configure.in:
scripts/mdb:
scripts/mdb.in:
	Replace mdb with mdb.in. Mdb is now created during configuration
	from mdb.in, filling in the name of the file that contains the default
	debugger initialization commands.

util/info_to_mdb.c:
	A program that does most of the work involved in automatically
	converting user guide sections into online documentation.
	(This couldn't easily be written in sh, because sh's read
	command has no notion of pushback.)

util/Mmakefile:
	Add info_to_mdb to the list of targets.

tools/bootcheck:
	Make sure that the tests in tests/debugger are executed with an
	initialization setup that is equivalent to what users will see
	by default.

REORGANIZE TRACING OPTIONS

compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
compiler/trace.m:
	Reorganize the handling of trace levels around the new options
	--trace-internal, --trace-redo, and --trace-return.

compiler/*.m:
	Use the new ways of getting at trace levels.

tests/hard_coded/typeclasses/Mmakefile:
	s/--trace all/--trace deep/

SUPPORT RETRY

compiler/trace.m:
	After every call to MR_trace(), emit code that checks whether it
	should jump away, and if yes, performs the jump. This is used to
	implement retry. (The debugger cannot execute the jump itself
	because it is in the wrong C stack frame.)

compiler/llds.m:
compiler/continuation_info.m:
compiler/stack_layout.m:
	Modify the data structures that record information about live
	value at program points, to record the identity of each variable.
	This is necessary for the implementation of the restart command,
	since we do not want to confuse two distinct variables just because
	they have the same name. For example, a variable whose name is X
	and number is 5 is now recorded in the name array as "5:X".

	Clean up the data structure a bit, so that we don't have to store
	dummy names for values that are not variables.

compiler/*.m:
	Minor changes to conform to the data structure changes.

runtime/mercury_stack_layout.h:
	Redefine an existing macro to strip away the initial number: prefix
	from the "name" of a variable (keeping its original function on
	changed data), and add a new one to access the raw unstripped data.

runtime/mercury_init.h:
runtime/mercury_wrapper.h:
	Update the prototype of MR_trace_{fake,real}, and the type of the
	global that points to them.

runtime/mercury_layout_util.h:
	Add an extra function, MR_get_register_number, for use by retry.

USE FIXED STACK SLOTS FOR TRACE INFO

compiler/code_gen.m:
compiler/code_info.m:
compiler/live_vars.m:
compiler/trace.m:
	If execution tracing is enabled, reserve the first few stack slots
	to hold the event number of the call event, the call number, the
	call depth, the redo layout structure address (if generating redo
	events) and the from_full flag at the time of call (if we are doing
	shallow tracing). By allocating the first four of these to fixed stack
	slots, the debugger knows where to look for them without having
	to be told. It finds out the location of the fifth, if needed,
	from a new slot in the proc layout structure. (It is not possible
	to allocate all five to fixed stack slots without wasting stack space
	in some cases.)

compiler/trace.m:
	Remove from the call to MR_trace the parameters that are now in fixed
	stack slots, since MR_trace can now look them up itself.

compiler/continuation_info.m:
compiler/stack_layout.m:
	Add an extra field to the proc_layout_info. If the module is shallow
	traced, this field says which stack slot holds the saved value of
	MR_from_full. If it is not shallow traced, this field says that
	there is no such stack slot.

runtime/mercury_stack_layout.h:
	Add macros for accessing the fixed stack slots holding the event
	number of the call event, the call number, the call depth, and,
	at a redo event, the redo layout structure address.

	Support the new field in proc layouts that gives the location of the
	from-full flag (if any).

runtime/mercury_trace_base.[ch]:
trace/mercury_trace.[ch]:
	Remove the call number and call depth arguments from MR_trace
	and its avatars, since this info is now in fixed stack slots
	in every procedure that can call MR_trace. This should reduce
	the size of the executable significantly, since there are lots
	of calls to MR_trace.

runtime/mercury_init.h:
runtime/mercury_wrapper.h:
	Update the prototype of MR_trace_{fake,real}, and the type of the
	global that points to them.

START NUMBERING FRAMEVARS FROM ONE

compiler/code_info.m:
compiler/live_vars.m:
compiler/llds_out.m:
compiler/trace.m:
	Start numbering framevars from 1 internally to the compiler;
	the runtime already starts from 1. This simplifies several tasks.

ADD REDO EVENTS

compiler/trace.m:
compiler/code_gen.m:
	Before the code that executes "succeed()", emit code to push a
	a temp nondet frame whose redoip points to a label in the runtime
	that calls MR_trace for a REDO event and then fails, provided
	--trace-redo is set.

compiler/llds.m:
	Add a new code address constant, do_trace_redo_fail, which stands
	for the address in the trace system to which calls MR_trace for
	the redo event and then fails.

compiler/trace.m:
compiler/llds_out.m:
	Provided we are doing redo tracing, fill in the slot that holds
	the layout information for the REDO event.

compiler/*.m:
	Minor changes to conform to handle the new code address constant.

browser/debugger_interface.m:
	Add redo to trace_port_type.

runtime/mercury_trace_base.[ch]:
	Add a C module containing the code that calls MR_trace for REDO
	events.

ENSURE THAT INPUT ARGUMENTS ARE ALWAYS VISIBLE

compiler/trace.m:
	When generating the set of live variables at internal ports,
	the variables that are in the pre-death set of the goal into which
	we are entering may not be available. However, the variables in the
	pre-death set that are also in the resume vars set will be available,
	so now include info about them in the layout structure for the event.
	Since with tracing the non-clobbered input args are in all resume vars
	sets, this ensures that these input args will be available from all
	internal events.

compiler/code_info.m:
	Export a previously internal predicate (current_resume_point_vars)
	to make this possible.

BUG FIX: WANT RETURN LAYOUTS

compiler/globals.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/mercury_compile.m:
	Add a new pred globals__want_return_layouts, which says whether the
	compiler should generate layout structures for call returns. This pred
	centralizes the several previous copies of the test. One of those
	copies (the one in call_gen) was faulty, leading to a bug: in the
	presence of execution tracing but the absence of accurate gc,
	information about the variables that are live at the call return
	wasn't being gathered properly.

BUG FIX: #include mercury_trace_base.h

compiler/llds_out.m:
	#include mercury_trace_base.h, not mercury_trace.h, since now
	mercury_trace_base.h defines everything directly accessible from
	modules compiled with tracing.

RECAST MERCURY_TRACE_UTIL AS MERCURY_LAYOUT_UTIL

runtime/mercury_trace_util.[ch]:
runtime/mercury_layout_util.[ch]:
	Rename this module from trace_util to layout_util, since it is also
	used by the native garbage collector. Remove "trace" from the names
	of functions.

	Get rid of the global variable MR_saved_regs, and instead thread
	a pointer to this data structure through the relevant functions
	as an extra argument.

	Add a lot more documentation in the header file.

runtime/Mmakefile:
	Reflect the module rename.

runtime/*.c:
	Refer to the new module.

DELETE EASY-TO-MISUSE MACROS

runtime/mercury_stacks.h:
	Delete the based_framevar and based_detstackvar macros, since their
	continued use can lead to off-by-one errors, and the saved_framevar
	and saved_detstackvar macros, since they are no longer used.

runtime/*.c
	Update any references to any macros removed from mercury_stacks.h.

MISC RUNTIME CHANGES

runtime/mercury_trace_base.[ch]:
trace/mercury_trace*.[ch]:
	Make typedef'd names conform to the naming convention.

	Make MR_trace_call_{seqno,depth} consistently Unsigned, rather than
	sometimes Word and sometimes Unsigned.

FIX BUG: MAKE THE DEBUGGER PRINT TO STDOUT, NOT THE CURRENT STREAM

library/io.m:
	Export to C code the predicates that return the identities and types
	of stdin, stdout and stderr, as well as io__print/[34].

library/std_util.m:
	Export to C code a predicate that returns the type_info for the
	type stdutil:type_info. This type_info is required if C code
	wants to invoke make_permanent on any type_info structure,
	as the debugger does.

runtime/mercury_init.h:
	Add extern declarations for the C functions now exported from io.m.

runtime/mercury_wrapper.[ch]:
	Add new global variables to hold the addresses of these C functions.

runtime/mercury_layout_util.c:
	Use indirect calls through these global variables to print Mercury
	values, instead of lower-level code.

util/mkinit.c:
	Assign the addresses of the functions exported from io.m to the
	global variables defined in mercury_wrapper.h.

BUG FIX: STACK TRACE FUNCTIONS DEPEND ON THE LABEL TABLE

runtime/mercury_stack_trace.c:
	On entry to any of the functions exported from this module,
	ensure that the label table is loaded by calling do_init_modules.
	Without a filled-in label table, the stack trace will not be able to
	find any stack layout info.

BUG FIX: REMOVE BROWSER/*.C

configure.in:
	When removing .c files generated by the C compiler, remove those
	in the browser directory as well as the compiler, library and
	profiler directories.

IMPLEMENT NEW DEBUGGER COMMAND SET

runtime/mercury_stack_trace.[ch]:
	Factor out the code that prints the id of a procedure into a function
	of its own, so that it can also be used from the debugger, ensuring
	appearance commonality.

	Add more documentation in the header file.

trace/mercury_trace_internal.c:
	Implement the proposed command set. Command names are now words,
	and several commands now have options allowing the user to override
	the default print level or strictness of the command, or the
	invocation conditions or action of a break point. Allows control
	over command echoing and the scrolling of sequences of event reports.
	Supports aliases, command file sourcing etc. Implements the retry
	command, using the info in the fixed stack slots.

trace/mercury_trace.[ch]:
	Extend the trace controls to support the new functionalities
	required by the new debugger language, which are print levels,
	variable-strictness commands, a more flexible finish command,
	and the retry command.

	Pass the command structure to MR_trace_event_report, since
	the user can now forcibly terminate the scrolling of reports.

trace/mercury_trace_alias.[ch]:
	New module to manage aliases for the debugger.

trace/mercury_trace_help.[ch]:
	New module to interface to browser/help.m.

trace/mercury_trace_spy.[ch]:
	New module to manage break points. The test of whether an event
	matches a break point is now much more efficient than before.
	The new module also allows several breakpoints with different
	actions and different invocation conditions (e.g. all ports,
	entry port, interface ports or specific (possibly internal) port)
	to be defined on the same procedure.

trace/mercury_trace_tables.[ch]:
	New module to manage a table of the debuggable modules, in which
	each such module is linked to the list of the layouts of all the
	procedures defined in that module. This information allows the
	debugger to turn the name of a predicate/function (possibly together
	with its arity and mode number) into the procedure layout structure
	required by the spy point module. Eventually it may also be useful
	in supplying lists of identifiers for command line completion.

	Modules for which no stack layout information is available will
	not be included in the table, since do_init_modules will not
	register any labels for them in the label table.

trace/Mmakefile:
	Mention the new files.

runtime/mercury_array_macros.h:
	A new file holding macros that can be useful in more than one module.

runtime/Mmakefile:
	Mention the new file.

runtime/mercury_conf.h.in:
	Mention a new configuration macro, MR_CANNOT_USE_STRUCTURE_ASSIGNMENT,
	used by runtime/mercury_array_macros.h.

configure.in:
	Find out whether we need to define MR_CANNOT_USE_STRUCTURE_ASSIGNMENT.

ADD TRACE DEPTH HISTOGRAMS

runtime/mercury_conf_param.h:
	Document MR_TRACE_HISTOGRAM.

runtime/mercury_trace_base.[ch]:
	Define the data structures for the histogram, and print the histogram
	when a traced program exits if MR_TRACE_HISTOGRAM is set.

trace/mercury_trace.[ch]:
	If MR_TRACE_HISTOGRAM is defined, record a count of the number of
	events at each depth. This information can help us evaluate space-time
	tradeoffs.

FACTOR OUT SHELL CODE HANDLING GRADE IMPLICATIONS

scripts/final_grade_options.sh-subr:
	A new file to contain any code that implements implications between
	grade flags; currently implements the implication debug -> use trail.

scripts/mgnuc.in:
scripts/ml.in:
	Replace the code that is now in final_grade_options.sh-subr with
	an inclusion of final_grade_options.sh-subr.

configure.in:
	Handle final_grade_options.sh-subr as {init,parse}_grade_options.sh-subr
	are handled.

SIMPLIFY THE MAINTAINANCE OF CONSISTENCY BETWEEN DEBUGGER CODE AND DOCUMENTATION

doc/Mmakefile:
	Add rules for creating mdb_command_list, a C code fragment
	that can included manually in trace/mercury_trace_internal.c
	to supply the list of valid commands, and mdb_command_test.inp,
	which is a list of invalid invocations of debugger commands,
	which tests whether the help message for such invocations
	can be located as expected.

doc/generate_mdb_command_list:
doc/generate_mdb_command_test:
	Awk scripts to create mdb_command_list and mdb_command_test.inp
	respectively from mdb_doc.

tools/bootcheck:
	Copy mdb_command_test.inp from doc to tests/debugger.

tests/debugger/Mmakefile:
	Add a new test that checks whether we get an internal error, unable
	to locate the right help node, for each invalid command invocation in
	mdb_command_test.inp.

UPDATE TEST CASES

tests/debugger/Mmakefile:
	Reenable queens. Conform to the new set of options.

tests/debugger/*.inp:
tests/debugger/*.exp:
	Update the inputs and expected outputs of the debugger test cases
	to use the new command set and output formats.
1998-10-16 06:20:28 +00:00

941 lines
22 KiB
Bash
Executable File

#!/bin/sh
#---------------------------------------------------------------------------#
# Copyright (C) 1995-1998 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.
#---------------------------------------------------------------------------#
usage="\
Usage: $0 [options]
Options:
-d <dirname>, --test-dir <dirname>
Run the tests only in <dirname>.
-h, --help
Display this usage message.
-j <num-jobs>, --jobs <num-jobs>
Run using <num-jobs> different parallel processes.
-k, --keep-objs
Keep the stage 2 object files even if stage 2 is successful.
-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.
This is necessary if one wants to bootcheck a grade
that is not compatible with the standard one.
-g, --copy-boehm-gc
Copy the bohem_gc directory instead of linking it.
This is necessary if one wants to bootcheck a grade
that is not compatible with the standard one.
-p, --copy-profiler
Copy the profiler directory instead of linking it.
This is sometimes necessary for bootstrapping
changes.
-s, --sicstus
As well as running the normal bootcheck, also build a SICStus
Prolog version of the compiler and check it against the
stage 2 directory.
-t, --no-test-suite
By default, bootcheck will also run the test quite.
This option prevents that.
-T, --test-suite-only
Do not run the bootstrap check; execute the test suite only.
This option requires a previous bootstrap check to have left
a working stage 2 directory.
-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.
--keep-stage-2-sicstus
Don't rebuild the SICStus stage 2 directory from scratch after
building stage 1. Instead use the existing SICStus stage 2
directory.
--use-subdirs
Assume intermediate files are built in subdirectories.
(Same as the \`--use-subdirs' option to mmake and mmc.)
"
testdir=""
jfactor=""
keep_objs=false
mmake_opts="-k"
outfile=""
runtests=true
do_bootcheck=true
copy_runtime=false
copy_boehm_gc=false
copy_profiler=false
keep_stage_2=false
keep_stage_3=false
keep_stage_2_sicstus=false
test_sicstus=false
use_subdirs=${MMAKE_USE_SUBDIRS=no}
# If you change these, you will also need to change scripts/ml.in,
# scripts/c2init.in, Mmake.common.in, tools/binary, tools/binary_step
# and tools/linear.
RT_LIB_NAME=mer_rt
STD_LIB_NAME=mer_std
TRACE_LIB_NAME=mer_trace
BROWSER_LIB_NAME=mer_browser
while [ $# -gt 0 ]; do
case "$1" in
-d|--test-dir)
testdir="$2"; shift ;;
-d*)
testdir="` expr $1 : '-d\(.*\)' `"; ;;
-h|--help)
echo "$usage"
exit 0 ;;
-j|--jobs)
jfactor="-j$2"; shift ;;
-j*)
jfactor="-j` expr $1 : '-j\(.*\)' `" ;;
--jobs*)
jfactor="--jobs` expr $1 : '--jobs\(.*\)' `" ;;
-k|--keep-objs)
keep_objs=true ;;
-m|--mmake)
mmake_opts="$mmake_opts $2"; shift ;;
-o|--output-file)
outfile="$2"; shift ;;
-o*)
outfile="` expr $1 : '-o\(.*\)' `"; ;;
-p|--copy-profiler)
copy_profiler=true ;;
-r|--copy-runtime)
copy_runtime=true ;;
-g|--copy-boehm-gc)
copy_boehm_gc=true ;;
-s|--sicstus)
test_sicstus=true ;;
-t|--no-test-suite)
runtests=false ;;
-T|--test-suite-only)
do_bootcheck=false ;;
-2|--keep-stage-2)
keep_stage_2=true ;;
-3|--keep-stage-3)
keep_stage_3=true ;;
--keep-stage-2-sicstus)
keep_stage_2_sicstus=true ;;
--use-subdirs)
use_subdirs=yes ;;
--no-use-subdirs)
use_subdirs=no ;;
--)
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
case $use_subdirs in
yes) cs_subdir=Mercury/cs/
;;
no) cs_subdir=
;;
esac
MMAKE_USE_SUBDIRS=$use_subdirs
export MMAKE_USE_SUBDIRS
# Turn off the debugger, since accidentally leaving it on will result
# in user interaction every time we any any version of the compiler
# that wwas compiled with tracing. This has happened to me accidentally
# one too many times - zs.
if echo $MERCURY_OPTIONS | grep '\-Di' > /dev/null
then
MERCURY_OPTIONS=`echo $MERCURY_OPTIONS | sed -e 's/-Di//'`
export MERCURY_OPTIONS
fi
echo "starting at `date`"
set -x
root=`/bin/pwd | sed '
s:/mount/munkora/mercury:/home/mercury:
s:/mount/munkora/home/mercury:/home/mercury:
s:/mount/munkora/clp/mercury:/home/mercury:'`
PATH=$root/tools:$PATH
export PATH
# Try the command given by the environment variable RMSTAGECMD to delete
# stage directories. Since this command may not always work due to
# security considerations (.rhost files), we execute /bin/rm -fr afterwards
# in any case.
if test "$RMSTAGECMD" = ""
then
RMSTAGECMD="/bin/rm -fr"
fi
if $test_sicstus
then
echo "Building SICStus stage 1..." 1>&2
if
cd $root/library &&
mmake $mmake_opts $jfactor sicstus &&
cd $root/compiler &&
mmake $mmake_opts $jfactor sicstus &&
cd $root
then
echo "building of SICStus stage 1 successful"
else
echo "building of SICStus stage 1 not successful"
exit 1
fi
MERCURY_COMPILER=$root/compiler/mercury_compile.sicstus
export MERCURY_COMPILER
MERCURY_INT_DIR=$root/stage2_sicstus/library
export MERCURY_INT_DIR
[ -d stage2_sicstus ] || mkdir stage2_sicstus
if $keep_stage_2_sicstus
then
echo keeping existing stage2_sicstus
else
# We try to do the removal of the stage 2 directory in parallel
# since recursive rm's across NFS can be quite slow ...
$RMSTAGECMD $root/stage2_sicstus/compiler < /dev/null &
$RMSTAGECMD $root/stage2_sicstus/library < /dev/null &
wait
$RMSTAGECMD $root/stage2_sicstus/* < /dev/null
/bin/rm -fr $root/stage2_sicstus/* < /dev/null
/bin/rm -fr $root/stage2_sicstus/.[a-zA-Z]* < /dev/null
fi
set +x
echo linking SICStus stage 2... 1>&2
cd stage2_sicstus
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_sicstus
mkdir library
cd library
ln -s $root/library/library.nu.nl.in .
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/$STD_LIB_NAME.init .
cd $root/stage2_sicstus
mkdir browser
cd browser
ln -s $root/browser/*.m .
cp $root/browser/Mmake* .
ln -s $root/browser/$BROWSER_LIB_NAME.init .
cd $root/stage2_sicstus
if "$copy_runtime"
then
# Remove symbolic link to the stage 1 runtime if it's present,
# which it can be with the -2 option.
rm runtime
mkdir runtime
cd runtime
ln -s $root/runtime/*.h .
ln -s $root/runtime/*.c .
ln -s $root/runtime/*.in .
cp $root/runtime/Mmake* .
ln -s $root/runtime/machdeps .
cd $root/stage2_sicstus
rm trace
mkdir trace
cd trace
ln -s $root/trace/*.h .
ln -s $root/trace/*.c .
cp $root/trace/Mmake* .
cd $root/stage2_sicstus
else
ln -s $root/runtime .
ln -s $root/trace .
fi
if "$copy_boehm_gc"
then
# Remove symbolic link to the stage 1 boehm_gc if it's present,
# which it can be with the -2 option.
rm boehm_gc
mkdir boehm_gc
cd boehm_gc
ln -s $root/boehm_gc/*.h .
ln -s $root/boehm_gc/*.c .
ln -s $root/boehm_gc/*.s .
ln -s $root/boehm_gc/includes .
cp $root/boehm_gc/Mmake* .
cp $root/boehm_gc/Makefile .
cd $root/stage2_sicstus
else
ln -s $root/boehm_gc .
fi
ln -s $root/doc .
ln -s $root/scripts .
ln -s $root/util .
if "$copy_profiler"
then
mkdir profiler
cd profiler
ln -s $root/profiler/*.m .
cp $root/profiler/Mmake* .
cd $root/stage2_sicstus
else
ln -s $root/profiler .
fi
ln -s $root/conf* .
ln -s $root/VERSION .
ln -s $root/.README.in .
ln -s $root/.INSTALL.in .
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_sicstus &&
mmake $mmake_opts depend_library depend_browser \
depend_compiler depend_profiler &&
cd $root
then
echo "building of SICStus stage 2 dependencies successful"
else
echo "building of SICStus stage 2 dependencies not successful"
exit 1
fi
MMAKE_VPATH=.
export MMAKE_VPATH
MMAKE_DIR=$root/scripts
export MMAKE_DIR
if
cd stage2_sicstus/library &&
mmake $mmake_opts $jfactor all-ints &&
mmake $mmake_opts $jfactor cs
then
echo "building of SICStus stage 2 library successful"
else
echo "building of SICStus stage 2 library not successful"
exit 1
fi
cd $root
if
cd stage2_sicstus/browser &&
mmake $mmake_opts $jfactor cs
then
echo "building of SICStus stage 2 browser successful"
else
echo "building of SICStus stage 2 browser not successful"
exit 1
fi
cd $root
if
cd stage2_sicstus/compiler &&
mmake $mmake_opts $jfactor cs
then
echo "building of SICStus stage 2 compiler successful"
else
echo "building of SICStus stage 2 compiler not successful"
exit 1
fi
cd $root
sicstus_diff_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 browser compiler; do
for file in stage2/$dir/${cs_subdir}*.c; do
diff -u $file \
stage2_sicstus/${cs_subdir}$dir/`basename $file` ||
sicstus_diff_status=1
done
done
exec >&3 # restore stdout from fd 3
if [ $sicstus_diff_status -ne 0 ]; then
echo "error - SICStus stage 2 and Mercury stage 2 differ!"
exit 1
else
echo "SICStus stage 2 and Mercury stage 2 compare ok"
echo "removing SICStus stage 2..."
# We try to do the removal of the SICStus stage 2 directory
# in parallel since recursive rm's across NFS can be quite
# slow ...
$RMSTAGECMD $root/stage2_sicstus/compiler < /dev/null &
$RMSTAGECMD $root/stage2_sicstus/library < /dev/null &
wait
$RMSTAGECMD $root/stage2_sicstus/* < /dev/null
/bin/rm -fr $root/stage2_sicstus/* < /dev/null
/bin/rm -fr $root/stage2_sicstus/.[a-zA-Z]* < /dev/null
exit 0
fi
fi
if $do_bootcheck
then
if mmake $mmake_opts MMAKEFLAGS=$jfactor all
then
echo "building of stage 1 successful"
else
cd $root/library;
mmake depend
cd $root/browser;
mmake depend
cd $root/compiler;
mmake depend
cd $root/profiler;
mmake depend
cd $root
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
fi
# this is only for a transition period,
# until all stage1 dirs have been removed
/bin/rm -fr stage1
MERCURY_COMPILER=$root/compiler/mercury_compile
export MERCURY_COMPILER
MERCURY_INT_DIR=$root/stage2/library
export MERCURY_INT_DIR
[ -d stage2 ] || mkdir stage2
if $keep_stage_2
then
echo keeping existing stage2
else
# We try to do the removal of the stage 2 directory in parallel
# since recursive rm's across NFS can be quite slow ...
$RMSTAGECMD $root/stage2/compiler < /dev/null &
$RMSTAGECMD $root/stage2/library < /dev/null &
wait
$RMSTAGECMD $root/stage2/* < /dev/null
/bin/rm -fr $root/stage2/* < /dev/null
/bin/rm -fr $root/stage2/.[a-zA-Z]* < /dev/null
fi
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/library.nu.nl.in .
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/$STD_LIB_NAME.init .
cd $root/stage2
mkdir browser
cd browser
ln -s $root/browser/*.m .
cp $root/browser/Mmake* .
ln -s $root/browser/$BROWSER_LIB_NAME.init .
cd $root/stage2
if "$copy_runtime"
then
# Remove symbolic link to the stage 1 runtime if it's present,
# which it can be with the -2 option.
rm runtime
mkdir runtime
cd runtime
ln -s $root/runtime/*.h .
ln -s $root/runtime/*.c .
ln -s $root/runtime/*.in .
cp $root/runtime/Mmake* .
ln -s $root/runtime/machdeps .
cd $root/stage2
rm trace
mkdir trace
cd trace
ln -s $root/trace/*.h .
ln -s $root/trace/*.c .
cp $root/trace/Mmake* .
cd $root/stage2
else
ln -s $root/runtime .
ln -s $root/trace .
fi
if "$copy_boehm_gc"
then
mkdir boehm_gc
cd boehm_gc
ln -s $root/boehm_gc/*.h .
ln -s $root/boehm_gc/*.c .
ln -s $root/boehm_gc/*.s .
ln -s $root/boehm_gc/includes .
cp $root/boehm_gc/Mmake* .
cp $root/boehm_gc/Makefile .
ln -s $root/boehm_gc/machdeps .
cd $root/stage2
else
ln -s $root/boehm_gc .
fi
ln -s $root/doc .
ln -s $root/scripts .
ln -s $root/util .
if "$copy_profiler"
then
mkdir profiler
cd profiler
ln -s $root/profiler/*.m .
cp $root/profiler/Mmake* .
cd $root/stage2
else
ln -s $root/profiler .
fi
ln -s $root/conf* .
ln -s $root/VERSION .
ln -s $root/.README.in .
ln -s $root/.INSTALL.in .
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_browser \
depend_compiler depend_profiler)
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=: mercury)
then
echo "building of stage 2 library successful"
else
echo "building of stage 2 library not successful"
exit 1
fi
if (cd stage2/browser && mmake $mmake_opts $jfactor RM_C=: library)
then
echo "building of stage 2 browser successful"
else
echo "building of stage 2 browser not successful"
exit 1
fi
if (cd stage2 && mmake $mmake_opts $jfactor trace)
then
echo "building of stage 2 trace successful"
else
echo "building of stage 2 trace 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 MMAKEFLAGS=$jfactor all)
then
echo "building of stage 2 successful"
else
echo "building of stage 2 not successful"
exit 1
fi
# We can remove the library object files now,
# but we will keep the compiler objects for a while longer
if $keep_objs
then
true
else
/bin/rm -f $root/stage2/library/[a-l]*.o < /dev/null
/bin/rm -f $root/stage2/library/[m-z]*.o < /dev/null
fi
MERCURY_COMPILER=$root/stage2/compiler/mercury_compile
export MERCURY_COMPILER
MERCURY_INT_DIR=$root/stage3/library
export MERCURY_INT_DIR
[ -d stage3 ] || mkdir stage3
if $keep_stage_3
then
echo keeping existing stage3
else
# We try to do the removal of the stage 3 directory in parallel
# since recursive rm's across NFS can be quite slow ...
$RMSTAGECMD $root/stage3/compiler < /dev/null &
$RMSTAGECMD $root/stage3/library < /dev/null &
wait
$RMSTAGECMD $root/stage3/* < /dev/null
/bin/rm -fr $root/stage3/* < /dev/null
/bin/rm -fr $root/stage3/.[a-zA-Z]* < /dev/null
fi
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/library.nu.nl.in .
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/$STD_LIB_NAME.init .
cd $root/stage3
mkdir browser
cd browser
ln -s $root/browser/*.m .
cp $root/browser/Mmake* .
ln -s $root/browser/$BROWSER_LIB_NAME.init .
cd $root/stage3
ln -s $root/boehm_gc .
ln -s $root/doc .
ln -s $root/runtime .
ln -s $root/trace .
ln -s $root/scripts .
ln -s $root/util .
ln -s $root/profiler .
ln -s $root/conf* .
ln -s $root/VERSION .
ln -s $root/.README.in .
ln -s $root/.INSTALL.in .
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_browser 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 all-ints &&
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
# We delay deleting the stage 2 compiler objects until now,
# so that if (a) an error manifests itself during the creation
# of the stage 3 library, and (b) this error can be fixed by
# changing the runtime, a bootcheck -2, which requires a relink,
# will not have to expensively recreate the stage 2 compiler objects.
if $keep_objs
then
true
else
/bin/rm -f $root/stage2/compiler/[a-l]*.o < /dev/null
/bin/rm -f $root/stage2/compiler/[i-s]*.o < /dev/null
/bin/rm -f $root/stage2/compiler/[t-z]*.o < /dev/null
fi
if (cd stage3/browser && mmake $mmake_opts $jfactor cs)
then
echo "building of stage 3 browser successful"
else
echo "building of stage 3 browser 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
diff_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 browser compiler; do
for file in stage2/$dir/${cs_subdir}*.c; do
diff -u $file stage3/$dir/${cs_subdir}`basename $file` ||
diff_status=1
done
done
exec >&3 # restore stdout from fd 3
if [ $diff_status -ne 0 ]; then
echo "error - stage 2 and stage 3 differ!"
else
echo "stage 2 and stage 3 compare ok"
echo "removing stage 3..."
# We try to do the removal of the stage 3 directory in parallel
# since recursive rm's across NFS can be quite slow ...
$RMSTAGECMD $root/stage3/compiler < /dev/null &
$RMSTAGECMD $root/stage3/library < /dev/null &
wait
$RMSTAGECMD $root/stage3/* < /dev/null
/bin/rm -fr $root/stage3/* < /dev/null
/bin/rm -fr $root/stage3/.[a-zA-Z]* < /dev/null
fi
echo "finishing stage3 at `date`"
else
diff_status=0
echo "building of stages 1 and 2 skipped"
fi
if $runtests
then
# Use everything from stage 2, unless we copied the runtime.
# In that case, the grades of stage 1 & 2 may be different,
# which means we have a choice between
#
# (a) using the stage 2 runtime and library, and the stage 2 flags, or
# (b) using the stage 1 runtime and library, and the default flags
#
# Some tests/ directories have several dozen executables. Compiling
# all these with debugging on yields far too many large (14 Mb +)
# executables. Since stage 2 is much more likely to have flags
# that turn on debugging, we prefer alternative (b).
MERCURY_COMPILER=$root/stage2/compiler/mercury_compile
export MERCURY_COMPILER
if $copy_runtime
then
MERCURY_INT_DIR=$root/library
export MERCURY_INT_DIR
MERCURY_LIBS="
$root/trace/lib$TRACE_LIB_NAME.a
$root/browser/lib$BROWSER_LIB_NAME.a
$root/library/lib$STD_LIB_NAME.a
$root/runtime/lib$RT_LIB_NAME.a
$root/boehm_gc/libgc.a
-lm"
export MERCURY_LIBS
MERCURY_ALL_C_INCL_DIRS="-I$root/trace
-I$root/runtime
-I$root/boehm_gc
-I$root/boehm_gc/include"
export MERCURY_ALL_C_INCL_DIRS
MMAKE_DIR="$root/scripts"
export MMAKE_DIR
MERCURY_MOD_LIB_MODS="
$root/browser/$BROWSER_LIB_NAME.init
$root/library/$STD_LIB_NAME.init
$root/runtime/$RT_LIB_NAME.init"
export MERCURY_MOD_LIB_MODS
# for mkinit, mmc, mgnuc, ml etc
PATH=$root/util:$root/scripts:$PATH
export PATH
else
MERCURY_INT_DIR=$root/stage2/library
export MERCURY_INT_DIR
MERCURY_LIBS="
$root/stage2/trace/lib$TRACE_LIB_NAME.a
$root/stage2/browser/lib$BROWSER_LIB_NAME.a
$root/stage2/library/lib$STD_LIB_NAME.a
$root/stage2/runtime/lib$RT_LIB_NAME.a
$root/stage2/boehm_gc/libgc.a
-lm"
export MERCURY_LIBS
MERCURY_ALL_C_INCL_DIRS="-I$root/stage2/trace
-I$root/stage2/runtime
-I$root/stage2/boehm_gc
-I$root/stage2/boehm_gc/include"
export MERCURY_ALL_C_INCL_DIRS
MMAKE_DIR="$root/stage2/scripts"
export MMAKE_DIR
MERCURY_MOD_LIB_MODS="
$root/stage2/browser/$BROWSER_LIB_NAME.init
$root/stage2/library/$STD_LIB_NAME.init
$root/stage2/runtime/$RT_LIB_NAME.init"
export MERCURY_MOD_LIB_MODS
# for mkinit, mmc, mgnuc, ml etc
PATH=$root/stage2/util:$root/stage2/scripts:$PATH
export PATH
fi
# We need to give tests/debugger access to the mdbrc and mdb_doc
# files in the doc and scripts directories, without hardcoding their
# pathnames. We must also compensate for scripts/mdbrc having hardcoded
# within it the *installed* pathname of mdb_doc and not its current
# pathname.
cat $root/doc/mdb_doc > $root/scripts/test_mdbrc
sed -e '/^source/d' $root/scripts/mdbrc >> $root/scripts/test_mdbrc
MERCURY_DEBUGGER_INIT=$root/scripts/test_mdbrc
export MERCURY_DEBUGGER_INIT
if test -d ../tests
then
cp $root/doc/mdb_command_test.inp ../tests/debugger
if test "$testdir" = ""
then
cd ../tests
./runtests $jfactor
else
cd ../tests/$testdir
./runtests $jfactor
fi
test_status=$?
cd $root
elif test -d tests
then
cp $root/doc/mdb_command_test.inp tests/debugger
if test "$testdir" = ""
then
cd tests
./runtests $jfactor
else
cd tests/$testdir
./runtests $jfactor
fi
test_status=$?
cd $root
else
echo "cannot find test directory"
test_status=1
fi
else
test_status=0
fi
echo "finishing at `date`"
if test "$diff_status" = 0 -a "$test_status" = 0
then
exit 0
else
exit 1
fi