Newsgroups: comp.lang.perl
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!convex!tchrist
From: tchrist@convex.com (Tom Christiansen)
Subject: compiling perl 4.003 on a Convex
Message-ID: <1991Apr24.232208.24472@convex.com>
Sender: newsadm@convex.com (news access account)
Nntp-Posting-Host: pixel.convex.com
Organization: Convex Computer Corporation, Richardson, Tx.
Date: Wed, 24 Apr 1991 23:22:08 GMT
Lines: 69


Has not been a particularly pleasant time...

First compiler switches:  There's -pcc for old pcc stuff, and -ext for
ANSI C + POSIX + Convex extensions.    I opted for -ext, because otherwise
I couldn't get things like waitpid(), since a corporate decision was made
not to extend functionality into pcc mode.

Note that one of the disadvantages of POSIX mode is that your old familiar
system calls won't restart anymore, like read from a slow device or wait.
On the other hand, this saves some complex eval/die stuff when you want to
have a timed out read.

Here are the problems I experienced.  I think what most annoys me is that
almost everyone of these is a bogus typing error that the compiler is just
too @!#$$@#%!@ picky about, because if it would just shut up, it would be
fine.  Sigh.


1.  /lib/libc.a is only for -pcc mode.  -ext uses /usr/lib/libc.a;
    I fixed this by editing convex.sh and setting libc='/usr/lib/libc.a'.
    Would be nice to have a way to select the right libc.

2.  System functions get redeclared if __STDC__ isn't defined. 
    For example, sprintf() is wrongly redeclared in perl.h if
    this is so.  Sadly, Convex only defines __stdc__ except in strictly
    conforming mode.  This is fixed by adding a -D__STDC__.
    Actually, the right thing is

	#if defined(__STDC__) || defined(__stdc__) 

3.  In doio.c, the socket calls (accept, bind, connect) get called
    with middle params of type (char *) instead of (struct sockaddr *)
    as their prototypes demand.  This can be fixed with casts.

4.  Also in doio.c, there are redeclarations of the getpw*() and
    getgr*() functions without prototypes.  (I'm really getting 
    to gate these @#$^@#$!@ prototypes.)  I fixed this by protecting
    them all with #ifndef __STDC__.

5.  In eval.c, there is a call to getpgrp(anum).  However, in 
    POSIX, getpgrp() takes no arg, so it doesn't match the prototype
    and blows up.  This I fixed by an #ifdef __STDC__ in which 
    the call had no arg, with the #else being what was there before.
    (My POSIX guru says this should be #ifdef _POSIX_SOURCE to use
    getpgid() instead.)

6.  malloc.c declares its own malloc, but the type needs to be 
    void * so as not to conflict with the system definition.
    I changed MALLOCPTRTYPE in config.h to be void.

7.  Also in malloc.c, free is declared to be 
	void free(cp) char *cp;
    which screws up the prototype.  I changed this to 
	void free(cp) MALLOCPTRTYPE *cp;

8.  Also in malloc.c, realloc needs the pointer to 
    be of MALLOCPTRTYPE as well.
   

Re #6-8, My ANSI guru tells me that Thou Shalt Not redefine a C lib
function according to the Rules, so that you really should have MALLOC,
FREE, and REALLOC functions that point to either the system malloc or else
to my_malloc, etc.

It runs now, passes all tests, and solves a coredumping problem I was
having with a massively huge eval.

--tom
