[MLton] PowerPC .deb built

Wesley W. Terpstra wesley@terpstra.ca
Fri, 13 May 2005 02:57:00 +0200


--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

So, I found a machine with more than 1GB of ram running powerpc linux.
Cross-compiling MLton was pretty straight-forward.

The attached patch makes the following small adjustments:

1. The bytecode/*.c files included "platform.h" and defined ISOC99_SOURCE.
   When you took out this macro from runtime/* you missed those files
   (it's just a warning during compile is all)

2. Added powerpc, hppa, and sparc to the debian Architecture list
   ... my .debs pass (more or less) the regressions on these platforms
   Should I NMU them now, or wait till you next release MLton?
   I am just a bit nervous b/c I thought I'd lost them today. ;)
   They are not (for obvious reasons) built from the 20041109 source

3. On linux, powerpc is __powerpc__ not __ppc__ like under MacOS X

4. The unhelpful error checking /,% hit me again.
   How often is it really the case that these operations will be wrong?
   Is there even one platform where this is a concern?
   If you don't remove it, please add __powerpc__ and __parisc__

5. I went digging through the kaffe source and copied it's definitions
   for accessing the instruction pointer for each platform except m68k. How
   can I test whether this is actually working? It compiled on all of the
   four platforms I have access to that have enough RAM anyways. :-)

PS. powerpc/linux does fail one unusual regression:

testing kitsimple
22c22,23
< ~61403
---
> ~61402
> *** ERROR ***
difference with -type-check true

Oh yeah, could you please ask whoever holds the repository for MLton cvs to
remove the obsolete directory regression/modules? Because there is a
regression of the same name, an unpruned checkout fails.

As I send this email, I am running a full rebuild on sparc and hppa with the
latest CVS+the above patch. The runtime built fine like I said; however, I
will need to wait two days before the complete build finishes. =)

-- 
Wesley W. Terpstra <wesley@terpstra.ca>

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="powerpc.patch"

Index: bytecode/interpret.c
===================================================================
RCS file: /cvsroot/mlton/mlton/bytecode/interpret.c,v
retrieving revision 1.25
diff -u -r1.25 interpret.c
--- bytecode/interpret.c	22 Dec 2004 05:11:24 -0000	1.25
+++ bytecode/interpret.c	12 May 2005 23:59:45 -0000
@@ -1,8 +1,6 @@
-#define _ISOC99_SOURCE
-
+#include "platform.h"
 #include <stdint.h>
 #include "interpret.h"
-#include "platform.h"
 #include "c-chunk.h"	// c-chunk.h must come before opcode.h because it
 			// redefines some opcode symbols
 #include "opcode.h"
Index: bytecode/print-opcodes.c
===================================================================
RCS file: /cvsroot/mlton/mlton/bytecode/print-opcodes.c,v
retrieving revision 1.4
diff -u -r1.4 print-opcodes.c
--- bytecode/print-opcodes.c	22 Dec 2004 05:11:24 -0000	1.4
+++ bytecode/print-opcodes.c	12 May 2005 23:59:45 -0000
@@ -1,7 +1,5 @@
-#define _ISOC99_SOURCE
-
-#include <stdio.h>
 #include "platform.h"
+#include <stdio.h>
 #include "opcode.h"
 
 int main () {
Index: debian/control
===================================================================
RCS file: /cvsroot/mlton/mlton/debian/control,v
retrieving revision 1.15
diff -u -r1.15 control
--- debian/control	28 Jun 2004 21:59:49 -0000	1.15
+++ debian/control	12 May 2005 23:59:45 -0000
@@ -6,7 +6,7 @@
 Standards-Version: 3.6.1
 
 Package: mlton
-Architecture: i386
+Architecture: i386, powerpc, hppa, sparc
 Depends: ${shlibs:Depends}, gcc, libgmp3-dev (>= 4.0.1)
 Description: Optimizing compiler for Standard ML
  MLton (www.mlton.org) is a whole-program
Index: runtime/platform.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform.h,v
retrieving revision 1.23
diff -u -r1.23 platform.h
--- runtime/platform.h	3 May 2005 21:28:42 -0000	1.23
+++ runtime/platform.h	12 May 2005 23:59:47 -0000
@@ -418,7 +418,7 @@
 #define MLton_Platform_Arch_host "m68k"
 #elif (defined (__mips__))
 #define MLton_Platform_Arch_host "mips"
-#elif (defined (__ppc__))
+#elif (defined (__ppc__)) || (defined (__powerpc__))
 #define MLton_Platform_Arch_host "powerpc"
 #elif (defined (__s390__))
 #define MLton_Platform_Arch_host "s390"
Index: runtime/basis/Int/Word.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Int/Word.c,v
retrieving revision 1.7
diff -u -r1.7 Word.c
--- runtime/basis/Int/Word.c	22 Apr 2005 18:13:48 -0000	1.7
+++ runtime/basis/Int/Word.c	12 May 2005 23:59:47 -0000
@@ -28,10 +28,6 @@
 #define DEBUG FALSE
 #endif
 
-#if ! (defined (__i386__) || defined (__ppc__) || defined (__sparc__))
-#error check that C {/,%} correctly implement {quot,rem} from the basis library
-#endif
-
 #define coerce(f, t)				\
 	t f##_to##t (f x) {			\
 		return (t)x;			\
Index: runtime/platform/linux.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/linux.c,v
retrieving revision 1.8
diff -u -r1.8 linux.c
--- runtime/platform/linux.c	23 Dec 2004 20:07:50 -0000	1.8
+++ runtime/platform/linux.c	12 May 2005 23:59:47 -0000
@@ -13,9 +13,57 @@
 #define EIP	14
 #endif
 
-static void catcher (int sig, siginfo_t *sip, ucontext_t *ucp) {
+/* The locations of the EIP equivalent register found in kaffe */
+#if (defined (__alpha__))
+static void catcher (int sig, siginfo_t *sip, struct sigcontext* scp) {
+	GC_handleSigProf ((pointer) scp->sc_pc);
+}
+#elif (defined (__x86_64__))
+#define REG_INDEX(NAME) (offsetof(struct sigcontext, NAME) / sizeof(greg_t))
+#ifndef REG_RIP
+#define REG_RIP REG_INDEX(rip) /* seems to be 16 */
+#endif
+static void catcher (int sig, siginfo_t *sip, ucontext_t* ucp) {
+	GC_handleSigProf ((pointer) ucp->uc_mcontext.gregs[REG_RIP]);
+}
+#elif (defined (__arm__))
+static void catcher (int sig, int arm1, int arm2, int arm3, struct sigcontext ctx) {
+	GC_handleSigProf ((pointer) ctx.arm_pc);
+}
+#elif (defined (__hppa__))
+static void catcher (int sig, siginfo_t *sip, ucontext_t* ucp) {
+	GC_handleSigProf ((pointer) ucp->uc_mcontext.sc_iaoq[0]);
+}
+#elif (defined (__ia64__))
+static void catcher (int sig, siginfo_t *sip, struct sigcontext* scp) {
+	GC_handleSigProf ((pointer) scp->sc_ip & ~0x3ULL);
+}
+#elif (defined (__m68k__))
+#error Eek - how to get EIP without assembler on m68k?	
+#elif (defined (__mips__))
+static void catcher (int sig, int dummy, struct sigcontext* scp) {
+	GC_handleSigProf ((pointer) scp->sc_pc);
+}
+#elif (defined (__ppc__)) || (defined (__powerpc__))
+static void catcher (int sig, struct sigcontext* scp) {
+	GC_handleSigProf ((pointer) scp->regs->nip);
+}
+#elif (defined (__s390__))
+static void catcher (int sig, struct sigcontext sc) {
+	GC_handleSigProf ((pointer) sc.sregs->regs.psw.addr);
+}
+#elif (defined (__sparc__))
+static void catcher (int sig, struct sigcontext* scp) {
+	GC_handleSigProf ((pointer) scp->si_regs.pc);
+//64bit	GC_handleSigProf ((pointer) scp->sigc_regs.tpc);
+}
+#elif (defined (__i386__))
+static void catcher (int sig, struct sigcontext* scp, ucontext_t* ucp) {
 	GC_handleSigProf ((pointer) ucp->uc_mcontext.gregs[EIP]);
 }
+#else
+#error Profiling handler is missing for this architecture
+#endif
 
 void setSigProfHandler (struct sigaction *sa) {
 	sa->sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
Index: runtime/platform/linux.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/linux.h,v
retrieving revision 1.9
diff -u -r1.9 linux.h
--- runtime/platform/linux.h	3 May 2005 20:16:49 -0000	1.9
+++ runtime/platform/linux.h	12 May 2005 23:59:47 -0000
@@ -23,11 +23,7 @@
 #define HAS_REMAP TRUE
 #define HAS_SIGALTSTACK TRUE
 #define HAS_SPAWN FALSE
-#ifdef __i386__
 #define HAS_TIME_PROFILING TRUE
-#else
-#define HAS_TIME_PROFILING FALSE
-#endif
 #define HAS_WEAK TRUE
 
 #define MLton_Platform_OS_host "linux"

--J2SCkAp4GZ/dPZZf--