[m-dev.] for review: mmc produce an executable using MSVC

Peter Ross petdr at cs.mu.OZ.AU
Sat Jun 17 02:39:26 AEST 2000


On Fri, Jun 16, 2000 at 10:18:12AM +1000, Fergus Henderson wrote:
> On 14-Jun-2000, Peter Ross <petdr at cs.mu.OZ.AU> wrote:
> > 
> > Changes needed to get
> >     mmc --grade hlc.gc file.m
> > producing an executable, using MSVC as the compiler.
> 
> Those changes look good, Pete.
> 
> I do see one problem with your changes:
> 
> >  
> > +case $# in
> > +	0) LINKER_FLAGS="$UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT \
> > +		$ARCH_OPTS @LINK_OPT_SEP@ $LIBDIR_OPTS $RPATH_OPT_LIST $LIBS" ;;
> > +
> > +	*) LINKER_FLAGS="$UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT \
> > +		$ARCH_OPTS $@ @LINK_OPT_SEP@ $LIBDIR_OPTS $RPATH_OPT_LIST $LIBS" ;;
> > +esac
> > +
> >  case $verbose in
> >      true)
> >  	echo "ml: using grade \`$GRADE'"
> >  	case $demangle in
> >  	    false)
> > -		echo $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT \
> > -			$ARCH_OPTS $LIBDIR_OPTS $RPATH_OPT_LIST "$@" $LIBS
> > +		echo $LINKER $LINKER_FLAGS
> >  		;;
> >  	    true)
> > -		echo $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT \
> > -			$ARCH_OPTS $LIBDIR_OPTS $RPATH_OPT_LIST "$@" $LIBS "|"
> > +		echo $LINKER $LINKER_FLAGS "|"
> >  		echo "$DEMANGLER"
> >  		;;
> >  	esac
> > @@ -660,13 +666,7 @@
> >  	exec $DEMANGLER --explain-link-errors 1>&2 < $PIPE &
> >  		# execute $CC with stdout & stderr redirected to
> >  		# go via the pipe to $DEMANGLER and then to stderr
> > -	case $# in
> > -		0) $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS \
> > -			$LIBDIR_OPTS $RPATH_OPT_LIST $LIBS >$PIPE 2>&1 ;;
> > -
> > -		*) $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS \
> > -			$LIBDIR_OPTS $RPATH_OPT_LIST "$@" $LIBS >$PIPE 2>&1 ;;
> > -	esac
> > +	$LINKER $LINKER_FLAGS >$PIPE 2>&1
> >  	linker_status=$?
> >  		# now we can remove the pipe; since is an open file, it will
> >  		# stay around until $DEMANGLER exits
> > @@ -676,11 +676,6 @@
> >  	exit $linker_status
> >  	;;
> >  false)
> > -	case $# in
> > -		0) exec $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS \
> > -			$LIBDIR_OPTS $RPATH_OPT_LIST $LIBS ;;
> > -		*) exec $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS \
> > -			$LIBDIR_OPTS $RPATH_OPT_LIST "$@" $LIBS ;;
> > -	esac
> > +	exec $LINKER $LINKER_FLAGS
> >  	;;
> 
> 
> I think that change will do the wrong thing in the case where "$@"
> includes arguments that contain spaces or other special characters.
> 

I modified it to use two new variables LINKER_PRE_FLAGS and
LINKER_POST_FLAGS.

Index: ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.77
diff -u -u -r1.77 ml.in
--- ml.in	2000/04/07 01:21:27	1.77
+++ ml.in	2000/06/16 16:34:51
@@ -610,17 +610,18 @@
     true) demangle=false ;;
 esac
 
+LINKER_PRE_FLAGS="$UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS"
+LINKER_POST_FLAGS="@LINK_OPT_SEP@ $LIBDIR_OPTS $RPATH_OPT_LIST $LIBS"
+
 case $verbose in
     true)
 	echo "ml: using grade \`$GRADE'"
 	case $demangle in
 	    false)
-		echo $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT \
-			$ARCH_OPTS $LIBDIR_OPTS $RPATH_OPT_LIST "$@" $LIBS
+		echo $LINKER $LINKER_PRE_FLAGS "$@" $LINKER_POST_FLAGS
 		;;
 	    true)
-		echo $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT \
-			$ARCH_OPTS $LIBDIR_OPTS $RPATH_OPT_LIST "$@" $LIBS "|"
+		echo $LINKER $LINKER_PRE_FLAGS "$@" $LINKER_POST_FLAGS "|"
 		echo "$DEMANGLER"
 		;;
 	esac
@@ -661,11 +662,9 @@
 		# execute $CC with stdout & stderr redirected to
 		# go via the pipe to $DEMANGLER and then to stderr
 	case $# in
-		0) $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS \
-			$LIBDIR_OPTS $RPATH_OPT_LIST $LIBS >$PIPE 2>&1 ;;
-
-		*) $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS \
-			$LIBDIR_OPTS $RPATH_OPT_LIST "$@" $LIBS >$PIPE 2>&1 ;;
+    		0) $LINKER $LINKER_PRE_FLAGS $LINKER_POST_FLAGS >$PIPE 2>&1 ;;
+    		*) $LINKER $LINKER_PRE_FLAGS "$@" $LINKER_POST_FLAGS \
+			>$PIPE 2>&1 ;;
 	esac
 	linker_status=$?
 		# now we can remove the pipe; since is an open file, it will
@@ -677,10 +676,8 @@
 	;;
 false)
 	case $# in
-		0) exec $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS \
-			$LIBDIR_OPTS $RPATH_OPT_LIST $LIBS ;;
-		*) exec $LINKER $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS \
-			$LIBDIR_OPTS $RPATH_OPT_LIST "$@" $LIBS ;;
+    		0) exec $LINKER $LINKER_PRE_FLAGS $LINKER_POST_FLAGS ;;
+    		*) exec $LINKER $LINKER_PRE_FLAGS "$@" $LINKER_POST_FLAGS ;;
 	esac
 	;;
 esac
--------------------------------------------------------------------------
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