[m-dev.] for review: README.lcc

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Feb 4 23:41:48 AEDT 2001


I've installed lcc on venus (using the RPM, I'm afraid, since there
was no Debian package for it), and I'm in the process of setting up
regular nightly tests using lcc.  But I thought it worth documenting
the various hacks needed to get it to work.

----------

Estimated hours taken: 3

README.lcc:
	New file.  Documents how to install using lcc.

----------

This file documents how to use lcc 4.1 as the C compiler when
installing Mercury on Linux.

Some of the same issues may arise when using lcc on other systems,
or when using other versions of lcc.

1.  You can get lcc from <http://www.cs.princeton.edu/software/lcc/>.
    In particular Linux RPM's are available from
    <ftp://ftp.cs.princeton.edu/pub/packages/lcc/contrib>.

2.  Apply the following patches:

(i)  On at least some versions of Linux, the following patch must be
applied to /usr/include/stdint.h.  This is because the Boehm (et al)
collector uses elf.h, and the version of elf.h that gets installed on
Linux uses by default is not compatible with lcc -- it uses
typedefs defined as `long long' in stdint.h.

If you prefer you can copy stdint.h to /usr/local/lib/lcc-4.1/include
and then apply the patch there.

This should be fixed in newer versions of glibc.

--- /usr/include/stdint.h	Sun Nov  7 03:23:27 1999
+++ ./stdint.h	Tue Nov 21 05:25:39 2000
@@ -28,6 +28,22 @@
 #include <stddef.h>
 #include <bits/wordsize.h>
 
+#ifdef __GNUC__
+__extension__
+typedef long long __long_long;
+__extension__
+typedef unsigned long long __u_long_long;
+#else
+typedef struct {
+	long __ll_first;
+	long __ll_second;
+} __long_long;
+typedef struct {
+	unsigned long __ull_first;
+	unsigned long __ull_second;
+} __u_long_long;
+#endif
+
 /* Exact integral types.  */
 
 /* Signed.  */
@@ -42,8 +58,10 @@
 typedef long int		int64_t;
 # else
 __extension__
-typedef long long int		int64_t;
+typedef __long_long		int64_t;
 # endif
+#else
+typedef __long_long		int64_t;
 #endif
 
 /* Unsigned.  */
@@ -54,7 +72,7 @@
 typedef unsigned long int	uint64_t;
 #else
 __extension__
-typedef unsigned long long int	uint64_t;
+typedef __u_long_long		uint64_t;
 #endif
 
 
@@ -68,7 +86,7 @@
 typedef long int		int_least64_t;
 #else
 __extension__
-typedef long long int		int_least64_t;
+typedef __long_long		int_least64_t;
 #endif
 
 /* Unsigned.  */
@@ -79,7 +97,7 @@
 typedef unsigned long int	uint_least64_t;
 #else
 __extension__
-typedef unsigned long long int	uint_least64_t;
+typedef __u_long_long		uint_least64_t;
 #endif
 
 
@@ -95,7 +113,7 @@
 typedef int			int_fast16_t;
 typedef int			int_fast32_t;
 __extension__
-typedef long long int		int_fast64_t;
+typedef __long_long		int_fast64_t;
 #endif
 
 /* Unsigned.  */
@@ -108,7 +126,7 @@
 typedef unsigned int		uint_fast16_t;
 typedef unsigned int		uint_fast32_t;
 __extension__
-typedef unsigned long long int	uint_fast64_t;
+typedef __u_long_long		uint_fast64_t;
 #endif
 
 
@@ -134,9 +152,9 @@
 typedef unsigned long int	uintmax_t;
 #else
 __extension__
-typedef long long int		intmax_t;
+typedef __long_long		intmax_t;
 __extension__
-typedef unsigned long long int	uintmax_t;
+typedef __u_long_long		uintmax_t;
 #endif
 
(ii) On some versions of Linux, the following patch must be
applied to /usr/local/lib/lcc-4.1/include/stdio.h.
This is due to an incompatibility between glibc's <sys/types.h>
and lcc's <stdio.h>.

--- stdio.h.orig	Thu Jul  6 10:12:07 2000
+++ stdio.h	Sun Feb  4 18:33:46 2001
@@ -444,18 +444,20 @@
    are originally defined in the Large File Support API.  */
 
 /* Types needed in these functions.  */
-#ifndef off_t
+#if !defined off_t && !defined __off_t_defined
 # ifndef __USE_FILE_OFFSET64
 typedef __off_t off_t;
 # else
 typedef __off64_t off_t;
 # endif
 # define off_t off_t
+# define __off_t_defined
 #endif
 
-#if defined __USE_LARGEFILE64 && !defined off64_t
+#if defined __USE_LARGEFILE64 && !defined off64_t && !defined __off64_t_defined
 typedef __off64_t off64_t;
 # define off64_t off64_t
+# define __off64_t_defined
 #endif
 
(iii) lcc 4.1 on at least some versions of Linux has a bug where
`lcc -static' is broken.  To work around that, rename the
original `lcc' program as `lcc.orig' and replace it with the
following script:

	#!/bin/sh
	lcc.orig "$@" -lc -lgcc

This results in some spurious warnings when invoking `lcc -c ...',
but ensures that `lcc -static ...' works.

3.  Set the environment variable `CC' to `lcc' before running configure.

4.  Follow the normal installation instructions in the INSTALL file.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- 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