[m-rev.] for review: fix Mmake linker flag bugs
Simon Taylor
stayl at cs.mu.OZ.AU
Thu Feb 7 01:35:48 AEDT 2002
Estimated hours taken: 1
Fix Mmake's handling of linker options.
scripts/Mmake.vars.in:
Add Mmake variables LDFLAGS, used for linker flags for
executables, and LD_LIBFLAGS, used for linker flags for
shared libraries. The separate variables are need because
on some architectures `ml' invokes the C compiler, but
`ml --make-shared-lib' invokes the linker directly.
Put `--' before CFLAGS in the construction of ALL_MGNUCFLAGS
to avoid confusion between C compiler options and mgnuc
options.
compiler/modules.m:
Pass LDFLAGS and LD_LIBFLAGS to ml.
doc/user_guide.texi:
Document CFLAGS, LDFLAGS and LD_LIBFLAGS.
scripts/parse_ml_options.sh_subr.in:
scripts/ml.in:
Define options `--print-link-command' and
`--print-shared-lib-link-command', which print
the commands ml uses to link executables and
shared libraries.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.213
diff -u -u -r1.213 modules.m
--- compiler/modules.m 30 Jan 2002 05:08:44 -0000 1.213
+++ compiler/modules.m 6 Feb 2002 05:12:59 -0000
@@ -3557,8 +3557,8 @@
"$(", MakeVarName, ".os) ",
InitObjFileName, " ", All_MLObjsString, " ",
All_MLLibsDepString, "\n",
- "\t$(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) -o ",
- ExeFileName, " ", InitObjFileName, " \\\n",
+ "\t$(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) -- $(ALL_LDFLAGS) ",
+ "-o ", ExeFileName, " ", InitObjFileName, " \\\n",
"\t $(", MakeVarName, ".os) ", All_MLObjsString,
" $(ALL_MLLIBS)\n"]
},
@@ -3583,8 +3583,8 @@
io__write_strings(DepStream, [
SplitExeFileName, " : ", SplitLibFileName, " ",
InitObjFileName, " ", All_MLLibsDepString, "\n",
- "\t$(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) -o ",
- SplitExeFileName, " ", InitObjFileName, " \\\n",
+ "\t$(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) -- $(ALL_LDFLAGS) ",
+ "-o ", SplitExeFileName, " ", InitObjFileName, " \\\n",
"\t ", SplitLibFileName, " $(ALL_MLLIBS)\n\n"
]),
@@ -3652,7 +3652,7 @@
"$(", MakeVarName, ".pic_os) ",
All_MLPicObjsString, " ", All_MLLibsDepString, "\n",
"\t$(ML) --make-shared-lib $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) ",
- "-o ", SharedLibFileName, " \\\n",
+ "-- $(ALL_LD_LIBFLAGS) -o ", SharedLibFileName, " \\\n",
"\t\t$(", MakeVarName, ".pic_os) ", All_MLPicObjsString,
" $(ALL_MLLIBS)\n\n"
]),
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.287
diff -u -u -r1.287 user_guide.texi
--- doc/user_guide.texi 30 Jan 2002 14:51:04 -0000 1.287
+++ doc/user_guide.texi 6 Feb 2002 10:12:37 -0000
@@ -633,6 +633,11 @@
@item MGNUCFLAGS and EXTRA_MGNUCFLAGS
@vindex MGNUCFLAGS
@vindex EXTRA_MGNUCFLAGS
+Options to pass to the mgnuc script.
+
+ at item CFLAGS and EXTRA_CFLAGS
+ at vindex CFLAGS
+ at vindex EXTRA_CFLAGS
Options to pass to the C compiler.
@item MS_CLFLAGS and EXTRA_MS_CLFLAGS
@@ -655,9 +660,24 @@
@item MLFLAGS and EXTRA_MLFLAGS
@vindex MLFLAGS
@vindex EXTRA_MLFLAGS
-Options to pass to the linker and the c2init program.
+Options to pass to the ml and c2init scripts.
(Note that compilation model options should be
specified in @code{GRADEFLAGS}, not in @code{MLFLAGS}.)
+
+ at item LDFLAGS and EXTRA_LDFLAGS
+ at vindex LDFLAGS
+ at vindex EXTRA_LDFLAGS
+Options to pass to the command used by the ml script to link
+executables (use @code{ml --print-link-command} to find out
+what command is used, usually the C compiler).
+
+ at item LD_LIBFLAGS and EXTRA_LD_LIBFLAGS
+ at vindex LD_LIBFLAGS
+ at vindex EXTRA_LD_LIBFLAGS
+Options to pass to the command used to by the ml script to link
+shared libraries (use @code{ml --print-shared-lib-link-command}
+to find out what command is used, usually the C compiler
+or the system linker, depending on the platform).
@item MLLIBS and EXTRA_MLLIBS
@vindex MLLIBS
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.61
diff -u -u -r1.61 Mmake.vars.in
--- scripts/Mmake.vars.in 11 Jan 2002 11:33:15 -0000 1.61
+++ scripts/Mmake.vars.in 6 Feb 2002 14:29:38 -0000
@@ -119,7 +119,7 @@
#
MGNUC = mgnuc
ALL_MGNUCFLAGS = $(MGNUCFLAGS) $(EXTRA_MGNUCFLAGS) $(TARGET_MGNUCFLAGS) \
- $(LIB_MGNUCFLAGS) $(ALL_CFLAGS)
+ $(LIB_MGNUCFLAGS) -- $(ALL_CFLAGS)
MGNUCFLAGS =
EXTRA_MGNUCFLAGS =
LIB_MGNUCFLAGS = $(patsubst %,-I %,$(EXTRA_C_INCL_DIRS))
@@ -170,8 +170,7 @@
LIB_MS_CSCFLAGS =
C2INIT = c2init
-# c2init and ml take the same arguments.
-ALL_C2INITFLAGS = $(ALL_MLFLAGS)
+ALL_C2INITFLAGS = $(C2INIT_AND_MLFLAGS)
C2INITFLAGS =
EXTRA_C2INITFLAGS =
LIB_C2INITFLAGS = $(patsubst %,--init-file-directory %,$(EXTRA_INIT_DIRS))
@@ -182,16 +181,28 @@
EXTRA_C2INITARGS =
LIB_C2INITARGS = $(patsubst %,%.init,$(ALL_EXTRA_LIBRARIES))
-ML = ml
-ALL_MLFLAGS = $(MLFLAGS) $(C2INITFLAGS) \
+# c2init and ml take the same arguments.
+C2INIT_AND_MLFLAGS = $(MLFLAGS) $(C2INITFLAGS) \
$(EXTRA_MLFLAGS) $(EXTRA_C2INITFLAGS) \
$(TARGET_MLFLAGS) $(TARGET_C2INITFLAGS) \
$(LIB_MLFLAGS) $(LIB_C2INITFLAGS)
-MLFLAGS = $(EXTRA_MLFLAGS)
+
+ML = ml
+ALL_MLFLAGS = $(C2INIT_AND_MLFLAGS)
+MLFLAGS =
EXTRA_MLFLAGS =
LIB_MLFLAGS = $(patsubst %,-R%,$(EXTRA_C_LIB_DIRS)) \
$(patsubst %,-L%,$(EXTRA_C_LIB_DIRS))
+ALL_LDFLAGS = $(LDFLAGS) $(EXTRA_LDFLAGS) $(TARGET_LDFLAGS)
+LDFLAGS =
+EXTRA_LDFLAGS =
+
+# Flags to use when linking a shared library.
+ALL_LD_LIBFLAGS = $(LD_LIBFLAGS) $(EXTRA_LD_LIBFLAGS) $(TARGET_LD_LIBFLAGS)
+LD_LIBFLAGS =
+EXTRA_LD_LIBFLAGS =
+
ALL_MLOBJS = $(MLOBJS) $(EXTRA_MLOBJS) $(TARGET_MLOBJS)
MLOBJS =
EXTRA_MLOBJS =
@@ -354,6 +365,16 @@
$(origin MLFLAGS-$(patsubst %_init.c,%,$@))))
maybe-target-MLFLAGS- = $(MLFLAGS-$(patsubst %_init.c,%,$@))
maybe-target-MLFLAGS-undefined =
+
+TARGET_LDFLAGS = \
+ $(maybe-target-LDFLAGS-$(findstring undefined,$(origin LDFLAGS-$@)))
+maybe-target-LDFLAGS- = $(LDFLAGS-$@)
+maybe-target-LDFLAGS-undefined =
+
+TARGET_LD_LIBFLAGS = \
+ $(maybe-target-LD_LIBFLAGS-$(findstring undefined,$(origin LD_LIBFLAGS-$@)))
+maybe-target-LD_LIBFLAGS- = $(LD_LIBFLAGS-$@)
+maybe-target-LD_LIBFLAGS-undefined =
TARGET_MLOBJS = \
$(maybe-target-MLOBJS-$(findstring undefined,$(origin MLOBJS-$@)))
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.93
diff -u -u -r1.93 ml.in
--- scripts/ml.in 3 Dec 2001 03:11:25 -0000 1.93
+++ scripts/ml.in 6 Feb 2002 09:54:24 -0000
@@ -311,6 +311,22 @@
;;
esac
+# if the --print-link-command option is specified,
+# then all we do is print the command used to link executables
+# and then exit.
+case "$print_link_command" in true)
+ echo $LINKER
+ exit 0
+esac
+
+# if the --print-shared-lib-command option is specified,
+# then all we do is print the command used to link executables
+# and then exit.
+case "$print_shared_lib_link_command" in true)
+ echo $LINK_SHARED_OBJ
+ exit 0
+esac
+
merc_libdir_opts="\
@LIB_LIBPATH@$LIBDIR/$GRADE/$FULLARCH
@LIB_LIBPATH@$LIBDIR/$FULLARCH
Index: scripts/parse_ml_options.sh-subr.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/parse_ml_options.sh-subr.in,v
retrieving revision 1.3
diff -u -u -r1.3 parse_ml_options.sh-subr.in
--- scripts/parse_ml_options.sh-subr.in 13 Jan 2002 10:13:13 -0000 1.3
+++ scripts/parse_ml_options.sh-subr.in 6 Feb 2002 05:11:26 -0000
@@ -43,6 +43,8 @@
use_thread_libs=false
print_grade=false
print_gc_grade=false
+print_link_command=false
+print_shared_lib_link_command=false
# initialize c2init options
maxcalls=40 # maximum number of calls to put in a single function
@@ -87,6 +89,10 @@
Compute the base name of the garbage collection library to
link with based on the command line options, print it to the
standard output, and then exit (don't actually link anything).
+ --print-link-command
+ Print the command used to link executables.
+ --print-shared-lib-link-command
+ Print the command used to link shared libraries.
Dynamic/static linking options:
--mercury-libs {shared, static, none}
@@ -346,6 +352,18 @@
;;
--no-print-gc-grade)
print_gc_grade=false
+ ;;
+ --print-link-command)
+ print_link_command=true
+ ;;
+ --no-print-link-command)
+ print_link_command=false
+ ;;
+ --print-shared-lib-link-command)
+ print_shared_lib_link_command=true
+ ;;
+ --no-print-shared-lib-link-command)
+ print_shared_lib_link_command=false
;;
#
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list