diff: boehm_gc/os_dep.c fix for hydra

Fergus Henderson fjh at cs.mu.oz.au
Mon Nov 24 17:23:22 AEDT 1997


Hi,

If anyone has a recent version of Linux (more recent that the one on hydra),
it would be helpful if they could test this change.

boehm_gc/os_dep.c:
	Fix a problem with the #ifdefs so that it works on hydra.

README.Linux:
	Update to reflect recent developments.

README.Linux-PPC:
	New file to document the Linux/PowerPC port.

Index: README.Linux
===================================================================
RCS file: /home/mercury1/repository/mercury/README.Linux,v
retrieving revision 1.6
diff -u -u -r1.6 README.Linux
--- README.Linux	1997/10/15 10:08:13	1.6
+++ README.Linux	1997/11/24 06:18:42
@@ -1,14 +1,15 @@
-Mercury has only been ported to Linux/x86, not to Linux/Alpha
-Linux/PowerPC, Linux/m68k, etc.  Those other ports should
-not be difficult, but this file documents just the Linux/x86 port.
+This file documents just the Linux/x86 port.  For the Linux/PowerPC
+port, see README.Linux-PPC.  (Ports to Linux on other architecures 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.
 
-If you are using libc6, then you need to apply the patch listed at
-the end of this file.  Just type `patch boehm_gc/os_dep.c < README.Linux'.
+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.
+Just type `patch boehm_gc/os_dep.c < README.Linux'.
 
 On Linux with ELF, shared libraries are supported.  However, ELF shared
 libraries require position-independent code, and (partly due to
@@ -46,18 +47,18 @@
 
 --------------------
 
-diff -u -r1.9 os_dep.c
---- os_dep.c	1997/03/06 02:51:19	1.9
-+++ os_dep.c	1997/10/15 10:04:53
-@@ -23,9 +23,11 @@
-     /* for some early 1.3.X releases.  Will hopefully go away soon.	*/
-     /* in some later Linux releases, asm/sigcontext.h may have to	*/
-     /* be included instead.						*/
-+#  if 0
- #   define __KERNEL__
- #   include <asm/signal.h>
- #   undef __KERNEL__
-+#  endif
+--- 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>
++/*** #     include <asm/sigcontext.h> ***/
+ #   endif
  # endif
  # if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS)
  #   include <sys/types.h>
+ #   if !defined(MSWIN32) && !defined(SUNOS4)


Index: os_dep.c
===================================================================
RCS file: /home/mercury1/repository/mercury/boehm_gc/os_dep.c,v
retrieving revision 1.10
diff -u -u -r1.10 os_dep.c
--- os_dep.c	1997/11/21 11:07:45	1.10
+++ os_dep.c	1997/11/24 06:01:23
@@ -27,7 +27,12 @@
 #     define __KERNEL__
 #     include <asm/signal.h>
 #     undef __KERNEL__
-#   elif (LINUX_VERSION_CODE < 0x20100)
+#   else
+      /* 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>
 #   endif
 # endif


Index: README.Linux-PPC
===================================================================
RCS file: README.Linux-PPC
diff -N README.Linux-PPC
--- /dev/null	Mon Nov 24 17:09:04 1997
+++ README.Linux-PPC	Mon Nov 24 17:16:07 1997
@@ -0,0 +1,133 @@
+Mercury should compile out-of-the-box on Linux for PPC.
+Thanks to Robert A. Abernathy for his help with this port.
+
+However, there are a few things that could be done to "tune" this port.
+Currently the Linux-PPC port does not yet support
+	- gcc global register variables
+	- shared libraries
+	- stack overflow detection
+
+Appended below is some information on how to add support for these.
+Intrepid hackers, read on ;-)
+
+> Robert A. Abernathy wrote:
+> > 
+> > You'll notice that shared libraries aren't supported on this
+> > machine yet.  The LinuxPPC on the machine is an ELF system
+> > and does support shared libs.  Most software I've tried to
+> > port that uses configure doesn't like to see this yet.
+> > I don't know in your case what the test is yet. 
+> > This certainly isn't crucial as far as I'm concerned.
+> > Just figured I'd let you know.
+> 
+> Thanks.
+> 
+> We don't try to auto-configure shared libraries;
+> it's not reliable, since often failures only exhibit
+> themselves on large programs, not simple test cases.
+> 
+> The code to handle shared libraries might be as simple as just
+> patching configure to tell it to assume that they work. 
+> (The way to do this is shown in the patch appended below.)
+> But more likely it will also require a little bit
+> of ABI-dependent code in runtime/goto.h, similar to the existing
+> stuff there for for __alpha or __sparc.
+> 
+> > checking whether we can use gcc labels and global registers... no
+> > checking whether we can use global registers without gcc labels... no
+> 
+> Actually it would probably be much more important to get gcc global
+> registers working; this would give you a big (50-100%) performance
+> boost.  This is also probably very easy.  You probably just need
+> to modify runtime/regs.h to change the line
+> 
+> 	#elif defined(_POWER)
+> 
+> to something that matches some symbol defined by gcc for Power PC,
+> e.g.
+> 
+> 	#elif defined(__powerpc__) || defined(_POWER)
+> 
+> We've already ported to rs6000-ibm-aix, so this architecture
+> has already been tested (RS/6000 is basically the same as PowerPC).
+> It should just be a matter of finding the right #define to enable it.
+> 
+> (Incidentally, if you're trying any of this stuff out, it is generally
+> quickest to start with a freshly untarred source distribution.)
+> 
+> > checking for sys/siginfo.h... no
+> > checking for ucontext.h... no
+> > checking for sys/ucontext.h... no
+> > checking for asm/sigcontext.h... yes
+> ...
+> > checking for `sigaction' field name... sa_handler
+> > checking for working `sigcontext_struct'... no
+> > checking for `siginfo_t'... no
+> 
+> The only other thing missing is stack overflow checking.
+> That requires a way of determining the fault address in a signal
+> handler, and there's no portable way of doing that.
+> We try a bunch of different ways, as shown above.
+> The method that is used on x86-linux is asm/sigcontext.h +
+> sigcontext_struct.  Unfortunately the sigcontext_struct field name
+> we use in this method is hard-coded as `cr2', so it won't work on
+> PPC-Linux.  There may be some way of getting the same information
+> on PPC-Linux.
+> 
+> Anyway, stack overflow checking is a lot less important than
+> the other two.  Global register variables would probably be
+> very easy and very beneficial, so it's very worthwhile.
+> Shared libraries would be useful, but might be a bit of work.
+> Stack overflow checking would be icing on the cake ;-)
+> 
+> Anyway, thanks for all your help, and I hope you enjoy using
+> Mercury.
+> 
+> Cheers,
+> 	Fergus.
+> 
+> -- 
+> 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.
+> 
+> P.S.  In the very latest beta-release, runtime/regs.h has been
+> renamed as runtime/mercury_regs.h, and similary goto.h is now
+> mercury_goto.h.
+> 
+> Index: regs.h
+> ===================================================================
+> RCS file: /home/staff/zs/imp/mercury/runtime/regs.h,v
+> retrieving revision 1.31
+> diff -u -u -r1.31 regs.h
+> --- regs.h	1997/08/23 22:34:17	1.31
+> +++ regs.h	1997/11/22 17:55:03
+> @@ -70,7 +70,7 @@
+>      #include "machdeps/alpha_regs.h"
+>    #elif defined(__hppa__)
+>      #include "machdeps/pa_regs.h"
+> -  #elif defined(_POWER)
+> +  #elif defined(__powerpc__) || defined(_POWER)
+>      #include "machdeps/rs6000_regs.h"
+>    #else
+>      #error "USE_GCC_GLOBAL_REGISTERS not yet supported on this machine."
+> 
+> Index: configure.in
+> ===================================================================
+> RCS file: /home/staff/zs/imp/mercury/configure.in,v
+> retrieving revision 1.117
+> diff -u -u -r1.117 configure.in
+> --- configure.in	1997/11/02 12:41:48	1.117
+> +++ configure.in	1997/11/22 17:37:07
+> @@ -1404,6 +1404,10 @@
+>  		AC_MSG_RESULT(yes)
+>  		EXT_FOR_SHARED_LIB=so
+>  		;;
+> +	powerpc-*-linux|powerpc-*-linux-gnu)
+> +		AC_MSG_RESULT(yes)
+> +		EXT_FOR_SHARED_LIB=so
+> +		;;
+>  	i?86-*-freebsd*)
+>  		# From Cornelis van der Laan <nils at ims.uni-stuttgart.de>
+>  		AC_MSG_RESULT(yes)
+> 

-- 
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.



More information about the developers mailing list