bugfix for gcc-3.x
Malcolm Wallace <[email protected]> Wed, 5 Feb 2003 15:32:51 +0000
| Newsgroups | gmane.comp.lang.haskell.nhc.bugs |
|---|---|
| Organization | Dept of Computer Science, University of York |
| Message-ID | <[email protected]> |
To any users of nhc98 who have reported faults when trying to build
or use the compiler in conjuction with gcc-3.x.
We have finally found the cause of the fault, and a fix. A source-code
patch for nhc98-1.14 is attached, and is also available for download from
the website.
Technical details:
It appears that gcc has changed the way it aligns statically declared
arrays of pointers, from 4-byte boundaries in (gcc-2.x) to 32-byte
boundaries (in gcc-3.x). Unfortunately, nhc98 was relying very
heavily on the 4-byte alignment. As it turns out, the alignment can
be restored to 4-byte boundaries without any ill effects, by using an
"evil mangler"(TM) on the assembly code.
Regards,
Malcolm
P.S. The phrase "evil mangler" is trademark of GHC. :-)
patch-1.14-gcc3
(text/plain, 2.6 KB)
Index: script/nhc98.inst
===================================================================
RCS file: /usr/src/master/nhc/script/nhc98.inst,v
retrieving revision 1.40
diff -u -r1.40 nhc98.inst
--- script/nhc98.inst 2002/12/22 22:22:44 1.40
+++ script/nhc98.inst 2003/02/05 15:17:48
@@ -539,7 +539,8 @@
then
echo $CPPAS $ENDIAN $CPPASFLAGS $CINCDIRS $TMPCPPASFILE -o $TMPASFILE
fi
- $CPPAS $ENDIAN $CPPASFLAGS $CINCDIRS $TMPCPPASFILE -o $TMPASFILE
+ $CPPAS $ENDIAN $CPPASFLAGS $CINCDIRS $TMPCPPASFILE -o - | \
+ sed -e '/.align 32/s/32/4/' >$TMPASFILE # evil mangler!
if test $CSRC -eq 0
then
if test $VFLAG -eq 1
Index: src/runtime/Kernel/Makefile
===================================================================
RCS file: /usr/src/master/nhc/src/runtime/Kernel/Makefile,v
retrieving revision 1.12
diff -u -r1.12 Makefile
--- src/runtime/Kernel/Makefile 2002/10/07 13:42:11 1.12
+++ src/runtime/Kernel/Makefile 2003/02/05 15:17:48
@@ -5,7 +5,8 @@
OBJDIR=${BUILDDIR}/${OBJ}/runtime/Kernel
OSRCS = mutator.c mutlib.c main.c
-ASRCS = haskellInit.c newtables.c dump.c inscount.c newbuiltin.c collector.c mark.c \
+SSRCS = newtables.c newbuiltin.c
+ASRCS = haskellInit.c dump.c inscount.c collector.c mark.c \
cdata.c timeUnix.c xlib_debug.c stableptr.c closureval.c ffiexport.c
ifneq "${PROFILING}" ""
@@ -17,6 +18,7 @@
endif
OOBJS = $(patsubst %.c,${OBJDIR}/%.o,${OSRCS})
+SOBJS = $(patsubst %.c,${OBJDIR}/%.o,${SSRCS})
AOBJS = $(patsubst %.c,${OBJDIR}/%.o,${ASRCS})
ifeq "$(CFG)" ""
@@ -25,7 +27,7 @@
ARCHIVE=${OBJDIR}/Runtime.${CFG}.a
endif
-OBJS = ${AOBJS} ${OOBJS}
+OBJS = ${AOBJS} ${SOBJS} ${OOBJS}
CFLAGS = ${DCFG} ${BUGFIX} ${ENDIAN} ${OPT} -I${INCDIR} \
-DVERSION="\"$(VERSION)\"" #-DBYTECODE_PROF
@@ -35,6 +37,9 @@
${AOBJS} ${OOBJS}: ${OBJDIR}/%.o: %.c
${CC} -c ${CFLAGS} -o $@ $<
+${SOBJS}: ${OBJDIR}/%.o: %.c
+ ${CC} -S ${CFLAGS} -o - $< | sed '/.align 32/s/32/4/' |\
+ ${CC} -c -x assembler ${CFLAGS} -o $@ -
LINKS = bytecode.h cinterface.h mutlib.h newmacros.h \
node.h runtime.h stableptr.h newbytecode.h bytecode_o.h
@@ -51,13 +56,14 @@
ifeq "${TPROF}" ""
-${ARCHIVE}: ${AOBJS}
- cd ${OBJDIR}; $(AR) $(ARFLAGS) $@ $(patsubst ${OBJDIR}/%,%,${AOBJS})
+${ARCHIVE}: ${AOBJS} ${SOBJS}
+ cd ${OBJDIR}; \
+ $(AR) $(ARFLAGS) $@ $(patsubst ${OBJDIR}/%,%,${AOBJS} ${SOBJS})
else
-${ARCHIVE}: ${AOBJS} ${TPLOBJS}
+${ARCHIVE}: ${AOBJS} ${SOBJS} ${TPLOBJS}
cd ${OBJDIR}; $(AR) $(ARFLAGS) $@ \
- $(patsubst ${OBJDIR}/%,%,${TPLOBJS} ${AOBJS})
+ $(patsubst ${OBJDIR}/%,%,${TPLOBJS} ${AOBJS} ${SOBJS})
rm -f ${TPLOBJS}
${TPLOBJS}: