The following patch allows clisp to build on sparc64, largely by ripping out any assembly code I came across.
Comments? Ok? Index: Makefile =================================================================== RCS file: /cvsroot/ports/lang/clisp/Makefile,v retrieving revision 1.33 diff -u -N Makefile --- Makefile 23 Aug 2010 16:31:33 -0000 1.33 +++ Makefile 21 Sep 2010 21:41:01 -0000 @@ -1,13 +1,14 @@ # $OpenBSD: Makefile,v 1.33 2010/08/23 16:31:33 jasper Exp $ -ONLY_FOR_ARCHS = amd64 i386 powerpc +ONLY_FOR_ARCHS = amd64 i386 powerpc sparc64 COMMENT = ANSI Common Lisp implementation DISTNAME= clisp-2.48 -REVISION = 0 +REVISION = 1 CATEGORIES= lang HOMEPAGE= http://clisp.cons.org/ +MAINTAINER = Josh Elsasser <[email protected]> # GPLv2 PERMIT_PACKAGE_CDROM= Yes @@ -40,5 +41,9 @@ --vimdir=${PREFIX}/share/doc/clisp \ --srcdir=${WRKSRC} ${WRKBUILD} CONFIGURE_ENV = ac_cv_prog_DVIPDF='' + +.if ${MACHINE_ARCH} == "sparc64" +CFLAGS += -DSAFETY=2 -DNO_ASM -mcmodel=medany +.endif .include <bsd.port.mk> Index: patches/patch-src_arilev0_d =================================================================== RCS file: patches/patch-src_arilev0_d diff -u -N patches/patch-src_arilev0_d --- /dev/null 21 Sep 2010 14:41:14 -0000 +++ patches/patch-src_arilev0_d 21 Sep 2010 20:03:44 -0000 @@ -0,0 +1,73 @@ +$OpenBSD$ + +Rip out a bunch of sparc assembly code which is dubious at best. + +--- src/arilev0.d.orig Thu Dec 13 14:27:48 2007 ++++ src/arilev0.d Sun Sep 19 15:45:18 2010 +@@ -337,12 +337,6 @@ + ); \ + hi_assignment _hi; lo_assignment _lo; \ + }) +- #elif defined(SPARC) +- #define mulu32(x,y,hi_assignment,lo_assignment) \ +- ({ lo_assignment mulu32_(x,y); # extern in Assembler \ +- {var register uint32 _hi __asm__("%g1"); \ +- hi_assignment _hi; \ +- }}) + #elif defined(HAVE_LONG_LONG_INT) && !defined(ARM) + #define mulu32(x,y,hi_assignment,lo_assignment) \ + ({ var register uint64 _prod = (uint64)(x) * (uint64)(y); \ +@@ -354,11 +348,9 @@ + #ifndef mulu32 + #define mulu32(x,y,hi_assignment,lo_assignment) \ + { lo_assignment mulu32_(x,y); hi_assignment mulu32_high; } +- #if defined(MC680X0) || defined(SPARC) || defined(SPARC64) || defined(ARM) || (defined(I80386) && !defined(BORLAND)) || defined(MIPS) || defined(HPPA) || defined(VAX) ++ #if defined(MC680X0) || defined(ARM) || (defined(I80386) && !defined(BORLAND)) || defined(MIPS) || defined(HPPA) || defined(VAX) + # mulu32_ extern in Assembler +- #if defined(SPARC) || defined(SPARC64) +- #define mulu32_high (uint32)(_get_g1()) # R??ckgabe im Register %g1 +- #elif defined(LISPARIT) && !defined(HPPA) # In arihppa.d ist mulu32_high bereits definiert. ++ #if defined(LISPARIT) && !defined(HPPA) # In arihppa.d ist mulu32_high bereits definiert. + global uint32 mulu32_high; + #endif + #else +@@ -468,12 +460,6 @@ + ); \ + highlow64(_hi,_lo); \ + }) +- #elif defined(SPARC) +- #define mulu32_64(x,y) \ +- ({ var register uint32 _lo = mulu32_(x,y); # extern in Assembler \ +- var register uint32 _hi __asm__("%g1"); \ +- highlow64(_hi,_lo); \ +- }) + #endif + #endif + #ifndef mulu32_64 +@@ -887,12 +873,6 @@ + q_assignment (uint32)__q; \ + r_assignment (uint32)__r; \ + }) +- #elif defined(SPARC) || defined(SPARC64) +- #define divu_6432_3232(xhi,xlo,y,q_assignment,r_assignment) \ +- ({ var uint32 _q = divu_6432_3232_(xhi,xlo,y); # extern in Assembler \ +- var register uint32 _r __asm__("%g1"); \ +- q_assignment _q; r_assignment _r; \ +- }) + #elif defined(ARM) && 0 # see comment ariarm.d + #define divu_6432_3232(xhi,xlo,y,q_assignment,r_assignment) \ + ({ var uint32 _q = divu_6432_3232_(xhi,xlo,y); # extern in Assembler \ +@@ -932,11 +912,9 @@ + #ifndef divu_6432_3232 + #define divu_6432_3232(xhi,xlo,y,q_assignment,r_assignment) \ + { q_assignment divu_6432_3232_(xhi,xlo,y); r_assignment divu_32_rest; } +- #if defined(MC680Y0) || defined(SPARC) || defined(SPARC64) || defined(ARM) || (defined(I80386) && !defined(BORLAND)) || defined(HPPA) ++ #if defined(MC680Y0) || defined(ARM) || (defined(I80386) && !defined(BORLAND)) || defined(HPPA) + # divu_6432_3232_ extern in Assembler +- #if defined(SPARC) || defined(SPARC64) +- #define divu_32_rest (uint32)(_get_g1()) # R??ckgabe im Register %g1 +- #elif defined(LISPARIT) ++ #if defined(LISPARIT) + global uint32 divu_32_rest; + #endif + #else Index: patches/patch-src_arisparc64_d =================================================================== RCS file: patches/patch-src_arisparc64_d diff -u -N patches/patch-src_arisparc64_d --- /dev/null 21 Sep 2010 14:41:14 -0000 +++ patches/patch-src_arisparc64_d 21 Sep 2010 20:03:44 -0000 @@ -0,0 +1,56 @@ +$OpenBSD$ + +Disable the assembler loops, at least one of them is broken. + +Remove a couple of potentially-broken math functions to make sure they +aren't used in case the maze of #ifdefs in arilev0.d ever changes. + +--- src/arisparc64.d.orig Wed Dec 5 08:06:32 2007 ++++ src/arisparc64.d Sun Sep 19 16:25:17 2010 +@@ -14,6 +14,7 @@ + + #ifdef INCLUDED_FROM_C + ++#if 0 + #define COPY_LOOPS + #define FILL_LOOPS + #define CLEAR_LOOPS +@@ -23,6 +24,7 @@ + #define SHIFT_LOOPS + #define MUL_LOOPS + #define DIV_LOOPS ++#endif + + #else + +@@ -73,30 +75,12 @@ C(mulu16_:) # Input in %o0,%o1, Output in %o0 + retl + _ srl %o2,0,%o0 + +-# extern struct { uint32 lo; uint32 hi; } mulu32_ (uint32 arg1, uint32 arg2); +-# 2^32*hi+lo := arg1*arg2. +-C(mulu32_:) # Input in %o0,%o1, Output in %o0,%g1 +- umul %o0,%o1,%o2 +- rd %y,%g1 +- retl +- _ srl %o2,0,%o0 +- + # extern uint32 mulu32_unchecked (uint32 x, uint32 y); + # result := arg1*arg2 < 2^32. + C(mulu32_unchecked:) # Input in %o0,%o1, Output in %o0 + umul %o0,%o1,%o2 + retl + _ srl %o2,0,%o0 +- +-# extern struct { uint32 q; uint32 r; } divu_6432_3232_ (uint32 xhi, uint32 xlo, uint32 y); +-# x = 2^32*xhi+xlo = q*y+r schreiben. Sei bekannt, dass 0 <= x < 2^32*y . +-C(divu_6432_3232_:) # Input in %o0,%o1,%o2, Output in %o0,%g1 +- wr %o0,%g0,%y +- udiv %o1,%o2,%o0 # x durch y dividieren, %o0 := q +- umul %o0,%o2,%g1 # %g1 := (q*y) mod 2^32 +- sub %o1,%g1,%g1 # %g1 := (xlo-q*y) mod 2^32 = r +- retl +- _ srl %o0,0,%o0 + + # extern struct { uint16 q; uint16 r; } divu_3216_1616_ (uint32 x, uint16 y); + # x = q*y+r schreiben. Sei bekannt, dass 0 <= x < 2^16*y . Index: patches/patch-src_makemake_in =================================================================== RCS file: /cvsroot/ports/lang/clisp/patches/patch-src_makemake_in,v retrieving revision 1.10 diff -u -N patches/patch-src_makemake_in --- patches/patch-src_makemake_in 7 Jan 2010 10:55:28 -0000 1.10 +++ patches/patch-src_makemake_in 21 Sep 2010 20:03:44 -0000 @@ -1,7 +1,20 @@ $OpenBSD: patch-src_makemake_in,v 1.10 2010/01/07 10:55:28 edd Exp $ ---- src/makemake.in.orig Tue Jul 28 19:58:03 2009 -+++ src/makemake.in Wed Dec 30 22:12:19 2009 -@@ -1916,7 +1916,7 @@ echol "# This can also be used for pre-test and post-r + +Override broken compiler test, attempting to build 32-bit clisp on a +64-bit patform will not work out very well. + +--- src/makemake.in.orig Tue Jul 28 06:58:03 2009 ++++ src/makemake.in Mon Sep 20 16:32:15 2010 +@@ -1108,6 +1108,8 @@ esac + # cpu=hppa ;; + # esac + ++test "$cpu" = "${host_cpu%*64}" && cpu=${host_cpu} ++ + if [ "${verbose}" = true -o "${verbose}" = yes ]; then + cat <<EOF >&2 + # host system: +@@ -1916,7 +1918,7 @@ echol "# This can also be used for pre-test and post-r echol "# make distrib VERSION_SUFFIX=pre" echol "VERSION_SUFFIX=" echol "# The distribution's top directory" @@ -10,7 +23,7 @@ echol echol '# Directories used by "make install":' echol "prefix = ${PREFIX}" -@@ -3002,7 +3002,7 @@ fi +@@ -3002,7 +3004,7 @@ fi CLISP_="${HERE_}lisp${LEXE} -M ${HERE_}lispinit.mem ${localeflags}${someflags}" if [ $CROSS = false ] ; then Index: patches/patch-src_spsparc64_d =================================================================== RCS file: patches/patch-src_spsparc64_d diff -u -N patches/patch-src_spsparc64_d --- /dev/null 21 Sep 2010 14:41:14 -0000 +++ patches/patch-src_spsparc64_d 21 Sep 2010 20:03:44 -0000 @@ -0,0 +1,24 @@ +$OpenBSD$ + +Using %g1 to pass values across function calls is a bit iffy so make +sure that trying to call _get_g1() results in a linker error. + +--- src/spsparc64.d.orig Mon Mar 24 11:23:28 2008 ++++ src/spsparc64.d Sun Sep 19 15:03:08 2010 +@@ -11,16 +11,8 @@ + + .global getSP + .global _getSP +- .global _get_g1 +- .global __get_g1 + + # extern void* getSP (void); + getSP: + _getSP: retl + _ mov %sp,%o0 +- +-# extern uint32 _get_g1 (void); +-_get_g1: +-__get_g1: retl +- _ srl %g1,0,%o0 +-
