for review: configure for libc6 with Linux.

Tyson Dowd trd at cs.mu.OZ.AU
Tue Feb 10 16:39:41 AEDT 1998


Hi,

Well, I wanted to do some development at home, but Mercury wasn't
really happy with libc6. Probably Fergus should look at this.

===================================================================


Estimated hours taken: 2

Fix the boehm_gc problem with libc6 on Linux systems.
This is a Mercury only fix because the boehm_gc doesn't use autoconf.
(It's not the world's most elegant fix, but it does fix the problem).

Mmakefile:
	Remove boehm_gc/mercury_boehm_gc_conf.h when cleaning up.

README.Linux:
	Update the documentation about this fix.

configure.in:
	Check whether we should #include <asm/sigcontext.h> in
	the GC.

boehm_gc/os_dep.c:
	Only include <asm/sigcontext.h> if it will work.

boehm_gc/mercury_boehm_gc_conf.h.in:
	New configuration header file.


Index: Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/mercury/Mmakefile,v
retrieving revision 1.16
diff -u -r1.16 Mmakefile
--- Mmakefile	1998/02/06 16:04:05	1.16
+++ Mmakefile	1998/02/10 04:44:10
@@ -181,7 +181,7 @@
 	cd doc && mmake distclean
 	-rm -f errs errs2 update.log
 	-rm -f config.status config.cache config.log configure.log
-	-rm -f runtime/mercury_conf.h
+	-rm -f runtime/mercury_conf.h boehm_gc/mercury_boehm_gc_conf.h
 	-rm -f Mmake.common
 	# Package up the mercury directory and the tests directory, 
 	# but with some subdirectories excluded, into a gzipped tar
Index: README.Linux
===================================================================
RCS file: /home/staff/zs/imp/mercury/README.Linux,v
retrieving revision 1.7
diff -u -r1.7 README.Linux
--- README.Linux	1997/11/24 06:30:50	1.7
+++ README.Linux	1998/02/10 05:06:22
@@ -7,8 +7,11 @@
 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.
 
-It is possible that on some recent versions of Linux, you may get an
-error when compiling boehm_gc/os_dep.c.  If so, apply the patch below.
+There are some incompatibilities in different kernel versions and libc
+versions to do with the handling of signals. We had added some
+autoconfiguration code to try to detect which header files need to be
+included, but if you have trouble compiling boehm_gc/os_dep.c, try
+applying the patch below (and send a bug report if you can).
 Just type `patch boehm_gc/os_dep.c < README.Linux'.
 
 On Linux with ELF, shared libraries are supported.  However, ELF shared
@@ -47,18 +50,13 @@
 
 --------------------
 
---- os_dep.c	Mon Nov 24 17:01:23 1997
-+++ new/os_dep.c	Mon Nov 24 17:04:10 1997
-@@ -31,11 +31,11 @@
-       /* This used to be conditional on (LINUX_VERSION_CODE < 0x20100), */
-       /* but that is not the right test, since it is needed for at    */
-       /* least one 2.1.35 (LINUX_VERSION_CODE = 0x20103) release.     */
-       /* For the moment I'll just make it unconditional.  If you get  */
-       /* a compilation error at the line below, just comment it out.  */
--#     include <asm/sigcontext.h>
+--- os_dep.c	Tue Feb 10 15:37:42 1998
++++ new/os_dep.c	Tue Feb 10 16:04:24 1998
+@@ -38,6 +38,7 @@
+       /* 10-Feb-1998 Modified to use autoconf to handle this for      */
+       /*             Mercury -- Tyson Dowd <trd at cs.mu.oz.au>          */
+ #     ifdef MERCURY_LINUX_NEED_ASM_SIGCONTEXT
 +/*** #     include <asm/sigcontext.h> ***/
+ #        include <asm/sigcontext.h>
+ #     endif
  #   endif
- # endif
- # if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS)
- #   include <sys/types.h>
- #   if !defined(MSWIN32) && !defined(SUNOS4)
Index: configure.in
===================================================================
RCS file: /home/staff/zs/imp/mercury/configure.in,v
retrieving revision 1.120
diff -u -r1.120 configure.in
--- configure.in	1997/12/05 15:46:37	1.120
+++ configure.in	1998/02/10 04:37:40
@@ -39,7 +39,7 @@
 	exit
 fi
 #-----------------------------------------------------------------------------#
-AC_CONFIG_HEADER(runtime/mercury_conf.h)
+AC_CONFIG_HEADER(runtime/mercury_conf.h boehm_gc/mercury_boehm_gc_conf.h)
 AC_PREFIX_DEFAULT(/usr/local/mercury-`. ./VERSION; echo $VERSION`)
 AC_CANONICAL_HOST
 FULLARCH="$host"
@@ -1512,6 +1512,49 @@
 		LIBRARY_RM_C=:
 		;;
 esac
+#-----------------------------------------------------------------------------#
+# The boehm_gc system doesn't use autoconf, but for cases like this,
+# it should.
+# Linux with libc6 souldn't use asm/sigcontext.h, but some versions of the
+# kernel with libc5 need it.
+case "$host" in
+	*-*-linux|*-*-linux-gnu)
+		AC_MSG_CHECKING(whether we need asm/sigcontext.h)
+		AC_CACHE_VAL(mercury_linux_need_asm_sigcontext,
+		AC_TRY_RUN([
+			#include <asm/sigcontext.h>
+			#include <signal.h> 
+			#include <linux/version.h>
+			#if (LINUX_VERSION_CODE >= 0x20100)
+				typedef void (* REAL_SIG_PF)(int, 
+						struct sigcontext);
+			#else
+				typedef void (* REAL_SIG_PF)(int, 
+						struct sigcontext_struct);
+			#endif
+
+			main() {
+				REAL_SIG_PF handler;
+				struct sigcontext foo;
+				if (0) {
+					handler(0, foo);
+				}
+				exit(0);
+			}], [mercury_linux_need_asm_sigcontext=yes],
+			[mercury_linux_need_asm_sigcontext=no], 
+			[mercury_linux_need_asm_sigcontext=no])
+		)
+		AC_MSG_RESULT($mercury_linux_need_asm_sigcontext)
+		if test $mercury_linux_need_asm_sigcontext = "yes"; then
+			AC_DEFINE(MERCURY_LINUX_NEED_ASM_SIGCONTEXT)
+		fi
+		;;
+	*)
+		mercury_linux_use_asm_signcontext=no
+		;;
+esac
+
+#-----------------------------------------------------------------------------#
 
 AC_SUBST(LINK_SHARED_OBJ)
 AC_SUBST(EXE_RPATH_OPT)
@@ -1551,9 +1594,11 @@
 scripts/msc scripts/msl scripts/msp scripts/sicstus_conv
 scripts/mkfifo_using_mknod bindist/bindist.build_vars
 ,
-if test "$CONFIG_HEADERS" = "runtime/mercury_conf.h"; then
-	touch runtime/mercury_conf.h.date
-fi
+for header in $CONFIG_HEADERS ; do
+	if test "$header" = "runtime/mercury_conf.h"; then
+		touch runtime/mercury_conf.h.date
+	fi
+done
 # conftest.junk is used to avoid a warning if there
 # are no files in the list passed to chmod
 touch conftest.junk
Index: boehm_gc/os_dep.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/boehm_gc/os_dep.c,v
retrieving revision 1.11
diff -u -r1.11 os_dep.c
--- os_dep.c	1997/11/24 06:31:25	1.11
+++ os_dep.c	1998/02/10 05:07:25
@@ -16,6 +16,7 @@
    and the work-around for SIG_FILL on gnu-win32.  -fjh. */
 
 # include "gc_priv.h"
+# include "mercury_boehm_gc_conf.h"
 
 # if defined(LINUX) && !defined(POWERPC)
 #   include <linux/version.h>
@@ -33,7 +34,12 @@
       /* least one 2.1.35 (LINUX_VERSION_CODE = 0x20103) release.     */
       /* For the moment I'll just make it unconditional.  If you get  */
       /* a compilation error at the line below, just comment it out.  */
-#     include <asm/sigcontext.h>
+      /*  							      */
+      /* 10-Feb-1998 Modified to use autoconf to handle this for      */
+      /*             Mercury -- Tyson Dowd <trd at cs.mu.oz.au>          */
+#     ifdef MERCURY_LINUX_NEED_ASM_SIGCONTEXT
+#        include <asm/sigcontext.h>
+#     endif
 #   endif
 # endif
 # if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS)

New File: boehm_gc/mercury_boehm_gc_conf.h.in
===================================================================
/*
** Copyright (C) 1998 The University of Melbourne.
** This file may only be copied under the terms of the GNU Library General
** Public License - see the file COPYING.LIB in the Mercury distribution.
*/

/*
** mercury_boehm_conf.h.in -
**	Various configuration parameters, determined automatically by
**	the auto-configuration script.
*/

/*
** IMPORTANT NOTE:
** This file must not contain any #include statements,
** and may not define any global variables,
** for reasons explained in mercury_imp.h.
** This file should contain _only_ configuration macros.
*/

#ifndef MERCURY_BOEHM_GC_CONF_H
#define MERCURY_BOEHM_GC_CONF_H

#undef	MERCURY_LINUX_NEED_ASM_SIGCONTEXT

#endif /* MERCURY_BOEHM_GC_CONF_H */


-- 
       Tyson Dowd           # There isn't any reason why Linux can't be
                            # implemented as an enterprise computing solution.
     trd at cs.mu.oz.au        # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.



More information about the developers mailing list