[m-rev.] for review: use shared libs by default on Linux/x86

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Jan 15 14:30:43 AEDT 2008

Estimated hours taken: 1
Branches: main

Make Mercury use shared libraries by default on Linux/x86.

Document that Mercury no longer supports a.out format executables on Linux.
(It's unlikely that the current version of Mercury would work on any Linux system
that uses them anyway.)

 	Make shared libraries the default on Linux/x86.

 	This file also covers the Linux/x86_64 port as well.

 	Mention that a.out format executables are not supported on Linux.

 	Delete most of the remainder of this file since it refers to things
 	that are either out-of-date or covered in the user's guide anyway.

 	Don't use static libraries on Linux/x86 by default.

 	Update some comments.

 	Announce this change.


Index: NEWS
RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
retrieving revision 1.483
diff -u -r1.483 NEWS
--- NEWS	23 Nov 2007 07:34:44 -0000	1.483
+++ NEWS	15 Jan 2008 03:20:20 -0000
@@ -207,6 +207,8 @@

  Changes to the Mercury compiler:

+* Shared libraries are now used by default on Linux/x86 systems.
  * Support for the reserve tag grades has been removed.

  * We have added an Erlang back-end.
Index: README.Linux
RCS file: /home/mercury/mercury1/repository/mercury/README.Linux,v
retrieving revision 1.15
diff -u -r1.15 README.Linux
--- README.Linux	23 Jan 2003 00:24:02 -0000	1.15
+++ README.Linux	15 Jan 2008 03:03:06 -0000
@@ -1,46 +1,8 @@
-This file documents just the Linux/x86 port. 
-For the Linux/PowerPC port, see README.Linux-PPC. 
-For the Linux/Alpha port, see README.Linux-Alpha. 
+This file documents the Linux/x86 and Linux/x86_64 ports.
+For the Linux/PowerPC port, see README.Linux-PPC.
+For the Linux/Apha port, see README.Linux-Alpha.
  (Ports to Linux on other architectures have not yet
  been attempted, but should not be difficult.)

-On Linux with a.out, shared libraries are not supported.
-If you still have an old a.out system, the auto-configuration might
-wrongly assume your Linux system uses ELF; if that happens, you will you
-have to manually edit the EXT_FOR_SHARED_LIB variable in Mmake.common.
-On Linux with ELF, shared libraries are supported.  However, ELF shared
-libraries require position-independent code, and (partly due to
-limitations in our current compilation technology, but partly due to
-limitations in the x86 architecture) this is quite costly for Mercury --
-probably considerably more costly than it is for C.
-Nevertheless, since shared libraries reduces disk usage, improve link
-times, and allow run-time sharing of the Mercury libraries between
-different applications, using them is a good idea.
-Currently the default is that programs do *not* use the Mercury shared
-libraries.  (Probably it ought to be the other way around, but that
-happened to be a little bit harder to implement.  We may change this in
-a future release.)
-To use the shared libraries, you must compile your program with
-`mmc --pic-reg' and link with `ml --shared' or add 
-`MGNUCFLAGS=--pic-reg' and `MLFLAGS=--shared' to your Mmake file.
-If you are using `mmc --make' you can set the MERCURY_LINKAGE Mmake
-variable to "shared" in the Mercury.options file or the environment,
-or use `mmc --make --linkage shared'.
-Mercury code compiled with `--pic-reg' or with gcc's `-fpic' option has
-what we shall call "PIC linkage", whereas Mercury code compiled without
-these options has "non-PIC linkage".  The static version of the Mercury
-libraries has non-PIC linkage, while the shared version has PIC linkage.
-Be careful that you do not try to link Mercury code with PIC linkage and
-Mercury code with non-PIC linkage into the same executable, otherwise you
-will probably get an obscure link error about `MR_grade_...' undefined
-or `MR_runtime_grade' multiply defined.
-(The reason for this is that standard non-PIC Mercury code uses the
-`ebx' register in ways that are incompatible with its uses as the global
-offset table pointer register in PIC code.  If only the Intel
-architecture wasn't so register-starved, we wouldn't need to use `ebx',
-and then PIC and non-PIC code could be mixed without any problems.)
+Linux systems that produce executables in a.out format are not supported by
+the Mercury compiler.
Index: configure.in
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.511
diff -u -r1.511 configure.in
--- configure.in	18 Dec 2007 22:35:35 -0000	1.511
+++ configure.in	15 Jan 2008 00:54:32 -0000
@@ -3548,17 +3548,6 @@
-		# Shared libraries are not the default on x86 systems that
-		# use ELF -- see README.Linux
-		# They are the default on x86_64 systems that use ELF.
-		case "$host" in
-			i*86-*-linux|i*86-*-linux-gnu)
-				;;
-			*)
-				;;
-		esac


Index: scripts/ml.in
RCS file: /home/mercury/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.121
diff -u -r1.121 ml.in
--- scripts/ml.in	8 Nov 2007 06:13:23 -0000	1.121
+++ scripts/ml.in	15 Jan 2008 03:18:52 -0000
@@ -146,9 +146,9 @@
  		case $FULLARCH in
-			i*86-*-linux*|i*86-*-freebsd*|i*86-*-cygwin*|i*86-*-solaris*)
-				# shared libraries are not the default on x86
-				#systems that use ELF -- see README.Linux
+			i*86-*-freebsd*|i*86-*-cygwin*|i*86-*-solaris*)
+				# Shared libraries are not the default on the above systems.
+				# See configure.in for details.
  				case $make_shared_lib in
@@ -164,9 +164,9 @@
  		case $FULLARCH in
-			i*86-*-linux*|i*86-*-freebsd*|i*86-*-cygwin*)
-				# Shared libraries are not the default on Linux
-				# -- see README.Linux. Likewise for FreeBSD and Cygwin.
+			i*86-*-freebsd*|i*86-*-cygwin*)
+				# Shared libraries are not the default on the above systems.
+				# See configure.in for details.
  				# We don't do this for Solaris/x86 because -ldl is
  				# only available for dynamically linked executables

mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au

More information about the reviews mailing list