NeXT Computers Forum Index NeXT Computers
www.NeXTComputers.org
 
Log in to check your private messagesLog in to check your private messages

Log inLog in  RegisterRegister


Profile  Search  Memberlist  FAQ  Usergroups
Windows to Rhapsody (maybe even NS/OS) cross compiler

 
Post new topic   Reply to topic    NeXT Computers Forum Index -> Porting New Software
View previous topic :: View next topic  
Author Message
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Wed Jun 14, 2017 10:54 pm    Post subject: Windows to Rhapsody (maybe even NS/OS) cross compiler Reply with quote

I picked up a copy of OPENSTEP NT off of Rob, and hammered it's GCC to compile under OPENSTEP NT PDO, and to cross compile...

Just took the first step.

Code:
C:\NeXT\NextDeveloper\Source\GNU\yy>type ..\hanoi.c| cc1obj.exe -arch i386 -quiet -dumpbase hanoi.c -version -dynamic -fPIC -o ..\h_cross.s
GNU Obj-C version 2.7.2.1 (80386, BSD syntax) compiled by GNU C version 2.6.1.


It is a very simple tower of hanoi I googled from somewhere and gutted to it's core

Code:
void move( m, a, b)
int m;
int a;
int b;
{
int c;
if(m==1)
        {
        putchar(a+48);
        putchar(' ');
        putchar(b+48);
        putchar(13);
        putchar(10);
        }
else
        {
        c=6-a-b;
        move(m-1,a,c);
        move(1,a,b);
        move(m-1,c,b);
        }
}

void main()
{
move(3,1,2);
}


And I get this assembly:


Code:
.text
   .align 2,0x90
.globl _move
_move:
   pushl %ebp
   movl %esp,%ebp
   subl $4,%esp
   pushl %ebx
   cmpl $1,8(%ebp)
   jne L2
   movl 12(%ebp),%eax
   addl $48,%eax
   pushl %eax
   call L_putchar$stub
   addl $4,%esp
   pushl $32
   call L_putchar$stub
   addl $4,%esp
   movl 16(%ebp),%eax
   addl $48,%eax
   pushl %eax
   call L_putchar$stub
   addl $4,%esp
   pushl $13
   call L_putchar$stub
   addl $4,%esp
   pushl $10
   call L_putchar$stub
   addl $4,%esp
   jmp L3
   .align 2,0x90
L2:
   movl $6,%eax
   subl 16(%ebp),%eax
   movl %eax,%edx
   subl 12(%ebp),%edx
   movl %edx,-4(%ebp)
   movl -4(%ebp),%edx
   pushl %edx
   movl 12(%ebp),%edx
   pushl %edx
   movl 8(%ebp),%eax
   decl %eax
   pushl %eax
   call _move
   addl $12,%esp
   movl 16(%ebp),%edx
   pushl %edx
   movl 12(%ebp),%edx
   pushl %edx
   pushl $1
   call _move
   addl $12,%esp
   movl 16(%ebp),%edx
   pushl %edx
   movl -4(%ebp),%edx
   pushl %edx
   movl 8(%ebp),%eax
   decl %eax
   pushl %eax
   call _move
   addl $12,%esp
L3:
L1:
   movl -8(%ebp),%ebx
   movl %ebp,%esp
   popl %ebp
   ret
   .align 2,0x90
.globl _main
_main:
   pushl %ebp
   movl %esp,%ebp
   pushl %ebx
   pushl $2
   pushl $1
   pushl $3
   call _move
   addl $12,%esp
L4:
   movl -4(%ebp),%ebx
   movl %ebp,%esp
   popl %ebp
   ret
.picsymbol_stub
L_putchar$stub:
   .indirect_symbol _putchar
   call LPC$1
LPC$1:   popl %eax
   movl L_putchar$lazy_ptr-LPC$1(%eax),%edx
   jmp %edx
L_putchar$stub_binder:
   lea L_putchar$lazy_ptr-LPC$1(%eax),%eax
   pushl %eax
   jmp dyld_stub_binding_helper
.lazy_symbol_pointer
L_putchar$lazy_ptr:
   .indirect_symbol _putchar
   .long L_putchar$stub_binder


And the best part!

I copy the assembly up to my Rhapsody vmware instance and go ahead and run the assembler, and linker... and it runs!

Code:
[darwin:/tmp] root# cc -v h_cross.s -o h
Reading specs from /usr/libexec/i386/2.7.2.1/specs
Apple Computer, Inc. version cc-1, based on gcc version 2.7.2.1
 /usr/libexec/i386/2.7.2.1/cpp -lang-asm -v -undef -$ -Di386 -D__MACH__ -D__LITTLE_ENDIAN__ -D__ARCHITECTURE__="i386" -D__APPLE__ -D__i386__ -D__MACH__ -D__LITTLE_ENDIAN__ -D__ARCHITECTURE__="i386" -D__APPLE__ -D__i386 -D__ASSEMBLER__ -D__STDC__ -D__APPLE_CC__=1 -D__DYNAMIC__ h_cross.s /var/tmp/cc023370.s
