[m-dev.] diff: fixes for lcc
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Dec 1 14:21:36 AEDT 2000
Estimated hours taken: 6
Support using `lcc' as the C compiler.
I've tested this on i686-pc-linux-gnu, using grade `none.gc'.
This is not a complete fix; it still fails a few test cases which I
haven't investigated yet. They might be due to bugs in lcc.
configure.in:
Some more fixes so that `configure' works with CC set to a compiler
other than gcc:
- Fix a bug in the autoconf test for using sockets.
The code here was assuming that the second argument
to the AC_TRY_LINK macro was some C code at global
scope (e.g. containing definitions of functions
and global variables), but in fact the argument is a C
function body. By chance this worked anyway with gcc,
because gcc supports nested functions! But it didn't
work with other C compilers.
- Fix a bug where it was assuming that asm labels
work on alpha*-dec-*; this is true for gcc, but
not for other C compilers.
- Set the `-I' options in CPPFLAGS rather than in CFLAGS,
so that they get used for `AC_CHECK_HEADER'.
- For Irix, don't assume that we should use grade reg.gc
unless the compiler is gcc.
- Make sure that we use CFLAGS_FOR_GOTOS and/or CFLAGS_FOR_REGS
when running the tests for non-local gotos and/or global
registers.
boehm_gc/gcconfig.h:
If __LCC__ is defined, use the generic C version of GC_push_regs()
rather than the version implemented using inline assembler, since
lcc doesn't support inline assembler.
scripts/mgnuc.in:
If `--no-ansi', is specified, pass `-D_GNU_SOURCE' to the C compiler.
This is needed for lcc, because lcc always passes `-DPOSIX_SOURCE',
and so we need to explicit pass `-D_GNUC_SOURCE' to enable all the
stuff in the standard header files.
scripts/ml.in:
Change the way we pass options to the linker, since the syntax
for this is slightly different in lcc than it is for gcc.
Workspace: /home/pgrad/fjh/ws/hg4
Index: boehm_gc/gcconfig.h
===================================================================
RCS file: /home/mercury1/repository/mercury/boehm_gc/gcconfig.h,v
retrieving revision 1.4
diff -u -d -r1.4 gcconfig.h
--- boehm_gc/gcconfig.h 2000/09/18 11:08:51 1.4
+++ boehm_gc/gcconfig.h 2000/11/20 19:10:46
@@ -1314,7 +1314,8 @@
# endif
# if defined(HP_PA) || defined(M88K) || defined(POWERPC) \
- || (defined(I386) && defined(OS2)) || defined(UTS4) || defined(LINT)
+ || (defined(I386) && defined(OS2)) || defined(UTS4) \
+ || defined(__LCC__) || defined(LINT)
/* Use setjmp based hack to mark from callee-save registers. */
# define USE_GENERIC_PUSH_REGS
# endif
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.235
diff -u -d -r1.235 configure.in
--- configure.in 2000/11/23 06:46:25 1.235
+++ configure.in 2000/11/25 10:47:47
@@ -225,14 +225,14 @@
# we also need to add the appropriate `-I' options so that the test programs
# can #include various Mercury runtime headers.
-CFLAGS="-Iruntime -Iruntime/machdeps $CFLAGS"
+CPPFLAGS="-Iruntime -Iruntime/machdeps $CPPFLAGS"
# Make sure we search /usr/local/include and /usr/local/lib for
# header files and libraries. GNU C normally searches /usr/local/include
# by default, but (inconsistently) it does _not_ search /usr/local/lib;
# and in any case the user might be using a different C compiler that
# doesn't search either of those by default.
-CFLAGS="-I/usr/local/include $CFLAGS"
+CPPFLAGS="-I/usr/local/include $CPPFLAGS"
LIBS="-L/usr/local/lib $LIBS"
AC_PROG_CPP
@@ -337,7 +337,6 @@
AC_CHECK_HEADER(ucontext.h, HAVE_UCONTEXT_H=1)
if test "$HAVE_UCONTEXT_H" = 1; then
AC_DEFINE(HAVE_UCONTEXT)
- CFLAGS="$CFLAGS -DHAVE_UCONTEXT"
else
AC_CHECK_HEADER(sys/ucontext.h, HAVE_SYS_UCONTEXT_H=1)
if test "$HAVE_SYS_UCONTEXT_H" = 1; then
@@ -1386,29 +1385,25 @@
#
# NB. Any changes here may also require changes to scripts/mgnuc.in.
#
-save_CC="$CC"
-save_LIBRARY_PATH="$LIBRARY_PATH"
CFLAGS_FOR_REGS=
+CFLAGS_FOR_GOTOS=
+LIBRARY_PATH_FOR_GOTOS=
case $ac_cv_prog_gcc in yes)
case "`$CC --version < /dev/null`" in
2.8*) CFLAGS_FOR_GOTOS="-fno-defer-pop -fno-function-cse" ;;
*) CFLAGS_FOR_GOTOS="-fno-defer-pop -fno-function-cse -fno-gcse" ;;
- esac ;;
-esac
-case "$host" in
+ esac
+ case "$host" in
mips-sgi-irix5.*)
- CC="$CC -non_shared -mno-abicalls"
CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -non_shared -mno-abicalls"
-LIBRARY_PATH="$NONSHARED_LIB_DIR:/usr/lib/nonshared:$LIBRARY_PATH"
- export LIBRARY_PATH
+ LIBRARY_PATH_FOR_GOTOS="$NONSHARED_LIB_DIR:/usr/lib/nonshared"
;;
-esac
-case "$host" in
+ esac
+ case "$host" in
mips-*)
CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer"
;;
i?86-*)
- CC="$CC -fno-builtin -fno-omit-frame-pointer"
CFLAGS_FOR_REGS="-fno-builtin -fno-omit-frame-pointer"
;;
# We need a special-case hack here, because the auto-config
@@ -1431,21 +1426,30 @@
mercury_cv_gcc_labels=no
;;
sparc*)
- case $ac_cv_prog_gcc in yes)
- case "`$CC --version < /dev/null`" in 2.8*)
+ case "`$CC --version < /dev/null`" in 2.8*)
AC_MSG_WARN(*** Mercury might not work with " \
"gcc 2.8 on sparc!)
AC_MSG_WARN(We advise using gcc 2.7.x or egcs.)
;;
- esac
- ;;
esac
;;
+ esac
+ ;;
esac
AC_SUBST(CFLAGS_FOR_REGS)
AC_SUBST(CFLAGS_FOR_GOTOS)
#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(whether we can use gcc labels)
+
+# Set env vars for compiling with gcc non-local gotos
+save_CC="$CC"
+save_LIBRARY_PATH="$LIBRARY_PATH"
+CC="$CC $CFLAGS_FOR_GOTOS"
+if test "$LIBRARY_PATH_FOR_GOTOS" != ""; then
+ LIBRARY_PATH="$LIBRARY_PATH_FOR_GOTOS:$LIBRARY_PATH"
+ export LIBRARY_PATH
+fi
+
AC_CACHE_VAL(mercury_cv_gcc_labels,
AC_TRY_RUN([
void *entry_foo_1;
@@ -1494,9 +1498,10 @@
if test "$mercury_cv_gcc_labels" = yes; then
AC_DEFINE(HAVE_GCC_LABELS)
fi
-#-----------------------------------------------------------------------------#
+
if test $mercury_cv_gcc_labels = yes; then
AC_MSG_CHECKING(whether we can use asm labels)
+
AC_CACHE_VAL(mercury_cv_asm_labels,
AC_TRY_RUN([
void *volatile volatile_global_pointer;
@@ -1525,6 +1530,11 @@
if test $HAVE_ASM_LABELS = 1; then
AC_DEFINE(HAVE_ASM_LABELS)
fi
+
+# Restore env vars modified above
+CC="$save_CC"
+LIBRARY_PATH="$save_LIBRARY_PATH"
+
#-----------------------------------------------------------------------------#
# We need to ensure that runtime/mercury_conf.h exists, since some of the
# programs we attempt to compile below indirectly include it.
@@ -1536,6 +1546,16 @@
#-----------------------------------------------------------------------------#
if test $mercury_cv_gcc_labels = yes || test $mercury_cv_asm_labels = yes; then
AC_MSG_CHECKING(whether we can use gcc labels and global registers)
+
+ # Set env vars for compiling with gcc non-local gotos and registers
+ save_CC="$CC"
+ save_LIBRARY_PATH="$LIBRARY_PATH"
+ CC="$CC $CFLAGS_FOR_GOTOS $CFLAGS_FOR_REGS"
+ if test "$LIBRARY_PATH_FOR_GOTOS" != ""; then
+ LIBRARY_PATH="$LIBRARY_PATH_FOR_GOTOS:$LIBRARY_PATH"
+ export LIBRARY_PATH
+ fi
+
AC_CACHE_VAL(mercury_cv_gcc_model_fast,
AC_TRY_RUN([
#define USE_GCC_NONLOCAL_GOTOS
@@ -1554,18 +1574,21 @@
[mercury_cv_gcc_model_fast=no])
)
AC_MSG_RESULT($mercury_cv_gcc_model_fast)
+
+ # Restore env vars modified above
+ CC="$save_CC"
+ LIBRARY_PATH="$save_LIBRARY_PATH"
else
mercury_cv_gcc_model_fast=no
fi
#-----------------------------------------------------------------------------#
-#
-# Restore env vars modified by Irix 5 hack above
-#
-CC="$save_CC"
-LIBRARY_PATH="$save_LIBRARY_PATH"
-#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(whether we can use global registers without gcc labels)
+
+# Set env vars for compiling with gcc registers
+save_CC="$CC"
+CC="$CC $CFLAGS_FOR_REGS"
+
AC_CACHE_VAL(mercury_cv_gcc_model_reg,
AC_TRY_RUN([
#define USE_GCC_GLOBAL_REGISTERS
@@ -1584,6 +1607,9 @@
)
AC_MSG_RESULT($mercury_cv_gcc_model_reg)
+# Restore env vars modified above
+CC="$save_CC"
+
#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(whether we can support profiling on this system)
@@ -1751,10 +1777,12 @@
# For Irix 5.x, shared libraries are incompatible
# with gcc non-local gotos.
# We prefer to use shared libraries by default
- case "$host" in
- mips-sgi-irix5.*)
+ case "$host" in mips-sgi-irix5.*)
+ case $ac_cv_prog_gcc in yes)
DEFAULT_GRADE=reg.gc
;;
+ esac
+ ;;
esac
fi
@@ -2032,8 +2060,15 @@
case "$host" in
i?86-*-linux|i?86-*-linux-gnu)
- AC_MSG_RESULT(yes)
- EXT_FOR_SHARED_LIB=so
+ case $ac_cv_prog_gcc in
+ yes)
+ AC_MSG_RESULT(yes)
+ EXT_FOR_SHARED_LIB=so
+ ;;
+ *)
+ AC_MSG_RESULT(no)
+ ;;
+ esac
;;
m68*-linux|m68*-linux-gnu)
AC_MSG_RESULT(yes)
@@ -2311,7 +2346,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
-],[
+
static int MR_debug_socket = 1;
void
@@ -2320,9 +2355,8 @@
fprintf(stderr, "", s);
exit(1);
}
-
- void
- MR_trace_init_external(void)
+],[
+ /* this is the body of the test function */
{
int fd;
int len;
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.75
diff -u -d -r1.75 mgnuc.in
--- scripts/mgnuc.in 2000/11/25 13:15:07 1.75
+++ scripts/mgnuc.in 2000/11/30 03:34:07
@@ -95,6 +95,8 @@
Echo gcc command before executing it.
--no-ansi
Don't pass \`-ansi' to gcc.
+ Use the full contents of system headers,
+ rather than the ANSI subset.
--no-check
Don't enable any of gcc's warnings.
--low-level-debug
@@ -143,7 +145,7 @@
--no-ansi)
ANSI_OPTS=
- DEFINE_OPTS="$DEFINE_OPTS -D__EXTENSIONS__"
+ DEFINE_OPTS="$DEFINE_OPTS -D__EXTENSIONS__ -D_GNU_SOURCE"
;;
--no-check)
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.86
diff -u -d -r1.86 ml.in
--- scripts/ml.in 2000/10/27 09:19:07 1.86
+++ scripts/ml.in 2000/11/20 18:57:05
@@ -399,7 +399,14 @@
# boehm_gc/dyn_load.c.
# (We might eventually need similar treatment
# for other OSs too)
- MAYBE_STATIC_OPT="-static -Wl-defsym -Wl_DYNAMIC=0"
+ case $compiler in
+ gcc)
+ MAYBE_STATIC_OPT="-static -Wl-defsym -Wl_DYNAMIC=0"
+ ;;
+ lcc)
+ MAYBE_STATIC_OPT="-static -Wl,-defsym -Wl,_DYNAMIC=0"
+ ;;
+ esac
;;
*)
MAYBE_STATIC_OPT=-static
--
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