Add support for sparc ghc.
Hard work by Donald Stewart <dons at cse.unsw.edu.au>
This commit is contained in:
parent
6fe14f0610
commit
f9f57467b2
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.12 2003/09/01 22:46:28 avsm Exp $
|
||||
# $OpenBSD: Makefile,v 1.13 2004/01/08 20:33:23 avsm Exp $
|
||||
# Based on Simon Marlow's port script for FreeBSD:
|
||||
# $FreeBSD: ports/lang/ghc/Makefile,v 1.13 2002/08/22 12:53:38 obraun Exp $
|
||||
# And on NetBSD's 5.04.3 .hc boot script
|
||||
@ -6,20 +6,17 @@
|
||||
# The build process:
|
||||
# 1) build a full ghc6 from pre-generated 6.0.1 C files
|
||||
|
||||
ONLY_FOR_ARCHS= i386
|
||||
# The general solution for other architectures [alpha, powerpc,
|
||||
# sparc64, hppa, mips, m68k at least] will be to boot via
|
||||
# unregisterised .hc files generated on openbsd-*-i386. See:
|
||||
ONLY_FOR_ARCHS= i386 sparc
|
||||
# The general solution for other architectures will be to boot
|
||||
# via unregisterised .hc files generated on openbsd-*-i386. See:
|
||||
#
|
||||
# http://haskell.org/ghc/docs/latest/html/building/sec-porting-ghc.html
|
||||
# http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/distrib/cross-port
|
||||
#
|
||||
# The best bets are powerpc, sparc, sparc64 and alpha, which are
|
||||
# working, or have recently worked, on linux. m68k needs to have
|
||||
# its asm format set in the mangler, before we can do any kind of
|
||||
# build. sparc is in a slightly better position, as we have
|
||||
# 4.08.2 .hc source, but the C-built ghc4 goes into an infinite
|
||||
# loop, when I last tried -- dons
|
||||
# The best bets are powerpc and alpha. sparc64 and amd64 should
|
||||
# work. hppa and mips have recently worked. m68k hasn't worked
|
||||
# for a long time now, and on mac68k at least _ld_ dies with a
|
||||
# malloc error when linking the ghc binary.
|
||||
|
||||
COMMENT= "compiler for the functional language Haskell"
|
||||
COMMENT-doc= "documentation for the functional language Haskell"
|
||||
@ -51,10 +48,11 @@ DOC_DIR= ${PREFIX}/share/doc/ghc
|
||||
DISTFILES= ghc-${V}-src.tar.bz2 \
|
||||
${DOC_FILES:C/(.+)/\1.html.tar.gz:0/g} \
|
||||
${DOC_FILES1:C/(.+)/\1-html.tar.gz:1/g} \
|
||||
ghc-regress-${V}.tar.bz2:2 \
|
||||
ghc-regress-${V}.1.tar.bz2:2 \
|
||||
ghc-${V}-${ARCH}-hc.tar.gz:2
|
||||
|
||||
# only i386 hc src exists at the moment
|
||||
# only i386 and sparc .hc src exist at the moment. generating
|
||||
# this tarball is the first step in porting to a new architecture
|
||||
SUPDISTFILES= ghc-${V}-${ARCH}-hc.tar.gz:2
|
||||
|
||||
USE_GMAKE= Yes
|
||||
|
@ -1,23 +1,26 @@
|
||||
MD5 (ghc-6.0.1/building.html.tar.gz) = 1d654d0c522dbd614c8cf8f000974103
|
||||
MD5 (ghc-6.0.1/ghc-6.0.1-i386-hc.tar.gz) = c810b7af85ae78a2c705843b60b7a0e9
|
||||
MD5 (ghc-6.0.1/ghc-6.0.1-sparc-hc.tar.gz) = 36cb2517b5d4b187d5d2689d32d9de2a
|
||||
MD5 (ghc-6.0.1/ghc-6.0.1-src.tar.bz2) = 6e258de758b34905ecfc636a38fa9e23
|
||||
MD5 (ghc-6.0.1/ghc-regress-6.0.1.tar.bz2) = 2c5db22a8a84e70f5fb9e2f8dfcb6b57
|
||||
MD5 (ghc-6.0.1/ghc-regress-6.0.1.1.tar.bz2) = 0410d0e4be72f68b90aa881b5e8c2493
|
||||
MD5 (ghc-6.0.1/haskell98-report-html.tar.gz) = c9cf3b70565462aba811a2d2ac8f4763
|
||||
MD5 (ghc-6.0.1/hslibs.html.tar.gz) = 817a4ff412976a2f712593ccf83f5b12
|
||||
MD5 (ghc-6.0.1/libraries.html.tar.gz) = 2cf4d165c302b9ea3b4ffd759af1bb65
|
||||
MD5 (ghc-6.0.1/users_guide.html.tar.gz) = 5c4a1873b1279d7cb79a00e821dc3045
|
||||
RMD160 (ghc-6.0.1/building.html.tar.gz) = 2c42b086d4d41743a45229025de667755deed329
|
||||
RMD160 (ghc-6.0.1/ghc-6.0.1-i386-hc.tar.gz) = 48382fe6b45cd5b607cce40bedf276669fd3f0dc
|
||||
RMD160 (ghc-6.0.1/ghc-6.0.1-sparc-hc.tar.gz) = 62db2b768443aa5559e35a4769fbb417415edfcc
|
||||
RMD160 (ghc-6.0.1/ghc-6.0.1-src.tar.bz2) = af7fed1536810be70bd4427b8e1ec53f8f172b01
|
||||
RMD160 (ghc-6.0.1/ghc-regress-6.0.1.tar.bz2) = a83f4831d272984d7a3c4b96069dcc41f70b351e
|
||||
RMD160 (ghc-6.0.1/ghc-regress-6.0.1.1.tar.bz2) = 87c9172daf6b0fa2101874f00d0642333d1ce3b7
|
||||
RMD160 (ghc-6.0.1/haskell98-report-html.tar.gz) = 695f7a747961a13f2dd8331f42aec393681ad0e9
|
||||
RMD160 (ghc-6.0.1/hslibs.html.tar.gz) = 356e76aaaa2a0cd089dfdb90659af0eee2760827
|
||||
RMD160 (ghc-6.0.1/libraries.html.tar.gz) = ef66cb1940c5d43acfc6c3a9eec0febaffb5bd09
|
||||
RMD160 (ghc-6.0.1/users_guide.html.tar.gz) = e233eddf51a63182093f53b63d3c5648744796f9
|
||||
SHA1 (ghc-6.0.1/building.html.tar.gz) = 413d5670dddce3a7f31e39fe83c67f32acacd49d
|
||||
SHA1 (ghc-6.0.1/ghc-6.0.1-i386-hc.tar.gz) = 1755d424e637c38c2ccdd0c3337069140b3fdce2
|
||||
SHA1 (ghc-6.0.1/ghc-6.0.1-sparc-hc.tar.gz) = b7b00d973f9d9f40341800baa61401f21b114c9a
|
||||
SHA1 (ghc-6.0.1/ghc-6.0.1-src.tar.bz2) = beeeddb18da37d95dd655fdf507dfa0700c7a025
|
||||
SHA1 (ghc-6.0.1/ghc-regress-6.0.1.tar.bz2) = 4a558414064f3afa257338915e058b9abc805e12
|
||||
SHA1 (ghc-6.0.1/ghc-regress-6.0.1.1.tar.bz2) = 7ffdf6bfef5cd325a4605fbc8fb596ff1a97a777
|
||||
SHA1 (ghc-6.0.1/haskell98-report-html.tar.gz) = f0387076344b9df0f576be1016777022385a9148
|
||||
SHA1 (ghc-6.0.1/hslibs.html.tar.gz) = 856fb4154bab2a1501563c6fd65667663a79e0ba
|
||||
SHA1 (ghc-6.0.1/libraries.html.tar.gz) = 699a823f3d47ae4ec4d72e0f191314f715eb1a9b
|
||||
|
@ -1,9 +1,9 @@
|
||||
# $OpenBSD: ghc.port.mk,v 1.1 2003/07/23 18:26:35 avsm Exp $
|
||||
# $OpenBSD: ghc.port.mk,v 1.2 2004/01/08 20:33:23 avsm Exp $
|
||||
# Module for Glasgow Haskell Compiler
|
||||
|
||||
# Not yet ported to other architectures
|
||||
# See comments in lang/ghc/Makefile for more information
|
||||
ONLY_FOR_ARCHS= i386
|
||||
ONLY_FOR_ARCHS= i386 sparc
|
||||
|
||||
BUILD_DEPENDS+= bin/ghc::lang/ghc
|
||||
RUN_DEPENDS+= bin/ghc::lang/ghc
|
||||
|
@ -9,7 +9,7 @@ Add a "check" target to make regress work nicely.
|
||||
+check::
|
||||
+ ( cd testsuite/tests/ghc-regress ; $(MAKE) $(MFLAGS) )
|
||||
+ @(sed 's/ started at .*$$//' actual.result > actual.result_)
|
||||
+ @(if cmp -s expected.result actual.result_ ; then \
|
||||
+ @(if cmp -s `uname -m`.expected.result actual.result_ ; then \
|
||||
+ echo "All is good!" ; \
|
||||
+ else \
|
||||
+ echo ;\
|
||||
@ -18,5 +18,5 @@ Add a "check" target to make regress work nicely.
|
||||
+ echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@";\
|
||||
+ echo ;\
|
||||
+ echo "here is a diff:" ;\
|
||||
+ diff -u expected.result actual.result_ ;\
|
||||
+ diff -u `uname -m`.expected.result actual.result_ ;\
|
||||
+ fi ; exit 0 )
|
||||
|
@ -1,42 +1,21 @@
|
||||
$OpenBSD: patch-configure,v 1.4 2003/08/12 13:25:18 avsm Exp $
|
||||
Falsely detects leading underscore. Plan for sparc.
|
||||
Help configure find libgmp properly. i.e. fix test for gmp
|
||||
|
||||
--- configure.orig Tue Jul 29 05:01:34 2003
|
||||
+++ configure Thu Aug 7 11:25:32 2003
|
||||
--- configure.orig Mon Jul 28 13:01:34 2003
|
||||
+++ configure Sat Sep 20 18:53:45 2003
|
||||
@@ -1708,6 +1708,15 @@
|
||||
HostVendor_CPP='sun'
|
||||
HostOS_CPP='solaris2'
|
||||
;;
|
||||
+sparc-*-openbsd*) #hack
|
||||
+ HostPlatform=sparc-sun-openbsd #hack
|
||||
+ TargetPlatform=sparc-sun-openbsd #hack
|
||||
+ BuildPlatform=sparc-sun-openbsd #hack
|
||||
+ HostPlatform_CPP='sparc_sun_openbsd'
|
||||
+sparc-*-openbsd*)
|
||||
+ HostPlatform=sparc-unknown-openbsd
|
||||
+ TargetPlatform=sparc-unknown-openbsd
|
||||
+ BuildPlatform=sparc-unknown-openbsd
|
||||
+ HostPlatform_CPP='sparc_unknown_openbsd'
|
||||
+ HostArch_CPP='sparc'
|
||||
+ HostVendor_CPP='sun'
|
||||
+ HostVendor_CPP='unknown'
|
||||
+ HostOS_CPP='openbsd'
|
||||
+ ;;
|
||||
*)
|
||||
echo "Unrecognised platform: $HostPlatform"
|
||||
exit 1
|
||||
@@ -19591,12 +19600,13 @@
|
||||
#endif
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
builtin and then its argument prototype would still apply. */
|
||||
-char __gmpz_fdiv_qr ();
|
||||
+#include <gmp.h>
|
||||
+
|
||||
int
|
||||
main ()
|
||||
{
|
||||
-__gmpz_fdiv_qr ();
|
||||
- ;
|
||||
+ mpz_ptr a, b, p, q;
|
||||
+ mpz_fdiv_qr(p,q,a,b);
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
@@ -23646,6 +23656,7 @@
|
||||
else
|
||||
|
||||
|
@ -1,11 +1,18 @@
|
||||
SplitObjs just slows things down, and can overrun ulimits
|
||||
|
||||
And GHC produces stack_smash_handler() core dumps on sparc
|
||||
unless propolice is turned off. This used to happen on x86, but
|
||||
has been fixed. Someone want to fix this on sparc?
|
||||
|
||||
Help ghc find libgmp.a
|
||||
|
||||
And that old regex doesn't work/is a gnu grep thing?
|
||||
|
||||
And touch some files to avoid recompiling ghc/compiler on install
|
||||
|
||||
--- distrib/hc-build.orig Fri Jul 25 20:23:30 2003
|
||||
+++ distrib/hc-build Sun Aug 24 11:36:45 2003
|
||||
@@ -37,10 +37,15 @@
|
||||
--- distrib/hc-build.orig Fri Jul 25 04:23:30 2003
|
||||
+++ distrib/hc-build Tue Sep 23 02:35:34 2003
|
||||
@@ -37,10 +37,20 @@
|
||||
*)
|
||||
cat >mk/build.mk <<END
|
||||
# empty
|
||||
@ -16,12 +23,17 @@ And touch some files to avoid recompiling ghc/compiler on install
|
||||
;;
|
||||
esac
|
||||
|
||||
+if [ `uname -m` == "sparc" ] ; then
|
||||
+ echo "SRC_HC_OPTS+=-optc-fno-stack-protector" >> mk/build.mk
|
||||
+ echo "SRC_CC_OPTS+=-fno-stack-protector" >> mk/build.mk
|
||||
+fi
|
||||
+
|
||||
+export CPPFLAGS="-I${LOCALBASE}/include" LDFLAGS="-L${LOCALBASE}/lib"
|
||||
+
|
||||
echo "*** Building compiler..."
|
||||
./configure --enable-hc-boot $configopts
|
||||
|
||||
@@ -75,12 +80,11 @@
|
||||
@@ -75,12 +85,11 @@
|
||||
# The reconfigure step updates a few files, which can lead to
|
||||
# unnecessary recompilations. Touch a bunch of things here to avoid
|
||||
# having to recompile stuff that we've already built.
|
||||
@ -35,7 +47,7 @@ And touch some files to avoid recompiling ghc/compiler on install
|
||||
|
||||
# Do includes and RTS now
|
||||
$MAKE -C ghc/includes boot && $MAKE -C ghc/includes all
|
||||
@@ -96,6 +100,6 @@
|
||||
@@ -96,6 +105,6 @@
|
||||
$MAKE -C hslibs boot all
|
||||
|
||||
# Avoid relinking the compiler during 'make install':
|
||||
|
@ -1,8 +1,5 @@
|
||||
$OpenBSD: patch-ghc_driver_mangler_ghc-asm_lprl,v 1.3 2003/08/01 14:03:40 avsm Exp $
|
||||
ELF
|
||||
|
||||
--- ghc/driver/mangler/ghc-asm.lprl.orig Fri Jul 4 10:55:44 2003
|
||||
+++ ghc/driver/mangler/ghc-asm.lprl Fri Jul 4 10:55:58 2003
|
||||
--- ghc/driver/mangler/ghc-asm.lprl.orig Mon Jun 30 08:40:55 2003
|
||||
+++ ghc/driver/mangler/ghc-asm.lprl Sat Sep 20 18:49:19 2003
|
||||
@@ -142,7 +142,7 @@
|
||||
$T_create_word = "\t.word";
|
||||
|
||||
@ -19,5 +16,14 @@ ELF
|
||||
- } elsif ( $TargetPlatform =~ /^i386-.*-(solaris2|linux|freebsd|netbsd)$/ ) {
|
||||
+ } elsif ( $TargetPlatform =~ /^i386-.*-(solaris2|linux|freebsd|netbsd|openbsd)$/ ) {
|
||||
|
||||
$T_STABBY = 0; # 1 iff .stab things (usually if a.out format)
|
||||
$T_US = ''; # _ if symbols have an underscore on the front
|
||||
@@ -317,7 +317,7 @@
|
||||
$T_create_word = "\t.long";
|
||||
|
||||
#--------------------------------------------------------#
|
||||
- } elsif ( $TargetPlatform =~ /^sparc-.*-solaris2/ ) {
|
||||
+ } elsif ( $TargetPlatform =~ /^sparc-.*-(solaris2|openbsd)/ ) {
|
||||
|
||||
$T_STABBY = 0; # 1 iff .stab things (usually if a.out format)
|
||||
$T_US = ''; # _ if symbols have an underscore on the front
|
||||
|
@ -1,4 +1,4 @@
|
||||
$OpenBSD: patch-ghc_rts_Adjustor_c,v 1.3 2003/09/01 20:32:14 espie Exp $
|
||||
$OpenBSD: patch-ghc_rts_Adjustor_c,v 1.4 2004/01/08 20:33:23 avsm Exp $
|
||||
Ok. This is the magical "adjustor thunk". The entry point into
|
||||
Haskell land from C land. Problem is that it (1) uses dynamically
|
||||
generated code stored on the heap, as well as (2) a nasty little hack
|
||||
@ -7,13 +7,12 @@ that invovles exec'ing some code in .data.
|
||||
Solved (1) by using a StablePtr, avoiding malloc memory
|
||||
altogether for the adjustor thunk itself.
|
||||
|
||||
Solved (2) by writing an assembly function to do the code they
|
||||
were too lazy to put into a .s file in the first place. See
|
||||
obscure_ccall.s
|
||||
Solved (2) by writing the assembly to do the code they
|
||||
were too lazy to put into asm in the first place.
|
||||
|
||||
--- ghc/rts/Adjustor.c.orig Wed Mar 26 04:58:47 2003
|
||||
+++ ghc/rts/Adjustor.c Thu Jul 10 21:25:30 2003
|
||||
@@ -65,10 +65,10 @@
|
||||
--- ghc/rts/Adjustor.c.orig Sat Oct 18 12:04:10 2003
|
||||
+++ ghc/rts/Adjustor.c Sat Oct 18 12:04:08 2003
|
||||
@@ -65,10 +65,11 @@
|
||||
For this to work we make the assumption that bytes in .data
|
||||
are considered executable.
|
||||
*/
|
||||
@ -21,31 +20,34 @@ obscure_ccall.s
|
||||
- { 0x83, 0xc4, 0x04 /* addl $0x4, %esp */
|
||||
- , 0xc3 /* ret */
|
||||
- };
|
||||
+
|
||||
+/* from obscure_ccall.s */
|
||||
+extern void __obscure_ccall_ret_code(void);
|
||||
+
|
||||
+static void __obscure_ccall_ret_code(void)
|
||||
+{
|
||||
+ asm("addl $0x4, %esp");
|
||||
+ asm("ret");
|
||||
+}
|
||||
#endif
|
||||
|
||||
#if defined(alpha_TARGET_ARCH)
|
||||
@@ -77,13 +77,14 @@
|
||||
@@ -77,7 +78,6 @@
|
||||
#endif
|
||||
|
||||
#if defined(ia64_TARGET_ARCH)
|
||||
-#include "Storage.h"
|
||||
-
|
||||
|
||||
/* Layout of a function descriptor */
|
||||
typedef struct _IA64FunDesc {
|
||||
StgWord64 ip;
|
||||
@@ -85,6 +85,10 @@
|
||||
StgWord64 gp;
|
||||
} IA64FunDesc;
|
||||
|
||||
+#endif
|
||||
+
|
||||
+#include "Storage.h"
|
||||
|
||||
+
|
||||
static void *
|
||||
stgAllocStable(size_t size_in_bytes, StgStablePtr *stable)
|
||||
@@ -105,7 +106,6 @@
|
||||
{
|
||||
@@ -105,7 +109,6 @@
|
||||
/* and return a ptr to the goods inside the array */
|
||||
return(BYTE_ARR_CTS(arr));
|
||||
}
|
||||
@ -53,95 +55,103 @@ obscure_ccall.s
|
||||
|
||||
void*
|
||||
createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr)
|
||||
@@ -128,20 +128,22 @@
|
||||
@@ -128,8 +131,13 @@
|
||||
<c>: ff e0 jmp %eax # and jump to it.
|
||||
# the callee cleans up the stack
|
||||
*/
|
||||
- if ((adjustor = stgMallocBytes(14, "createAdjustor")) != NULL) {
|
||||
- unsigned char *const adj_code = (unsigned char *)adjustor;
|
||||
- adj_code[0x00] = (unsigned char)0x58; /* popl %eax */
|
||||
-
|
||||
- adj_code[0x01] = (unsigned char)0x68; /* pushl hptr (which is a dword immediate ) */
|
||||
- *((StgStablePtr*)(adj_code + 0x02)) = (StgStablePtr)hptr;
|
||||
-
|
||||
- adj_code[0x06] = (unsigned char)0x50; /* pushl %eax */
|
||||
+ {
|
||||
+ StgStablePtr stable;
|
||||
+ unsigned char *const adj_code;
|
||||
|
||||
- adj_code[0x07] = (unsigned char)0xb8; /* movl $wptr, %eax */
|
||||
- *((StgFunPtr*)(adj_code + 0x08)) = (StgFunPtr)wptr;
|
||||
+ adjustor = stgAllocStable(18,&stable);
|
||||
+ StgStablePtr stable;
|
||||
+ unsigned char *adj_code;
|
||||
+
|
||||
+ adjustor = stgAllocStable(18, &stable);
|
||||
+ adj_code = (unsigned char *)adjustor;
|
||||
+
|
||||
adj_code[0x00] = (unsigned char)0x58; /* popl %eax */
|
||||
|
||||
- adj_code[0x0c] = (unsigned char)0xff; /* jmp %eax */
|
||||
- adj_code[0x0d] = (unsigned char)0xe0;
|
||||
+ adj_code[0] = (unsigned char)0x58; /* popl %eax */
|
||||
+ adj_code[1] = (unsigned char)0x68; /* pushl hptr (which is a dword immediate ) */
|
||||
+ *((StgStablePtr*)(adj_code+2)) = (StgStablePtr)hptr;
|
||||
+ adj_code[6] = (unsigned char)0x50; /* pushl %eax */
|
||||
+ adj_code[7] = (unsigned char)0xb8; /* movl $wptr, %eax */
|
||||
+ *((StgFunPtr*)(adj_code+8)) = (StgFunPtr)wptr;
|
||||
+ adj_code[12] = (unsigned char)0xff; /* jmp %eax */
|
||||
+ adj_code[13] = (unsigned char)0xe0;
|
||||
+ *((StgStablePtr*)(adj_code+14)) = (StgStablePtr)stable;
|
||||
adj_code[0x01] = (unsigned char)0x68; /* pushl hptr (which is a dword immediate ) */
|
||||
@@ -142,6 +150,8 @@
|
||||
|
||||
adj_code[0x0c] = (unsigned char)0xff; /* jmp %eax */
|
||||
adj_code[0x0d] = (unsigned char)0xe0;
|
||||
+
|
||||
+ *((StgStablePtr*)(adj_code + 0x0e)) = (StgStablePtr)stable;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@@ -172,20 +174,22 @@
|
||||
@@ -172,9 +182,13 @@
|
||||
That's (thankfully) the case here with the restricted set of
|
||||
return types that we support.
|
||||
*/
|
||||
- if ((adjustor = stgMallocBytes(17, "createAdjustor")) != NULL) {
|
||||
- unsigned char *const adj_code = (unsigned char *)adjustor;
|
||||
-
|
||||
- adj_code[0x00] = (unsigned char)0x68; /* pushl hptr (which is a dword immediate ) */
|
||||
- *((StgStablePtr*)(adj_code+0x01)) = (StgStablePtr)hptr;
|
||||
-
|
||||
- adj_code[0x05] = (unsigned char)0xb8; /* movl $wptr, %eax */
|
||||
- *((StgFunPtr*)(adj_code + 0x06)) = (StgFunPtr)wptr;
|
||||
-
|
||||
- adj_code[0x0a] = (unsigned char)0x68; /* pushl __obscure_ccall_ret_code */
|
||||
- *((StgFunPtr*)(adj_code + 0x0b)) = (StgFunPtr)__obscure_ccall_ret_code;
|
||||
-
|
||||
- adj_code[0x0f] = (unsigned char)0xff; /* jmp *%eax */
|
||||
- adj_code[0x10] = (unsigned char)0xe0;
|
||||
+ {
|
||||
+ StgStablePtr stable;
|
||||
+ unsigned char *const adj_code;
|
||||
+
|
||||
+ adjustor = stgAllocStable(21, &stable);
|
||||
+ {
|
||||
+ StgStablePtr stable;
|
||||
+ unsigned char *adj_code;
|
||||
|
||||
+ adjustor = stgAllocStable(21, &stable);
|
||||
+ adj_code = (unsigned char *)adjustor;
|
||||
+
|
||||
+ adj_code[0] = (unsigned char)0x68; /* pushl hptr (which is a dword immediate ) */
|
||||
+ *((StgStablePtr*)(adj_code+1)) = (StgStablePtr)hptr;
|
||||
+ adj_code[5] = (unsigned char)0xb8; /* movl $wptr, %eax */
|
||||
+ *((StgFunPtr*)(adj_code+6)) = (StgFunPtr)wptr;
|
||||
+ adj_code[10] = (unsigned char)0x68; /* pushl __obscure_ccall_ret_code */
|
||||
+ *((StgFunPtr*)(adj_code+11)) = (StgFunPtr)__obscure_ccall_ret_code;
|
||||
+ adj_code[15] = (unsigned char)0xff; /* jmp *%eax */
|
||||
+ adj_code[16] = (unsigned char)0xe0;
|
||||
+ *((StgStablePtr*)(adj_code+17)) = (StgStablePtr)stable;
|
||||
adj_code[0x00] = (unsigned char)0x68; /* pushl hptr (which is a dword immediate ) */
|
||||
*((StgStablePtr*)(adj_code+0x01)) = (StgStablePtr)hptr;
|
||||
|
||||
@@ -186,6 +200,8 @@
|
||||
|
||||
adj_code[0x0f] = (unsigned char)0xff; /* jmp *%eax */
|
||||
adj_code[0x10] = (unsigned char)0xe0;
|
||||
+
|
||||
+ *((StgStablePtr*)(adj_code+0x11)) = (StgStablePtr)stable;
|
||||
}
|
||||
#elif defined(sparc_TARGET_ARCH)
|
||||
/* Magic constant computed by inspecting the code length of the following
|
||||
@@ -476,12 +480,16 @@
|
||||
@@ -217,9 +233,13 @@
|
||||
similarly, and local variables should be accessed via %fp, not %sp. In a
|
||||
nutshell: This should work! (Famous last words! :-)
|
||||
*/
|
||||
- if ((adjustor = stgMallocBytes(4*(11+1), "createAdjustor")) != NULL) {
|
||||
- unsigned long *const adj_code = (unsigned long *)adjustor;
|
||||
+ {
|
||||
+ StgStablePtr stable;
|
||||
+ unsigned long *adj_code;
|
||||
|
||||
+ adjustor = stgAllocStable(4*(11+2), &stable);
|
||||
+ adj_code = (unsigned long *)adjustor;
|
||||
+
|
||||
adj_code[ 0] = 0x9C23A008UL; /* sub %sp, 8, %sp */
|
||||
adj_code[ 1] = 0xDA23A060UL; /* st %o5, [%sp + 96] */
|
||||
adj_code[ 2] = 0xD823A05CUL; /* st %o4, [%sp + 92] */
|
||||
@@ -237,6 +257,7 @@
|
||||
adj_code[10] |= ((unsigned long)hptr) & 0x000003FFUL;
|
||||
|
||||
adj_code[11] = (unsigned long)hptr;
|
||||
+ adj_code[12] = (unsigned long)stable;
|
||||
|
||||
/* flush cache */
|
||||
asm("flush %0" : : "r" (adj_code ));
|
||||
@@ -476,12 +497,15 @@
|
||||
return;
|
||||
}
|
||||
|
||||
- /* Free the stable pointer first..*/
|
||||
+ /* Free the internal stable pointer first..*/
|
||||
if (*(unsigned char*)ptr == 0x68) { /* Aha, a ccall adjustor! */
|
||||
- freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 0x01)));
|
||||
+ freeStablePtr( *((StgStablePtr*)((unsigned char*)ptr + 1)) );
|
||||
+ freeStablePtr( *((StgStablePtr*)((unsigned char*)ptr + 17)) );
|
||||
freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 0x01)));
|
||||
+ freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 0x11)));
|
||||
} else {
|
||||
- freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 0x02)));
|
||||
+ freeStablePtr( *((StgStablePtr*)((unsigned char*)ptr + 2)) );
|
||||
+ freeStablePtr( *((StgStablePtr*)((unsigned char*)ptr + 14)) );
|
||||
freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 0x02)));
|
||||
+ freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 0x0e)));
|
||||
}
|
||||
+ return;
|
||||
+
|
||||
#elif defined(sparc_TARGET_ARCH)
|
||||
if ( *(unsigned long*)ptr != 0x9C23A008UL ) {
|
||||
fprintf(stderr, "freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
|
||||
@@ -490,6 +514,8 @@
|
||||
|
||||
/* Free the stable pointer first..*/
|
||||
freeStablePtr(*((StgStablePtr*)((unsigned long*)ptr + 11)));
|
||||
+ freeStablePtr(*((StgStablePtr*)((unsigned long*)ptr + 12)));
|
||||
+ return;
|
||||
#elif defined(alpha_TARGET_ARCH)
|
||||
if ( *(StgWord64*)ptr != 0xa77b0018a61b0010L ) {
|
||||
fprintf(stderr, "freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
|
||||
|
@ -1,10 +1,10 @@
|
||||
$OpenBSD: patch-ghc_rts_Linker_c,v 1.4 2003/09/01 20:32:14 espie Exp $
|
||||
$OpenBSD: patch-ghc_rts_Linker_c,v 1.5 2004/01/08 20:33:23 avsm Exp $
|
||||
sprintf.
|
||||
preliminary attempts to get object file loading working, so that
|
||||
ghci will work. Needs revisiting, to check all lib interfaces
|
||||
|
||||
--- ghc/rts/Linker.c.orig Wed Apr 30 07:37:31 2003
|
||||
+++ ghc/rts/Linker.c Sun Jul 6 21:29:55 2003
|
||||
--- ghc/rts/Linker.c.orig Fri May 30 08:40:51 2003
|
||||
+++ ghc/rts/Linker.c Fri Nov 7 12:32:30 2003
|
||||
@@ -59,7 +59,7 @@
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
@ -14,19 +14,7 @@ ghci will work. Needs revisiting, to check all lib interfaces
|
||||
# define OBJFORMAT_ELF
|
||||
#elif defined(cygwin32_TARGET_OS) || defined (mingw32_TARGET_OS)
|
||||
# define OBJFORMAT_PEi386
|
||||
@@ -724,7 +724,11 @@
|
||||
|
||||
initLinker();
|
||||
|
||||
+#if !defined(openbsd_TARGET_OS)
|
||||
hdl= dlopen(dll_name, RTLD_NOW | RTLD_GLOBAL);
|
||||
+#else
|
||||
+ hdl= dlopen(dll_name, RTLD_LAZY);
|
||||
+#endif
|
||||
if (hdl == NULL) {
|
||||
/* dlopen failed; return a ptr to the error msg. */
|
||||
errmsg = dlerror();
|
||||
@@ -763,10 +767,10 @@
|
||||
@@ -773,10 +773,10 @@
|
||||
extension. */
|
||||
|
||||
buf = stgMallocBytes(strlen(dll_name) + 10, "addDLL");
|
||||
@ -39,7 +27,7 @@ ghci will work. Needs revisiting, to check all lib interfaces
|
||||
instance = LoadLibrary(buf);
|
||||
if (instance == NULL) {
|
||||
stgFree(buf);
|
||||
@@ -2001,7 +2005,15 @@
|
||||
@@ -2011,7 +2011,15 @@
|
||||
# define ELF_NEED_PLT /* needs Procedure Linkage Tables */
|
||||
#endif
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
$OpenBSD: patch-ghc_rts_Makefile,v 1.3 2003/09/01 20:32:14 espie Exp $
|
||||
Tell the bootstrap code how to compile the .s file
|
||||
This code replaces the silly [] of code used in Adjustor.c
|
||||
|
||||
--- ghc/rts/Makefile.orig Thu Jul 24 22:17:59 2003
|
||||
+++ ghc/rts/Makefile Thu Aug 21 13:45:54 2003
|
||||
@@ -53,6 +53,10 @@
|
||||
HC_SRCS = $(filter %.hc, $(SRCS))
|
||||
HC_OBJS = $(patsubst %.hc,%.$(way_)o, $(HC_SRCS))
|
||||
|
||||
+C_OBJS += obscure_ccall.o
|
||||
+obscure_ccall.o :
|
||||
+ $(CC) -c obscure_ccall.s
|
||||
+
|
||||
CLEAN_FILES += $(HC_OBJS)
|
||||
|
||||
# Override the default $(LIBOBJS) (defaults to $(HS_OBJS))
|
@ -1,14 +0,0 @@
|
||||
$OpenBSD: patch-ghc_rts_obscure_ccall_s,v 1.3 2003/09/01 20:32:14 espie Exp $
|
||||
The assembly code to go in .text, replacing the opcodes for this
|
||||
code that were stored in an array in .data land, by a C hacker.
|
||||
See Adjustor.c
|
||||
|
||||
--- /dev/null Thu Jul 10 14:39:57 2003
|
||||
+++ ghc/rts/obscure_ccall.s Thu Jul 10 14:48:47 2003
|
||||
@@ -0,0 +1,6 @@
|
||||
+ .text
|
||||
+ .globl __obscure_ccall_ret_code
|
||||
+
|
||||
+__obscure_ccall_ret_code:
|
||||
+ addl $4, %esp
|
||||
+ ret
|
@ -1,13 +0,0 @@
|
||||
$OpenBSD: patch-mk_build_mk,v 1.3 2003/08/12 13:25:18 avsm Exp $
|
||||
SplitObjs are unnecessary (it splits object files up), and seems
|
||||
to use enormous amounts of memory, eventually stomping on my
|
||||
stack/data/file size ulimits when set, and dumping core. Solution
|
||||
: turn it off
|
||||
|
||||
Help ghc find libgmp.a
|
||||
|
||||
--- /dev/null Tue Aug 5 10:47:30 2003
|
||||
+++ mk/build.mk Tue Aug 5 10:51:30 2003
|
||||
@@ -0,0 +1,2 @@
|
||||
+SplitObjs=NO
|
||||
+SRC_HC_OPTS+=-L$(LOCALBASE)/lib
|
Loading…
Reference in New Issue
Block a user