[m-dev.] diff: fix portability problem with `-lm'
Fergus Henderson
fjh at cs.mu.OZ.AU
Sun Sep 24 19:51:37 AEDT 2000
On 24-Sep-2000, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> On 23-Sep-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > On 22-Sep-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > > Estimated hours taken: 1
> > >
> > > Fix a portability problem: we were assuming that `-lm' would work, but
> > > on some systems, e.g. MacOS X (Darwin), it doesn't.
> >
> > In my haste to get down to the pub on Friday night,
> > I committed that one a little too hastily...
> >
> > configure.in:
> > Fix a bug in my previous fix for the `-lm' portability problem.
> > I was using the wrong syntax for variable references (Make syntax
> > rather than sh syntax).
>
> Unfortunately this is wrong too.
>
> SHARED_LIBS is used in Mmake.common and scripts/ml
>
> So it has to work both in sh and make.
Ah, ouch.
> This is one solution, but I don't like it very much.
>
> Index: configure.in
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/configure.in,v
> retrieving revision 1.227
> diff -u -r1.227 configure.in
> --- configure.in 2000/09/23 12:59:10 1.227
> +++ configure.in 2000/09/24 07:13:22
> @@ -2018,7 +2018,8 @@
> # see Mmake.common.in for documentation on the meaning of these variables
> LINK_SHARED_OBJ="$CC -shared"
> LINK_SHARED_OBJ_SH="$CC -shared"
> -SHARED_LIBS='`gcc -print-libgcc-file-name` $MATH_LIB -lc'
> +SHARED_LIBS='`gcc -print-libgcc-file-name` $(MATH_LIB) -lc'
> +SHARED_LIBS_SH='`gcc -print-libgcc-file-name` $MATH_LIB -lc'
> EXE_RPATH_OPT="-Wl,-rpath,"
> EXE_RPATH_SEP=" -Wl,-rpath,"
> SHLIB_RPATH_OPT="-Wl,-rpath,"
...
> Index: scripts/ml.in
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
> retrieving revision 1.84
> diff -u -r1.84 ml.in
> --- scripts/ml.in 2000/09/22 08:27:30 1.84
> +++ scripts/ml.in 2000/09/24 07:13:36
> @@ -31,7 +31,7 @@
> LINK_SHARED_OBJ=${MERCURY_LINK_SHARED_OBJ="@LINK_SHARED_OBJ_SH@"}
> SHLIB_RPATH_OPT=${MERCURY_SHLIB_RPATH_OPT="@SHLIB_RPATH_OPT@"}
> SHLIB_RPATH_SEP=${MERCURY_SHLIB_RPATH_SEP="@SHLIB_RPATH_SEP@"}
> -SHARED_LIBS=${MERCURY_SHARED_LIBS="@SHARED_LIBS@"}
> +SHARED_LIBS=${MERCURY_SHARED_LIBS="@SHARED_LIBS_SH@"}
> TMPDIR=${TMPDIR=/tmp}
> MATH_LIB=${MERCURY_MATH_LIB="@MATH_LIB@"}
That one still doesn't quite work, I think, because @SHARED_LIBS_SH@
will contain a reference to $MATH_LIB, but it gets expanded before
MATH_LIB has been set. Another problem is that we need to pass on
SHARED_LIB_SH in bindist/bindist.build_vars.in.
However, I think both of those problems are easily fixed.
For the first one, we just need to swap the order of those variable settings.
Another solution -- which I started working on before I saw your email --
would be to change configure.in so that MATH_LIB gets expanded at configure
time rather than when ml/mmake is invoked. But I prefer your solution.
I'll go ahead and commit your solution, modified by the two fixes noted
above, and together with a fix to the other problem that you mentioned
in your other mail.
----------
Estimated hours taken: 0.75 (about half of it by Tyson)
configure.in:
Fix two bugs in my previous fix for the `-lm' portability problem:
- AC_CHECK_LIB should have been AC_HAVE_LIBRARY
- SHARED_LIB needed to be valid as *both* Make and sh syntax.
To fix this one, we've added a new variable SHARED_LIB_SH
which has the sh-syntax version of it, while SHARED_LIB now
has the Make-syntax version of it.
scripts/ml.in:
Use SHARED_LIB_SH rather than SHARED_LIB.
bindist/bindist.build_vars.in:
Pass on the value of SHARED_LIB_SH.
Workspace: /home/pgrad/fjh/ws/hg
Index: bindist/bindist.build_vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/bindist.build_vars.in,v
retrieving revision 1.15
diff -u -d -r1.15 bindist.build_vars.in
--- bindist/bindist.build_vars.in 2000/09/22 08:23:40 1.15
+++ bindist/bindist.build_vars.in 2000/09/24 08:45:35
@@ -31,6 +31,7 @@
EXT_FOR_SHARED_LIB="@EXT_FOR_SHARED_LIB@"
CFLAGS_FOR_PIC="@CFLAGS_FOR_PIC@"
SHARED_LIBS='@SHARED_LIBS@'
+SHARED_LIBS_SH='@SHARED_LIBS_SH@'
HAVE_DELAY_SLOT="@HAVE_DELAY_SLOT@"
DEFAULT_RM_C="@DEFAULT_RM_C@"
ERROR_UNDEFINED="@ERROR_UNDEFINED@"
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.227
diff -u -d -r1.227 configure.in
--- configure.in 2000/09/23 12:59:10 1.227
+++ configure.in 2000/09/24 08:43:29
@@ -224,7 +224,7 @@
AC_RETSIGTYPE
#-----------------------------------------------------------------------------#
# Check for `-lm': some systems, e.g. MacOS X (Darwin), don't have it.
-AC_CHECK_LIB(m,[MATH_LIB=-lm],[MATH_LIB=])
+AC_HAVE_LIBRARY(m,[MATH_LIB=-lm],[MATH_LIB=])
AC_SUBST(MATH_LIB)
#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(for use of a Microsoft compiler)
@@ -2018,7 +2018,8 @@
# see Mmake.common.in for documentation on the meaning of these variables
LINK_SHARED_OBJ="$CC -shared"
LINK_SHARED_OBJ_SH="$CC -shared"
-SHARED_LIBS='`gcc -print-libgcc-file-name` $MATH_LIB -lc'
+SHARED_LIBS='`gcc -print-libgcc-file-name` $(MATH_LIB) -lc'
+SHARED_LIBS_SH='`gcc -print-libgcc-file-name` $MATH_LIB -lc'
EXE_RPATH_OPT="-Wl,-rpath,"
EXE_RPATH_SEP=" -Wl,-rpath,"
SHLIB_RPATH_OPT="-Wl,-rpath,"
@@ -2055,7 +2056,8 @@
;;
sparc-sun-solaris2.*)
AC_MSG_RESULT(yes)
- SHARED_LIBS="$MATH_LIB -lc" # don't link in libgcc.a
+ SHARED_LIBS="$(MATH_LIB) -lc" # don't link in libgcc.a
+ SHARED_LIBS_SH="$MATH_LIB -lc" # don't link in libgcc.a
LINK_SHARED_OBJ="$CC -G"
LINK_SHARED_OBJ_SH="$CC -G"
ERROR_UNDEFINED="-Wl,-z,defs"
@@ -2209,6 +2211,7 @@
AC_SUBST(EXT_FOR_EXE)
AC_SUBST(USE_DLLS)
AC_SUBST(SHARED_LIBS)
+AC_SUBST(SHARED_LIBS_SH)
AC_SUBST(DEFAULT_RM_C)
AC_SUBST(LIBRARY_RM_C)
if test $USE_DLLS = "yes"; then
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.84
diff -u -d -r1.84 ml.in
--- scripts/ml.in 2000/09/22 08:27:30 1.84
+++ scripts/ml.in 2000/09/24 08:45:16
@@ -31,9 +31,11 @@
LINK_SHARED_OBJ=${MERCURY_LINK_SHARED_OBJ="@LINK_SHARED_OBJ_SH@"}
SHLIB_RPATH_OPT=${MERCURY_SHLIB_RPATH_OPT="@SHLIB_RPATH_OPT@"}
SHLIB_RPATH_SEP=${MERCURY_SHLIB_RPATH_SEP="@SHLIB_RPATH_SEP@"}
-SHARED_LIBS=${MERCURY_SHARED_LIBS="@SHARED_LIBS@"}
TMPDIR=${TMPDIR=/tmp}
MATH_LIB=${MERCURY_MATH_LIB="@MATH_LIB@"}
+# Note: the setting of SHARED_LIBS needs to come after the setting of MATH_LIB,
+# since @SHARED_LIBS_SH@ may refer to $MATH_LIB.
+SHARED_LIBS=${MERCURY_SHARED_LIBS="@SHARED_LIBS_SH@"}
# When compiling in the hlc.gc grade using the Microsoft Visual C
# compiler, the default maximum stack size of 4Mb is too low for a
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- 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