GNU CPP version 2.6.3 (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
 /System/Library/Frameworks/System.framework/PrivateHeaders
 /System/Library/Frameworks/System.framework/PrivateHeaders/bsd
 /System/Library/Frameworks/System.framework/Headers
 /usr/include
 /usr/local/include
End of search list.
 /usr/libexec/i386/as -arch i386 -o /var/tmp/cc023370-h_cross.o /var/tmp/cc023370.s
 /usr/bin/ld -arch i386 -o h -dynamic -lcrt1.o /var/tmp/cc023370-h_cross.o -lcc_dynamic -framework System
[darwin:/tmp] root# ./h
1 2
1 3
2 3
1 2
3 1
3 2
1 2


Of course someone will ask why, and the answer is that I hope to get the full toolchain running on Windows so I can use all the cores in my host machine...
_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Wed Jun 14, 2017 11:12 pm    Post subject: Reply with quote

Oh yeah diff for GCC using the version inside OPENSTEP 4.2 for NT

Code:
diff -ruN gcc/calls.c gcc_hacked/calls.c
--- gcc/calls.c   Thu Feb 01 04:08:18 1996
+++ gcc_hacked/calls.c   Thu Jun 15 12:49:03 2017
@@ -18,6 +18,9 @@
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#warning "defined NEXT_PDO"
+#define NEXT_PDO 1
+
 #include "config.h"
 #include "rtl.h"
 #include "tree.h"
diff -ruN gcc/expr.c gcc_hacked/expr.c
--- gcc/expr.c   Fri Dec 13 01:37:20 1996
+++ gcc_hacked/expr.c   Thu Jun 15 13:10:43 2017
@@ -18,7 +18,8 @@
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-
+#warning "hardcoding NEXT_PDO"
+#define NEXT_PDO 1
 #include "config.h"
 #include "machmode.h"
 #include "rtl.h"
diff -ruN gcc/toplev.c gcc_hacked/toplev.c
--- gcc/toplev.c   Tue Jan 21 09:26:38 1997
+++ gcc_hacked/toplev.c   Thu Jun 15 13:59:04 2017
@@ -4402,7 +4402,9 @@
   
   if (! valid)
     {
-      NXArchInfo *info = (NXArchInfo*) NXGetAllArchInfos ();
+//      NXArchInfo *info = (NXArchInfo*) NXGetAllArchInfos ();
+#warning "making a guess about NXGetAllArchInfos"
+      NXArchInfo *info = "i386";
       register int j;
       
       for (j = 0; info[j].name; j++)


Currently only the compilers themselves will build, no driver, nor pre-processor.

Code:
sh ..\gcc\configure --srcdir=/NeXT/NextDeveloper/Source/GNU/gcc --host=i386-nextpdo-winnt3.5 --target=i386-next-nextstep3

_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Thu Jun 15, 2017 5:02 am    Post subject: Reply with quote

After a bit of fighting with cctools, I got the i386 assembler 'working' ....


Code:
C:\NeXT\NextDeveloper\Source\GNU\c2\cctools-2\as>a386_dir\as -v hanoi.s -o hanoi.o
Apple Computer, Inc. version -f-, GNU assembler version 1.38

C:\NeXT\NextDeveloper\Source\GNU\c2\cctools-2\as>copy hanoi.o s:\darwin\xx\hanoi2.o
        1 file(s) copied.


Running the linker from Darwin:

Code:
[darwin:/tmp/jj] root# cc -v /mnt/data/darwin/xx/hanoi2.o -o hanoi
Reading specs from /usr/libexec/i386/2.7.2.1/specs
Apple Computer, Inc. version cc-1, based on gcc version 2.7.2.1
 /usr/bin/ld -arch i386 -o hanoi -dynamic -lcrt1.o /mnt/data/darwin/xx/hanoi2.o -lcc_dynamic -framework System
[darwin:/tmp/jj] root# ./hanoi
1 2
1 3
2 3
1 2
3 1
3 2
1 2

_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Thu Jun 15, 2017 5:07 am    Post subject: Reply with quote

much more substantial changes.

This is against the cc-tools from Darwin 0.3 Some of the files, like make.h makeUser.h were generated on Darwin using it's MIG, which I haven't even attempted to port yet. I don't think I really want to go there right now.

At this point I wonder if the linker will run, but I suspect under OPENSTEP is it's best bet.


Code:

diff -ruN cctools-2/as/Makefile cctools-hacked/as/Makefile
--- cctools-2/as/Makefile   Sat May 08 01:45:40 1999
+++ cctools-hacked/as/Makefile   Thu Jun 15 19:39:51 2017
@@ -1,6 +1,6 @@
 OFLAG = -O
 ifneq "mwcc" "$(notdir $(CC))"
-  GCC_FLAGS = -Wall -Wno-precomp
+  GCC_FLAGS =-DNeXT #-Wall -Wno-precomp
 endif
 CFLAGS = $(OFLAG) -g -I$(SRCROOT) -I$(SRCROOT)/../include -I$(OFILE_DIR) \
    $(GCC_FLAGS) -DNeXT_MOD \
@@ -11,7 +11,7 @@
 ifneq "" "$(wildcard /bin/mkdirs)"
   MKDIRS = /bin/mkdirs
 else
-  MKDIRS = /bin/mkdir -p
+  MKDIRS = mkdir -p
 endif
 
 MIG = $(NEXT_ROOT)/usr/bin/mig
@@ -253,16 +253,18 @@
       $(OFILE_DIR)/driver.o $(OFILE_DIR)/apple_version.o $(LIBSTUFF)
 
 as:   $(OBJS) $(TARGET_OBJS) makeUser.o
-   $(CC) $(COPTS) $(CFLAGS) $(RC_CFLAGS) -nostdlib -r \
-      -o $(SYMROOT)/as.private.o $(OBJS) $(TARGET_OBJS) \
-      makeUser.o $(LIBSTUFF)
-   $(CC) $(CFLAGS) $(RC_CFLAGS) -o $(SYMROOT)/as $(SYMROOT)/as.private.o
+   $(CC) -v $(COPTS) $(CFLAGS) $(RC_CFLAGS) $(OBJS) $(TARGET_OBJS) makeUser.o ../../libstuff/libstuff.a -o as
+#   $(CC) $(COPTS) $(CFLAGS) $(RC_CFLAGS) -nostdlib -r \
+#      -o $(SYMROOT)/as.private.o $(OBJS) $(TARGET_OBJS) \
+#      makeUser.o $(LIBSTUFF)
+#   $(CC) $(CFLAGS) $(RC_CFLAGS) -o $(SYMROOT)/as $(SYMROOT)/as.private.o
 
 makeUser.c messages.c: make.h
 
 make.h makeUser.c: make.defs
-   $(MIG) $(MIG_FLAGS) $(SRCROOT)/make.defs
-   rm -f makeServer.c
+   echo copy_make.h_from_somewhere_else
+#   $(MIG) $(MIG_FLAGS) $(SRCROOT)/make.defs
+#   rm -f makeServer.c
 
 m68k-check:
    $(CC) $(COPTS) $(CFLAGS) -o check ../m68k-check.c
@@ -301,7 +303,7 @@
 .c.o:
    $(CC) $(COPTS) $(CFLAGS) $(RC_CFLAGS) -c -MD \
       -dependency-file $(OFILE_DIR)/$*.d -o $(OFILE_DIR)/$*.o $<
-   md -d -u $(OFILE_DIR)/Makedep $(OFILE_DIR)/$*.d
+#   md -d -u $(OFILE_DIR)/Makedep $(OFILE_DIR)/$*.d
 
 clean shlib_clean:
    -rm -r -f $(OFILE_DIRS) make.out
diff -ruN cctools-2/as/as.c cctools-hacked/as/as.c
--- cctools-2/as/as.c   Sat May 08 01:45:41 1999
+++ cctools-hacked/as/as.c   Thu Jun 15 19:08:30 2017
@@ -79,7 +79,7 @@
 /*
  * The list of signals to catch if not ignored.
  */
-static int sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM, 0};
+static int sig[] = { SIGINT, SIGTERM, 0};
 static void got_sig(
     int sig);
 
diff -ruN cctools-2/as/driver.c cctools-hacked/as/driver.c
--- cctools-2/as/driver.c   Sat May 08 01:45:59 1999
+++ cctools-hacked/as/driver.c   Thu Jun 15 19:04:47 2017
@@ -9,7 +9,7 @@
 #include "stdio.h"
 #include "stdlib.h"
 #include "string.h"
-#include "libc.h"
+//#include "libc.h"
 #include <sys/file.h>
 #include <mach/mach.h>
 #include "stuff/arch.h"
diff -ruN cctools-2/as/i386.c cctools-hacked/as/i386.c
--- cctools-2/as/i386.c   Sat May 08 01:45:47 1999
+++ cctools-hacked/as/i386.c   Thu Jun 15 19:49:45 2017
@@ -46,6 +46,8 @@
 #include "sections.h"
 #include "input-scrub.h"
 
+#define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0)
+
 /*
  * These are the default cputype and cpusubtype for the i386 architecture.
  */
diff -ruN cctools-2/as/i386.h cctools-hacked/as/i386.h
--- cctools-2/as/i386.h   Sat May 08 01:45:54 1999
+++ cctools-hacked/as/i386.h   Thu Jun 15 19:11:25 2017
@@ -140,6 +140,8 @@
 typedef unsigned int uint;
 #endif
 
+typedef unsigned int uint;
+
 typedef struct {
   /* instruction name sans width suffix ("mov" for movl insns) */
   char          *name;
diff -ruN cctools-2/as/input-file.c cctools-hacked/as/input-file.c
--- cctools-2/as/input-file.c   Sat May 08 01:45:43 1999
+++ cctools-hacked/as/input-file.c   Thu Jun 15 19:52:45 2017
@@ -30,7 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
-#include <libc.h>
+//#include <libc.h>
 #include "input-file.h"
 #include "xmalloc.h"
 #include "input-scrub.h"
@@ -37,6 +37,24 @@
 #include "app.h"
 #include "as.h"
 
+#define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0)
+
+
+#include <string.h>
+char *
+index(const char *p, int ch)
+{
+   for (;; ++p) {
+      if (*p == ch)
+         return((char *)p);
+      if (!*p)
+         return((char *)NULL);
+   }
+   /* NOTREACHED */
+}
+
+
+
 /*
  * This variable is non-zero if the file currently being read should be
  * preprocessed by app.  It is zero if the file can be read straight in.
@@ -122,9 +140,10 @@
       return;
    }
 #ifdef NeXT_MOD   /* .include feature */
-   setbuffer(f_in, xmalloc(BUFFER_SIZE), BUFFER_SIZE);
+#warning no setbuffer!!
+//   setbuffer(f_in, xmalloc(BUFFER_SIZE), BUFFER_SIZE);
 #else
-   setbuffer(f_in,in_buf,BUFFER_SIZE);
+//   setbuffer(f_in,in_buf,BUFFER_SIZE);
 #endif
    c=getc(f_in);
    if(c=='#') {   /* Begins with comment, may not want to preprocess */
diff -ruN cctools-2/as/input-scrub.c cctools-hacked/as/input-scrub.c
--- cctools-2/as/input-scrub.c   Sat May 08 01:45:43 1999
+++ cctools-hacked/as/input-scrub.c   Thu Jun 15 19:48:40 2017
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#include <libc.h>
+//#include <libc.h>
 #ifdef NeXT_MOD   /* .include feature */
 #include <sys/file.h>
 #include <sys/param.h>
@@ -33,6 +33,8 @@
 #include "xmalloc.h"
 #include "messages.h"
 
+#define access _access
+
 /*
  * O/S independent module to supply buffers of sanitised source code
  * to rest of assembler. We get raw input data of some length.
@@ -273,7 +275,8 @@
     char *p, *q;
     static char directory_buf[MAXPATHLEN];
 
-   getwd(directory_buf);
+#warning as_where_ProjectBuilder
+//   getwd(directory_buf);
    *fileName = NULL;
    *directory = directory_buf;
    *line = 0;
diff -ruN cctools-2/as/make.h cctools-hacked/as/make.h
--- cctools-2/as/make.h
+++ cctools-hacked/as/make.h   Thu Jun 15 18:37:27 2017
@@ -0,0 +1,43 @@
+#ifndef   _make_make
+#define   _make_make
+
+/* Module make */
+
+#include <mach/kern_return.h>
+#include <mach/port.h>
+#include <mach/message.h>
+
+#ifndef   mig_external
+#define mig_external extern
+#endif
+
+#include <mach/std_types.h>
+#include "make_defs.h"
+
+/* SimpleRoutine make_alert_old */
+mig_external kern_return_t make_alert_old (
+   port_t makePort,
+   int eventType,
+   make_string_t functionName,
+   unsigned int functionNameCnt,
+   make_string_t fileName,
+   unsigned int fileNameCnt,
+   int line,
+   make_string_t message,
+   unsigned int messageCnt);
+
+/* SimpleRoutine make_alert */
+mig_external kern_return_t make_alert (
+   port_t makePort,
+   int eventType,
+   make_string_t functionName,
+   unsigned int functionNameCnt,
+   make_string_t fileName,
+   unsigned int fileNameCnt,
+   make_string_t directory,
+   unsigned int directoryCnt,
+   int line,
+   make_string_t message,
+   unsigned int messageCnt);
+
+#endif   /* _make_make */
diff -ruN cctools-2/as/makeUser.c cctools-hacked/as/makeUser.c
--- cctools-2/as/makeUser.c
+++ cctools-hacked/as/makeUser.c   Thu Jun 15 19:50:20 2017
@@ -0,0 +1,458 @@
+#include "make.h"
+#include <mach/mach_types.h>
+#include <mach/message.h>
+#include <mach/mig_errors.h>
+#include <mach/msg_type.h>
+#if   !defined(KERNEL) && !defined(MIG_NO_STRINGS)
+#include <strings.h>
+#endif
+/* LINTLIBRARY */
+
+#define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0)
+
+extern port_t mig_get_reply_port();
+extern void mig_dealloc_reply_port();
+
+#ifndef   mig_internal
+#define   mig_internal   static
+#endif
+
+#ifndef   TypeCheck
+#define   TypeCheck 1
+#endif
+
+#ifndef   UseExternRCSId
+#ifdef   hc
+#define   UseExternRCSId      1
+#endif
+#endif
+
+#ifndef   UseStaticMsgType
+#if   !defined(hc) || defined(__STDC__)
+#define   UseStaticMsgType   1
+#endif
+#endif
+
+#define msg_request_port   msg_remote_port
+#define msg_reply_port      msg_local_port
+
+
+/* SimpleRoutine alert_old */
+mig_external kern_return_t make_alert_old (
+   port_t makePort,
+   int eventType,
+   make_string_t functionName,
+   unsigned int functionNameCnt,
+   make_string_t fileName,
+   unsigned int fileNameCnt,
+   int line,
+   make_string_t message,
+   unsigned int messageCnt)
+{
+   typedef struct {
+      msg_header_t Head;
+      msg_type_t eventTypeType;
+      int eventType;
+      msg_type_t functionNameType;
+      char functionName[1024];
+      msg_type_t fileNameType;
+      char fileName[1024];
+      msg_type_t lineType;
+      int line;
+      msg_type_t messageType;
+      char message[1024];
+   } Request;
+
+   union {
+      Request In;
+   } Mess;
+
+   register Request *InP = &Mess.In;
+
+   unsigned int msg_size = 52;
+   /* Maximum request size 3124 */
+   unsigned int msg_size_delta;
+
+#if   UseStaticMsgType
+   static const msg_type_t eventTypeType = {
+      /* msg_type_name = */      MSG_TYPE_INTEGER_32,
+      /* msg_type_size = */      32,
+      /* msg_type_number = */      1,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   static const msg_type_t functionNameType = {
+      /* msg_type_name = */      MSG_TYPE_CHAR,
+      /* msg_type_size = */      8,
+      /* msg_type_number = */      1024,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   static const msg_type_t fileNameType = {
+      /* msg_type_name = */      MSG_TYPE_CHAR,
+      /* msg_type_size = */      8,
+      /* msg_type_number = */      1024,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   static const msg_type_t lineType = {
+      /* msg_type_name = */      MSG_TYPE_INTEGER_32,
+      /* msg_type_size = */      32,
+      /* msg_type_number = */      1,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   static const msg_type_t messageType = {
+      /* msg_type_name = */      MSG_TYPE_CHAR,
+      /* msg_type_size = */      8,
+      /* msg_type_number = */      1024,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   InP->eventTypeType = eventTypeType;
+#else   /* UseStaticMsgType */
+   InP->eventTypeType.msg_type_name = MSG_TYPE_INTEGER_32;
+   InP->eventTypeType.msg_type_size = 32;
+   InP->eventTypeType.msg_type_number = 1;
+   InP->eventTypeType.msg_type_inline = TRUE;
+   InP->eventTypeType.msg_type_longform = FALSE;
+   InP->eventTypeType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   InP->eventType /* eventType */ = /* eventType */ eventType;
+
+#if   UseStaticMsgType
+   InP->functionNameType = functionNameType;
+#else   /* UseStaticMsgType */
+   InP->functionNameType.msg_type_name = MSG_TYPE_CHAR;
+   InP->functionNameType.msg_type_size = 8;
+   InP->functionNameType.msg_type_inline = TRUE;
+   InP->functionNameType.msg_type_longform = FALSE;
+   InP->functionNameType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   if (functionNameCnt > 1024)
+      return MIG_ARRAY_TOO_LARGE;
+   bcopy((char *) functionName, (char *) InP->functionName, 1 * functionNameCnt);
+
+   InP->functionNameType.msg_type_number /* functionNameCnt */ = /* functionNameType.msg_type_number */ functionNameCnt;
+
+   msg_size_delta = (1 * functionNameCnt + 3) & ~3;
+   msg_size += msg_size_delta;
+   InP = (Request *) ((char *) InP + msg_size_delta - 1024);
+
+#if   UseStaticMsgType
+   InP->fileNameType = fileNameType;
+#else   /* UseStaticMsgType */
+   InP->fileNameType.msg_type_name = MSG_TYPE_CHAR;
+   InP->fileNameType.msg_type_size = 8;
+   InP->fileNameType.msg_type_inline = TRUE;
+   InP->fileNameType.msg_type_longform = FALSE;
+   InP->fileNameType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   if (fileNameCnt > 1024)
+      return MIG_ARRAY_TOO_LARGE;
+   bcopy((char *) fileName, (char *) InP->fileName, 1 * fileNameCnt);
+
+   InP->fileNameType.msg_type_number /* fileNameCnt */ = /* fileNameType.msg_type_number */ fileNameCnt;
+
+   msg_size_delta = (1 * fileNameCnt + 3) & ~3;
+   msg_size += msg_size_delta;
+   InP = (Request *) ((char *) InP + msg_size_delta - 1024);
+
+#if   UseStaticMsgType
+   InP->lineType = lineType;
+#else   /* UseStaticMsgType */
+   InP->lineType.msg_type_name = MSG_TYPE_INTEGER_32;
+   InP->lineType.msg_type_size = 32;
+   InP->lineType.msg_type_number = 1;
+   InP->lineType.msg_type_inline = TRUE;
+   InP->lineType.msg_type_longform = FALSE;
+   InP->lineType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   InP->line /* line */ = /* line */ line;
+
+#if   UseStaticMsgType
+   InP->messageType = messageType;
+#else   /* UseStaticMsgType */
+   InP->messageType.msg_type_name = MSG_TYPE_CHAR;
+   InP->messageType.msg_type_size = 8;
+   InP->messageType.msg_type_inline = TRUE;
+   InP->messageType.msg_type_longform = FALSE;
+   InP->messageType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   if (messageCnt > 1024)
+      return MIG_ARRAY_TOO_LARGE;
+   bcopy((char *) message, (char *) InP->message, 1 * messageCnt);
+
+   InP->messageType.msg_type_number /* messageCnt */ = /* messageType.msg_type_number */ messageCnt;
+
+   msg_size_delta = (1 * messageCnt + 3) & ~3;
+   msg_size += msg_size_delta;
+
+   InP = &Mess.In;
+   InP->Head.msg_simple = TRUE;
+   InP->Head.msg_size = msg_size;
+   InP->Head.msg_type = MSG_TYPE_NORMAL;
+   InP->Head.msg_request_port = makePort;
+   InP->Head.msg_reply_port = PORT_NULL;
+   InP->Head.msg_id = 100;
+
+   return msg_send(&InP->Head, MSG_OPTION_NONE, 0);
+}
+
+/* SimpleRoutine alert */
+mig_external kern_return_t make_alert (
+   port_t makePort,
+   int eventType,
+   make_string_t functionName,
+   unsigned int functionNameCnt,
+   make_string_t fileName,
+   unsigned int fileNameCnt,
+   make_string_t directory,
+   unsigned int directoryCnt,
+   int line,
+   make_string_t message,
+   unsigned int messageCnt)
+{
+   typedef struct {
+      msg_header_t Head;
+      msg_type_t eventTypeType;
+      int eventType;
+      msg_type_t functionNameType;
+      char functionName[1024];
+      msg_type_t fileNameType;
+      char fileName[1024];
+      msg_type_t directoryType;
+      char directory[1024];
+      msg_type_t lineType;
+      int line;
+      msg_type_t messageType;
+      char message[1024];
+   } Request;
+
+   union {
+      Request In;
+   } Mess;
+
+   register Request *InP = &Mess.In;
+
+   unsigned int msg_size = 56;
+   /* Maximum request size 4152 */
+   unsigned int msg_size_delta;
+
+#if   UseStaticMsgType
+   static const msg_type_t eventTypeType = {
+      /* msg_type_name = */      MSG_TYPE_INTEGER_32,
+      /* msg_type_size = */      32,
+      /* msg_type_number = */      1,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   static const msg_type_t functionNameType = {
+      /* msg_type_name = */      MSG_TYPE_CHAR,
+      /* msg_type_size = */      8,
+      /* msg_type_number = */      1024,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   static const msg_type_t fileNameType = {
+      /* msg_type_name = */      MSG_TYPE_CHAR,
+      /* msg_type_size = */      8,
+      /* msg_type_number = */      1024,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   static const msg_type_t directoryType = {
+      /* msg_type_name = */      MSG_TYPE_CHAR,
+      /* msg_type_size = */      8,
+      /* msg_type_number = */      1024,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   static const msg_type_t lineType = {
+      /* msg_type_name = */      MSG_TYPE_INTEGER_32,
+      /* msg_type_size = */      32,
+      /* msg_type_number = */      1,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   static const msg_type_t messageType = {
+      /* msg_type_name = */      MSG_TYPE_CHAR,
+      /* msg_type_size = */      8,
+      /* msg_type_number = */      1024,
+      /* msg_type_inline = */      TRUE,
+      /* msg_type_longform = */   FALSE,
+      /* msg_type_deallocate = */   FALSE,
+      /* msg_type_unused = */      0,
+   };
+#endif   /* UseStaticMsgType */
+
+#if   UseStaticMsgType
+   InP->eventTypeType = eventTypeType;
+#else   /* UseStaticMsgType */
+   InP->eventTypeType.msg_type_name = MSG_TYPE_INTEGER_32;
+   InP->eventTypeType.msg_type_size = 32;
+   InP->eventTypeType.msg_type_number = 1;
+   InP->eventTypeType.msg_type_inline = TRUE;
+   InP->eventTypeType.msg_type_longform = FALSE;
+   InP->eventTypeType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   InP->eventType /* eventType */ = /* eventType */ eventType;
+
+#if   UseStaticMsgType
+   InP->functionNameType = functionNameType;
+#else   /* UseStaticMsgType */
+   InP->functionNameType.msg_type_name = MSG_TYPE_CHAR;
+   InP->functionNameType.msg_type_size = 8;
+   InP->functionNameType.msg_type_inline = TRUE;
+   InP->functionNameType.msg_type_longform = FALSE;
+   InP->functionNameType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   if (functionNameCnt > 1024)
+      return MIG_ARRAY_TOO_LARGE;
+   bcopy((char *) functionName, (char *) InP->functionName, 1 * functionNameCnt);
+
+   InP->functionNameType.msg_type_number /* functionNameCnt */ = /* functionNameType.msg_type_number */ functionNameCnt;
+
+   msg_size_delta = (1 * functionNameCnt + 3) & ~3;
+   msg_size += msg_size_delta;
+   InP = (Request *) ((char *) InP + msg_size_delta - 1024);
+
+#if   UseStaticMsgType
+   InP->fileNameType = fileNameType;
+#else   /* UseStaticMsgType */
+   InP->fileNameType.msg_type_name = MSG_TYPE_CHAR;
+   InP->fileNameType.msg_type_size = 8;
+   InP->fileNameType.msg_type_inline = TRUE;
+   InP->fileNameType.msg_type_longform = FALSE;
+   InP->fileNameType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   if (fileNameCnt > 1024)
+      return MIG_ARRAY_TOO_LARGE;
+   bcopy((char *) fileName, (char *) InP->fileName, 1 * fileNameCnt);
+
+   InP->fileNameType.msg_type_number /* fileNameCnt */ = /* fileNameType.msg_type_number */ fileNameCnt;
+
+   msg_size_delta = (1 * fileNameCnt + 3) & ~3;
+   msg_size += msg_size_delta;
+   InP = (Request *) ((char *) InP + msg_size_delta - 1024);
+
+#if   UseStaticMsgType
+   InP->directoryType = directoryType;
+#else   /* UseStaticMsgType */
+   InP->directoryType.msg_type_name = MSG_TYPE_CHAR;
+   InP->directoryType.msg_type_size = 8;
+   InP->directoryType.msg_type_inline = TRUE;
+   InP->directoryType.msg_type_longform = FALSE;
+   InP->directoryType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   if (directoryCnt > 1024)
+      return MIG_ARRAY_TOO_LARGE;
+   bcopy((char *) directory, (char *) InP->directory, 1 * directoryCnt);
+
+   InP->directoryType.msg_type_number /* directoryCnt */ = /* directoryType.msg_type_number */ directoryCnt;
+
+   msg_size_delta = (1 * directoryCnt + 3) & ~3;
+   msg_size += msg_size_delta;
+   InP = (Request *) ((char *) InP + msg_size_delta - 1024);
+
+#if   UseStaticMsgType
+   InP->lineType = lineType;
+#else   /* UseStaticMsgType */
+   InP->lineType.msg_type_name = MSG_TYPE_INTEGER_32;
+   InP->lineType.msg_type_size = 32;
+   InP->lineType.msg_type_number = 1;
+   InP->lineType.msg_type_inline = TRUE;
+   InP->lineType.msg_type_longform = FALSE;
+   InP->lineType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   InP->line /* line */ = /* line */ line;
+
+#if   UseStaticMsgType
+   InP->messageType = messageType;
+#else   /* UseStaticMsgType */
+   InP->messageType.msg_type_name = MSG_TYPE_CHAR;
+   InP->messageType.msg_type_size = 8;
+   InP->messageType.msg_type_inline = TRUE;
+   InP->messageType.msg_type_longform = FALSE;
+   InP->messageType.msg_type_deallocate = FALSE;
+#endif   /* UseStaticMsgType */
+
+   if (messageCnt > 1024)
+      return MIG_ARRAY_TOO_LARGE;
+   bcopy((char *) message, (char *) InP->message, 1 * messageCnt);
+
+   InP->messageType.msg_type_number /* messageCnt */ = /* messageType.msg_type_number */ messageCnt;
+
+   msg_size_delta = (1 * messageCnt + 3) & ~3;
+   msg_size += msg_size_delta;
+
+   InP = &Mess.In;
+   InP->Head.msg_simple = TRUE;
+   InP->Head.msg_size = msg_size;
+   InP->Head.msg_type = MSG_TYPE_NORMAL;
+   InP->Head.msg_request_port = makePort;
+   InP->Head.msg_reply_port = PORT_NULL;
+   InP->Head.msg_id = 101;
+
+   return msg_send(&InP->Head, MSG_OPTION_NONE, 0);
+}
diff -ruN cctools-2/as/symbols.c cctools-hacked/as/symbols.c
--- cctools-2/as/symbols.c   Sat May 08 01:45:45 1999
+++ cctools-hacked/as/symbols.c   Thu Jun 15 19:49:33 2017
@@ -33,6 +33,8 @@
 #include "fixes.h"
 #include "input-scrub.h"
 
+#define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0)
+
 /* symbol-name => struct symbol pointer */
 struct hash_control *sy_hash = NULL;
 
diff -ruN cctools-2/as/write_object.c cctools-hacked/as/write_object.c
--- cctools-2/as/write_object.c   Sat May 08 01:45:46 1999
+++ cctools-hacked/as/write_object.c   Thu Jun 15 19:58:07 2017
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/file.h>
-#include <libc.h>
+//#include <libc.h>
 #include <mach/mach.h>
 #include "stuff/openstep_mach.h"
 #include <mach-o/loader.h>
@@ -59,6 +59,11 @@
 #define RELOC_PAIR   GENERIC_RELOC_PAIR
 #endif
 
+#define open _open
+#define write _write
+#define close _close
+#define bcopy _bcopy
+
 /*
  * These variables are set by layout_symbols() to organize the symbol table and
  * string table in order the dynamic linker expects.  They are then used in
@@ -341,7 +346,8 @@
     * Create the buffer to copy the parts of the output file into.
     */
    output_size = offset;
-   if((r = vm_allocate(mach_task_self(), (vm_address_t *)&output_addr,
+#warning vm_allocate / mach_task_self
+   if((r = vm_allocate(0, (vm_address_t *)&output_addr,
              output_size, TRUE)) != KERN_SUCCESS)
        as_fatal("can't vm_allocate() buffer for output file of size %lu",
            output_size);
@@ -540,7 +546,7 @@
    if(bad_error != 0)
        return;
    (void)unlink(out_file_name);
-   if((fd = open(out_file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) == -1)
+   if((fd = open(out_file_name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)) == -1)
        as_fatal("can't create output file: %s", out_file_name);
    if(write(fd, output_addr, output_size) != output_size)
        as_fatal("can't write output file");
diff -ruN cctools-2/include/ar.h cctools-hacked/include/ar.h
--- cctools-2/include/ar.h
+++ cctools-hacked/include/ar.h   Thu Jun 15 19:19:48 2017
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
+ * Reserved.  This file contains Original Code and/or Modifications of
+ * Original Code as defined in and that are subject to the Apple Public
+ * Source License Version 1.1 (the "License").  You may not use this file
+ * except in compliance with the License.  Please obtain a copy of the
+ * License at http://www.apple.com/publicsource and read it before using
+ * this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*-
+ * Copyright (c) 1991, 1993
+ *      The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Hugh Smith at The University of Guelph.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *      @(#)ar.h        8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _AR_H_
+#define _AR_H_
+
+/* Pre-4BSD archives had these magic numbers in them. */
+#define OARMAG1 0177555
+#define OARMAG2 0177545
+
+#define ARMAG           "!<arch>\n"     /* ar "magic number" */
+#define SARMAG          8               /* strlen(ARMAG); */
+
+#define AR_EFMT1        "#1/"           /* extended format #1 */
+
+struct ar_hdr {
+        char ar_name[16];               /* name */
+        char ar_date[12];               /* modification time */
+        char ar_uid[6];                 /* user id */
+        char ar_gid[6];                 /* group id */
+        char ar_mode[8];                /* octal file permissions */
+        char ar_size[10];               /* size in bytes */
+#define ARFMAG  "`\n"
+        char ar_fmag[2];                /* consistency check */
+};
+
+#endif /* !_AR_H_ */
diff -ruN cctools-2/include/stuff/allocate.h cctools-hacked/include/stuff/allocate.h
--- cctools-2/include/stuff/allocate.h   Sat May 08 01:46:16 1999
+++ cctools-hacked/include/stuff/allocate.h   Thu Jun 15 19:15:57 2017
@@ -24,6 +24,7 @@
 #if defined(__MWERKS__) && !defined(__private_extern__)
 #define __private_extern__ __declspec(private_extern)
 #endif
+#define __private_extern__
 
 /* defined in allocate.c */
 
diff -ruN cctools-2/include/stuff/best_arch.h cctools-hacked/include/stuff/best_arch.h
--- cctools-2/include/stuff/best_arch.h   Sat May 08 01:46:17 1999
+++ cctools-hacked/include/stuff/best_arch.h   Thu Jun 15 19:22:37 2017
@@ -24,6 +24,7 @@
 #if defined(__MWERKS__) && !defined(__private_extern__)
 #define __private_extern__ __declspec(private_extern)
 #endif
+#define __private_extern__
 
 #include <mach/machine.h>
 
diff -ruN cctools-2/include/stuff/bytesex.h cctools-hacked/include/stuff/bytesex.h
--- cctools-2/include/stuff/bytesex.h   Sat May 08 01:46:17 1999
+++ cctools-hacked/include/stuff/bytesex.h   Thu Jun 15 19:07:28 2017
@@ -54,14 +54,13 @@
             (((a) >> 8) & 0x0000ff00) | \
    ((unsigned long)(a) >> 24) )
 
-__private_extern__ float SWAP_FLOAT(
-    float f);
+#define __private_extern__
 
-__private_extern__ double SWAP_DOUBLE(
-    double d);
+__private_extern__ float SWAP_FLOAT(float f);
 
-__private_extern__ enum byte_sex get_host_byte_sex(
-    void);
+__private_extern__ double SWAP_DOUBLE(double d);
+
+__private_extern__ enum byte_sex get_host_byte_sex(void);
 
 __private_extern__ void swap_fat_header(
     struct fat_header *fat_header,
diff -ruN cctools-2/include/stuff/errors.h cctools-hacked/include/stuff/errors.h
--- cctools-2/include/stuff/errors.h   Sat May 08 01:46:16 1999
+++ cctools-hacked/include/stuff/errors.h   Thu Jun 15 19:16:39 2017
@@ -24,6 +24,7 @@
 #if defined(__MWERKS__) && !defined(__private_extern__)
 #define __private_extern__ __declspec(private_extern)
 #endif
+#define __private_extern__
 
 #import "mach/mach.h"
 
diff -ruN cctools-2/include/stuff/hash_string.h cctools-hacked/include/stuff/hash_string.h
--- cctools-2/include/stuff/hash_string.h   Sat May 08 01:46:17 1999
+++ cctools-hacked/include/stuff/hash_string.h   Thu Jun 15 19:30:36 2017
@@ -24,6 +24,7 @@
 #if defined(__MWERKS__) && !defined(__private_extern__)
 #define __private_extern__ __declspec(private_extern)
 #endif
+#define __private_extern__
 
 __private_extern__ long hash_string(
     char *key);
diff -ruN cctools-2/include/stuff/hppa.h cctools-hacked/include/stuff/hppa.h
--- cctools-2/include/stuff/hppa.h   Sat May 08 01:46:18 1999
+++ cctools-hacked/include/stuff/hppa.h   Thu Jun 15 19:18:03 2017
@@ -24,6 +24,7 @@
 #if defined(__MWERKS__) && !defined(__private_extern__)
 #define __private_extern__ __declspec(private_extern)
 #endif
+#define __private_extern__
 
 __private_extern__ void calc_hppa_HILO(
     unsigned long base,
diff -ruN cctools-2/include/stuff/print.h cctools-hacked/include/stuff/print.h
--- cctools-2/include/stuff/print.h   Sat May 08 01:46:18 1999
+++ cctools-hacked/include/stuff/print.h   Thu Jun 15 19:24:53 2017
@@ -24,6 +24,7 @@
 #if defined(__MWERKS__) && !defined(__private_extern__)
 #define __private_extern__ __declspec(private_extern)
 #endif
+#define __private_extern__
 
 #import <stdarg.h>
 
diff -ruN cctools-2/include/stuff/round.h cctools-hacked/include/stuff/round.h
--- cctools-2/include/stuff/round.h   Sat May 08 01:46:17 1999
+++ cctools-hacked/include/stuff/round.h   Thu Jun 15 19:09:27 2017
@@ -28,6 +28,7 @@
 /*
  * round() rounds v to a multiple of r.
  */
-__private_extern__ long round(
+//__private_extern__ long round(
+long round(
     long v,
     unsigned long r);
diff -ruN cctools-2/include/stuff/vm_flush_cache.h cctools-hacked/include/stuff/vm_flush_cache.h
--- cctools-2/include/stuff/vm_flush_cache.h   Sat May 08 01:46:18 1999
+++ cctools-hacked/include/stuff/vm_flush_cache.h   Thu Jun 15 19:30:18 2017
@@ -24,6 +24,7 @@
 #if defined(__MWERKS__) && !defined(__private_extern__)
 #define __private_extern__ __declspec(private_extern)
 #endif
+#define __private_extern__
 
 #import <mach/mach.h>
 __private_extern__ kern_return_t vm_flush_cache(
diff -ruN cctools-2/libstuff/Makefile cctools-hacked/libstuff/Makefile
--- cctools-2/libstuff/Makefile   Sat May 08 01:45:39 1999
+++ cctools-hacked/libstuff/Makefile   Thu Jun 15 19:16:09 2017
@@ -2,13 +2,13 @@
 ifeq "mwcc" "$(notdir $(CC))"
   CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include
 else
-  CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include -Wall -Wno-precomp
+  CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include
 endif
 
 ifneq "" "$(wildcard /bin/mkdirs)"
   MKDIRS = /bin/mkdirs
 else
-  MKDIRS = /bin/mkdir -p
+  MKDIRS = mkdir -p
 endif
 
 SRCROOT = .
@@ -167,7 +167,7 @@
    $(CC) $(CFLAGS) $(RC_CFLAGS) $(COPTS) -c \
       -MD -dependency-file $(OFILE_DIR)/$*.d \
       -o $(OFILE_DIR)/$*.o $<
-   md -d -u $(OFILE_DIR)/Makedep $(OFILE_DIR)/$*.d
+#   md -d -u $(OFILE_DIR)/Makedep $(OFILE_DIR)/$*.d
 endif
 
 clean shlib_clean:
diff -ruN cctools-2/libstuff/execute.c cctools-hacked/libstuff/execute.c
--- cctools-2/libstuff/execute.c   Sat May 08 01:45:34 1999
+++ cctools-hacked/libstuff/execute.c   Thu Jun 15 19:17:10 2017
@@ -21,11 +21,11 @@
  *
  * @APPLE_LICENSE_HEADER_END@
  */
-#include <bsd/libc.h> /* first to get rid of pre-comp warning */
+//#include <bsd/libc.h> /* first to get rid of pre-comp warning */
 #include <mach/mach.h> /* first to get rid of pre-comp warning */
 #include "stdio.h"
 #include <signal.h>
-#include <sys/wait.h>
+//#include <sys/wait.h>
 #include "stuff/errors.h"
 #include "stuff/allocate.h"
 #include "stuff/execute.h"
diff -ruN cctools-2/libstuff/get_toc_byte_sex.c cctools-hacked/libstuff/get_toc_byte_sex.c
--- cctools-2/libstuff/get_toc_byte_sex.c   Sat May 08 01:45:36 1999
+++ cctools-hacked/libstuff/get_toc_byte_sex.c   Thu Jun 15 19:21:36 2017
@@ -37,6 +37,7 @@
  * object file's bytesex.  If it can't figure it out, because the library has
  * no object file members or is malformed it will return UNKNOWN_BYTE_SEX.
  */
+#define __private_extern__
 __private_extern__
 enum byte_sex
 get_toc_byte_sex(
Binary files cctools-2/libstuff/libstuff.a and cctools-hacked/libstuff/libstuff.a differ
Binary files cctools-2/libstuff/libstuff.dylib and cctools-hacked/libstuff/libstuff.dylib differ
diff -ruN cctools-2/libstuff/ofile.c cctools-hacked/libstuff/ofile.c
--- cctools-2/libstuff/ofile.c   Sat May 08 01:45:36 1999
+++ cctools-hacked/libstuff/ofile.c   Thu Jun 15 19:24:10 2017
@@ -24,7 +24,7 @@
 #ifdef SHLIB
 #include "shlib.h"
 #endif
-#include <bsd/libc.h>
+//#include <bsd/libc.h>
 #include <mach/mach.h>
 #include "stuff/openstep_mach.h"
 #include <stdarg.h>
@@ -33,6 +33,7 @@
 #include <ctype.h>
 #include <ar.h>
 #include <sys/file.h>
+#include <sys/stat.h>
 #include <mach-o/fat.h>
 #include <mach-o/loader.h>
 #import <mach/m68k/thread_status.h>
@@ -54,6 +55,9 @@
 #include "stuff/allocate.h"
 #include "stuff/ofile.h"
 #include "stuff/print.h"
+
+#define __private_extern__
+#define NULL 0
 
 #ifdef OTOOL
 #undef ALIGNMENT_CHECKS
diff -ruN cctools-2/libstuff/print.c cctools-hacked/libstuff/print.c
--- cctools-2/libstuff/print.c   Sat May 08 01:45:37 1999
+++ cctools-hacked/libstuff/print.c   Thu Jun 15 19:24:29 2017
@@ -24,6 +24,8 @@
 #import <stdio.h>
 #import "stuff/print.h"
 
+#define __private_extern__
+
 /*
  * All printing of all messages for ofile functions goes through this function.
  * It is broken out here so it can be overridden for some uses.
diff -ruN cctools-2/libstuff/round.c cctools-hacked/libstuff/round.c
--- cctools-2/libstuff/round.c   Sat May 08 01:45:35 1999
+++ cctools-hacked/libstuff/round.c   Thu Jun 15 19:17:36 2017
@@ -22,6 +22,7 @@
  * @APPLE_LICENSE_HEADER_END@
  */
 #include "stuff/round.h"
+#define __private_extern__
 /*
  * round() rounds v to a multiple of r.
  */
diff -ruN cctools-2/libstuff/writeout.c cctools-hacked/libstuff/writeout.c
--- cctools-2/libstuff/writeout.c   Sat May 08 01:45:38 1999
+++ cctools-hacked/libstuff/writeout.c   Thu Jun 15 19:29:48 2017
@@ -23,9 +23,13 @@
  */
 #include <mach/mach.h>
 #include "stuff/openstep_mach.h"
-#include <libc.h>
+//#include <libc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/stat.h>
 #ifndef __OPENSTEP__
-#include <utime.h>
+//#include <utime.h>
 #endif
 #include "stuff/ofile.h"
 #include "stuff/breakout.h"
@@ -33,6 +37,8 @@
 #include "stuff/round.h"
 #include "stuff/errors.h"
 
+#define NULL 0
+
 static void copy_new_symbol_info(
     char *p,
     unsigned long *size,
@@ -97,11 +103,11 @@
     struct fat_header *fat_header;
     struct fat_arch *fat_arch;
     int fd;
-#ifndef __OPENSTEP__
-    struct utimbuf timep;
-#else
+//#ifndef __OPENSTEP__
+//    struct utimbuf timep;
+//#else
     time_t timep[2];
-#endif
+//#endif
     struct dysymtab_command dyst;
     unsigned long mh_flags;
     struct load_command *lc;
@@ -457,15 +463,15 @@
        system_fatal("can't close output file: %s", output);
        return;
    }
-#ifndef __OPENSTEP__
-   timep.actime = toc_time - 5;
-   timep.modtime = toc_time - 5;
-   if(utime(output, &timep) == -1)
-#else
+//#ifndef __OPENSTEP__
+//   timep.actime = toc_time - 5;
+//   timep.modtime = toc_time - 5;
+//   if(utime(output, &timep) == -1)
+//#else
    timep[0] = toc_time - 5;
    timep[1] = toc_time - 5;
    if(utime(output, timep) == -1)
-#endif
+//#endif
    {
        system_fatal("can't set the modifiy times in output file: %s",
           output);


_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Thu Jun 15, 2017 8:58 am    Post subject: Reply with quote

took a look at the linker.

Looks like it'll need some kind of re-write.

Code:
   if((r = map_fd((int)fd, (vm_offset_t)0, (vm_offset_t *)&file_addr,
       (boolean_t)TRUE, (vm_size_t)file_size)) != KERN_SUCCESS){
       close(fd);
       mach_fatal(r, "pass1.c #1 can't map file: %s", file_name);
   }


this bombs no matter what. It appears that map_fd is not an appropriate thing to be using on OPENSTEP NT...

I can't imagine this being of use to anyone but ... trial_cross_compiler.zip. Username & password is in the 404 page.

I guess it's enough that I can build the gcc driver the way I need it and at least cross compile from Windows, just link natively....

Otherwise, yeah it's not too interesting.

Code:
S:\trial_cross_compiler>type hanoi.c   | cc1obj.exe  -arch i386 -quiet -dumpbase hanoi.c -version -dynamic -fPIC -o hanoi.s
GNU Obj-C version 2.7.2.1 (80386, BSD syntax) compiled by GNU C version 2.6.1.

S:\trial_cross_compiler>as -arch i386 -o hanoi.o hanoi.s

S:\trial_cross_compiler>ld -L. -arch i386 -o hanoi -dynamic -lcrt1.o hanoi.o -lcc_dynamic -framework System
file -lcrt1.o is 2440 bytes
ld: pass1.c #1 can't map file: ./crt1.o (mach error 5)

_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
t-rexky



Joined: 09 Jan 2011
Posts: 271
Location: Snowy Canada

PostPosted: Thu Jun 15, 2017 9:32 am    Post subject: Reply with quote

Nice progress!

I am not sure if you caught this before, but I put together a proof of concept gcc-4.6.3 cross compiler for NS33 and built it on my PowerMac G5 with OS X 10.5. Following similar approach to what you did above I compiled a pretty complex propeller optimization code into assembly. Then moved the assembly over to my NS3.3 box, assembled, linked and run. It run like a champ. I did not finish the complete cross toolchain because the Apple code in cctools needed a number of tweaks to the path locations for all the tools and I run out of time to do this.

I am saying all of this because I wonder if it would be simpler to build a cross toolchain on either PPC or i386 OS X, particularly with an earlier release of OS X. The assembler just builds for all historical architectures including m68k, sparc and hppa. The linker is almost compatible. I know that a VM running on modern hardware would be significantly faster, but there may be more integration issues like the ones you are seeing...
Back to top
View user's profile Send private message
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Thu Jun 15, 2017 9:58 am    Post subject: Reply with quote

t-rexky wrote:
Nice progress!

I am not sure if you caught this before, but I put together a proof of concept gcc-4.6.3 cross compiler for NS33 and built it on my PowerMac G5 with OS X 10.5. Following similar approach to what you did above I compiled a pretty complex propeller optimization code into assembly. Then moved the assembly over to my NS3.3 box, assembled, linked and run. It run like a champ. I did not finish the complete cross toolchain because the Apple code in cctools needed a number of tweaks to the path locations for all the tools and I run out of time to do this.

I am saying all of this because I wonder if it would be simpler to build a cross toolchain on either PPC or i386 OS X, particularly with an earlier release of OS X. The assembler just builds for all historical architectures including m68k, sparc and hppa. The linker is almost compatible. I know that a VM running on modern hardware would be significantly faster, but there may be more integration issues like the ones you are seeing...


Wow I didn't think of anything that aggressive... I'm just frustrated at the slow IO, and I had remembered that before webObjects there was PDO, which later on Openstep was all objective C based...

Basically my goal is to hack the kernel on Windows, I don't care much that I have to prep and start the build on Rhapsody, nor do I care about trashing my Openstep install... Just to know stuff compiles as I swear it gets slower with more ram, and it feels like qemu in 100% software mode is faster than VMware..

At any rate, I'm still amazed that I got this far, with the objective C compiler built, and the assembler.

I've hacked the GCC 2.6 driver to do weird things before, so I'll probably use that in this mix maybe with the Openstep pre-processor to get me what I'm hoping for.

Hell I don't even need make I can take a "clean build" kernel output and paste it for all I care, it's blazingly fast on Windows 10 x64!

1997 in 2017!
_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Thu Jun 15, 2017 11:06 am    Post subject: Reply with quote

here is one example of what Im talking about.

my main laptop died, so Im using some crappy $100 special that is nearly 8 years old. Crying or Very sad

anyways, here we go and let's build GCC for OPENSTEP NT

Code:
C:\NeXT\NextDeveloper\Source\GNU\nn>time
The current time is:  1:57:21.30
Enter the new time:

(building)

C:\NeXT\NextDeveloper\Source\GNU\nn>time
The current time is:  1:58:39.93
Enter the new time:


Yes that is right, one minute and 18 seconds to compile the whole thing.

Code:
16/06/2017  01:57 AM           404,480 cccp.exe
16/06/2017  01:57 AM           404,480 cpp.exe
16/06/2017  01:57 AM         4,003,840 cc1.exe
16/06/2017  01:57 AM         4,206,080 cc1obj.exe
16/06/2017  01:58 AM         5,330,432 cc1plus.exe
16/06/2017  01:58 AM         5,585,408 cc1objplus.exe
16/06/2017  01:58 AM            38,912 ld.exe
16/06/2017  01:58 AM           182,784 xgcc.exe
16/06/2017  01:58 AM            61,952 g++.exe
16/06/2017  01:58 AM            93,184 enquire.exe
16/06/2017  01:58 AM           117,248 c++filt.exe


Intel i7 L 640 @ 2.13Ghz

This HP 2540p is *NOT* a fast machine, contrary it's basically junk. I did manage to get 8GB of ram for it, but it has the stock hard disk, which is horribly slow.

Sigh I just saw it's 2am. I need to go to sleep! But at any rate, this is what I'm hoping to do, go through 12MB of C, 2MB of headers and produce some 12MB of object files in under 2 minutes. Laughing
_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
NCommander



Joined: 11 Mar 2017
Posts: 55
Location: New York, NY

PostPosted: Sat Jun 17, 2017 12:09 pm    Post subject: Reply with quote

Late to the party, but you're almost certainly running into alignment and segment issues. As you saw in mach, there are fairly large bits of the code base written by people who have no idea how to write portable code Smile.
Back to top
View user's profile Send private message
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Sat Jun 17, 2017 8:12 pm    Post subject: Reply with quote

NCommander wrote:
Late to the party, but you're almost certainly running into alignment and segment issues. As you saw in mach, there are fairly large bits of the code base written by people who have no idea how to write portable code Smile.

I get the feeling that map_file probably isn't even implimented.

Although I've never used it before, I guess mallocing some ram and reading a file is too pedestrian, got to some way to map it directly into virtual memory, because I only have 4mb of ram, and the #1 feature of Mach was "better virtual memory" than 4.3BSD ....

I haven't looked at lineage, where did the cctools linker come from? CMU? GNU would have been my guess, without GNU it would have been PCC I guess or some quickly dead thing.
_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
t-rexky



Joined: 09 Jan 2011
Posts: 271
Location: Snowy Canada

PostPosted: Sun Jun 18, 2017 3:06 am    Post subject: Reply with quote

neozeed wrote:
I haven't looked at lineage, where did the cctools linker come from? CMU? GNU would have been my guess, without GNU it would have been PCC I guess or some quickly dead thing.


I have not looked at any ancient GNU linkers, but the ld in cctools appears to be either home-brewed by NeXT or CMU sourced. I don't think anyone else was using Mach-O...

Interestingly the concept of shared libraries that is used in NS33 (and earlier) is virtually identical to what was used in SCO. In my days of experimenting with cctools I used information from SCO to build spec file and a proof of concept shlib, using the mkshlib tool that is still there in Apple's cctools.
Back to top
View user's profile Send private message
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Sun Jun 18, 2017 3:12 am    Post subject: Reply with quote

From memory Mach loads servers in the Mach-O format. I recall back in the days of messing with GNUmach+Lites that the lites server had to be compiled as Mach-O while in turn it loaded 386BSD a.out ...

I should look, but apple / NeXT was weird in that there is no servers to load, so everything is Mach-O.

Shared libs on Xenix??
_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
t-rexky



Joined: 09 Jan 2011
Posts: 271
Location: Snowy Canada

PostPosted: Sun Jun 18, 2017 3:41 am    Post subject: Reply with quote

neozeed wrote:
Shared libs on Xenix??


Not sure of the lineage, but here it is: http://osr507doc.sco.com/en/tools/ShLib.html

And my original posts: http://www.nextcomputers.org/forums/viewtopic.php?t=3206

Anyhow, I will stop polluting the thread now...
Back to top
View user's profile Send private message
neozeed



Joined: 15 Apr 2006
Posts: 685
Location: Hong Kong

PostPosted: Sun Jun 18, 2017 3:50 am    Post subject: Reply with quote

t-rexky wrote:
neozeed wrote:
Shared libs on Xenix??


Not sure of the lineage, but here it is: http://osr507doc.sco.com/en/tools/ShLib.html

And my original posts: http://www.nextcomputers.org/forums/viewtopic.php?t=3206

Anyhow, I will stop polluting the thread now...


I'll have to read up on this tonight as I'm at a birthday party. But dude you aren't polluting with any and all great info.

I haven't had time to turn everything off and stare at it, but I did check in the elevator, the first GNU ld, was tiny, nowhere near this convoluted. I don't think any of the CMU pre version 3 stuff made it out. Last time I emailed I got nowhere... Like asking attachmate for a SYSV license
_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    NeXT Computers Forum Index -> Porting New Software All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2017 phpBB Group