[m-dev.] for review: lmc

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Jan 15 14:53:33 AEDT 2001


On 15-Jan-2001, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> tools/lmc:
> 	A shell script to allow you to execute a version of the Mercury
> 	compiler that you have built in a workspace. Everything that the
> 	compilation process needs will come from that workspace: the libraries
> 	for the runtime system, the trace system, the Mercury standard library,
> 	the Boehm collector, etc.
> 
> Zoltan.
> 
> #!/bin/sh
> #
> # This shell script allows you to execute a version of the Mercury compiler
> # that you have built in a workspace. Everything that the compilation process
> # needs will come from that workspace: the libraries for the runtime system,
> # the trace system, the Mercury standard library, the Boehm collector, etc.
> # You specify the directory containing the workspace by setting the value of
> # the WORKSPACE environment variable. This can be done by setting up a small
> # shell script for each workspace you have:
> #
> # #!/bin/sh
> # WORKSPACE=$HOME/mer/ws1
> # export WORKSPACE
> # $HOME/bin/scripts/lmc "$@"
> #
> # This of course assumes that your copy of this script resides in
> # $HOME/bin/scripts.

I suggest deleting that comment and replacing the line above it with

	# $WORKSPACE/tools/lmc "$@"

> # If you want to track down some low level bug, you can ask this script to
> # execute the Mercury compiler under gdb by setting the environment variable
> # MMC_UNDER_GDB to the string "true".
...
> if test "$MMC_UNDER_GDB" = true
> then
> 	echo --link-flags "-g" --cflags "-g" --cflags "-I$WORKSPACE/trace" --cflags "-I$WORKSPACE/runtime" --cflags "-I$WORKSPACE/boehm_gc" --cflags "-I$WORKSPACE/boehm_gc/include" "$@"
> 	gdb $MERCURY_COMPILER

I suggest replacing those two lines with

	MERCURY_COMPILER="$WORKSPACE/tools/gdbrun $MERCURY_COMPILER" mmc "$@"

and adding the following gdbrun script to tools:

	#!/bin/sh
	#
	# Usage: gdbrun <program> <arguments>
	# Invokes gdb on <program>, and runs the
	# program with the given <arguments>.
	#
	program="$1"
	tmpfile=/tmp/gdbrun.$$
	trap "rm -f $tmpfile" 1 2 3 13 15
	shift
	echo run "$@" > "$tmpfile"
	echo gdb --command="$tmpfile" $program
	gdb --command="$tmpfile" $program
	rm -f "$tmpfile"

This has two advantages:
	(1) you get all the extra arguments that the mmc script passes
	    to mercury_compile, e.g. the essential `-I $MERCURY_INT_DIR'.
	(2) you don't have to manually cut-and-paste the arguments to
	    the `run' command.

> else
> 	mmc --link-flags "-g" --cflags "-g" --cflags "-g" --cflags "-I$WORKSPACE/trace" --cflags "-I$WORKSPACE/runtime" --cflags "-I$WORKSPACE/boehm_gc" --cflags "-I$WORKSPACE/boehm_gc/include" "$@"
> fi

I don't think you should include `-g' by default.  lmc should behave
the same as mmc except that it uses the local workspace's copy of all
the tools.  The user can always specify `--c-debug' on the command
line to lmc if they want debugging.

Apart from that, this looks good.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list