Make Power MachTen use vfork and perl's malloc
[p5sagit/p5-mst-13.2.git] / hints / machten.sh
1 # machten.sh
2 # This is for MachTen 4.0.3.  It might work on other versions and variants too.
3 #
4 # Users of earlier MachTen versions might need a fixed tr from ftp.tenon.com.
5 # This should be described in the MachTen release notes.
6 #
7 # MachTen 2.x has its own hint file.
8 #
9 # This file has been put together by Andy Dougherty
10 # <doughera@lafcol.lafayette.edu> based on comments from lots of
11 # folks, especially 
12 #       Mark Pease <peasem@primenet.com>
13 #       Martijn Koster <m.koster@webcrawler.com>
14 #       Richard Yeh <rcyeh@cco.caltech.edu>
15 #
16 # Use vfork and perl's malloc by default
17 #                      -- Dominic Dunlop <domo@computer.org> 980630
18 # Raise perl's stack size again; cut down reg_infty; document
19 #                      -- Dominic Dunlop <domo@computer.org> 980619
20 # Use of semctl() can crash system: disable -- Dominic Dunlop 980506
21 # Raise stack size further; slight tweaks to accomodate MT 4.1
22 #                      -- Dominic Dunlop <domo@computer.org> 980211
23 # Raise perl's stack size -- Dominic Dunlop <domo@tcp.ip.lu> 970922
24 # Reinstate sigsetjmp iff version is 4.0.3 or greater; use nm
25 # (assumes Configure change); prune libswanted -- Dominic Dunlop 970113
26 # Warn about test failure due to old Berkeley db -- Dominic Dunlop 970105
27 # Do not use perl's malloc; SysV IPC OK -- Neil Cutcliffe, Tenon 961030
28 # File::Find's use of link count disabled by Dominic Dunlop 960528
29 # Perl's use of sigsetjmp etc. disabled by Dominic Dunlop 960521
30 #
31 # Comments, questions, and improvements welcome!
32 #
33 # MachTen 4.X does support dynamic loading, but perl doesn't
34 # know how to use it yet.
35
36 # Power MachTen is a real memory system and its standard malloc
37 # has been optimized for this. Using this malloc instead of Perl's
38 # malloc may result in significant memory savings.  In particular,
39 # unlike most UNIX memory allocation subsystems, MachTen's free()
40 # really does return unneeded process data memory to the system.
41 # However, MachTen's malloc() is woefully slow -- maybe 100 times
42 # slower than perl's own, so perl's own is usually the better
43 # choice.  In order to use perl's malloc(), the sbrk() system call
44 # must be simulated using MachTen's malloc().  See malloc.c for
45 # precise details of how this is achieved.  Recent improvements
46 # to perl's malloc() currently crash MachTen, and so are disabled
47 # by -DPLAIN_MALLOC and -DNO_FANCY_MALLOC.
48 usemymalloc=${usemymalloc:-y}
49
50 # Do not wrap the following long line
51 malloc_cflags='ccflags="$ccflags -DPLAIN_MALLOC -DNO_FANCY_MALLOC -DUSE_PERL_SBRK"'
52
53 # Note that an empty malloc_cflags appears in config.sh if perl's
54 # malloc() is not used.  his is harmless.
55 case "$usemymalloc" in
56 n) unset malloc_cflags;;
57 *) ccflags="$ccflags  -DHIDEMYMALLOC"
58 esac
59
60 # When MachTen does a fork(), it immediately copies the whole of
61 # the parent process' data space for the child.  This can be
62 # expensive.  Using vfork() where appropriate avoids this cost.
63 d_vfork=${d_vfork:-define}
64
65 # Specify a high level of optimization (-O3 wouldn't do much more)
66 optimize=${optimize:--O2 -fomit-frame-pointer}
67
68 # Make symbol table listings les voluminous
69 nmopts=-gp
70
71 # Set reg_infty -- the maximum allowable number of repeats in regular
72 # expressions such as  /a{1,$max_repeats}/, and the maximum number of
73 # times /a*/ will match.  Setting this too high without having a stack
74 # large enough to accommodate deep recursion in the regular expression
75 # engine allows perl to crash your Mac due to stack overrun if it
76 # encounters a pathological regular expression.  The default is a
77 # compromise between capability and required stack size (see below).
78 # You may override the default value from the Configure command-line
79 # like this:
80 #
81 #   Configure -Dreg_infty=16368 ...
82
83 reg_infty=${reg_infty:-2047}
84
85 # If you want to have many perl processes active simultaneously --
86 # processing CGI forms -- for example, you should opt for a small stack.
87 # For safety, you should set reg_infty no larger than the corresponding
88 # value given in this table:
89 #
90 # Stack size  reg_infty value supported
91 # ----------  -------------------------
92 # 128k        2**8-1    (256)
93 # 256k        2**9-1    (511)
94 # 512k        2**10-1  (1023)
95 #   1M        2**11-1  (2047)
96 # ...
97 #  16M        2**15-1 (32767) (perl's default value)
98
99 # This script selects a safe stack size based on the value of reg_infty
100 # specified above.  However, you may choose to take a risk and set
101 # stack size lower: pathological regular expressions are rare in real-world
102 # programs.  But be aware that, if perl does encounter one, it WILL
103 # crash your system.  Do not set stack size lower than 96k unless
104 # you want perl's installation tests ( make test ) to crash your system.
105 #
106 # You may override the default value from the Configure command-line
107 # by specifying the required size in kilobytes like this:
108 #
109 #   Configure -Dstack_size=96
110
111 if [ "X$stack_size" = 'X' ]
112 then
113     stack_size=128
114     X=`expr $reg_infty / 256`
115
116     while [ $X -gt 0 ]
117     do
118         X=`expr $X / 2`
119         stack_size=`expr $stack_size \* 2`
120     done
121     X=`expr $stack_size \* 1024`
122 fi
123
124 ldflags="$ldflags -Xlstack=$X"
125 ccflags="$ccflags -DREG_INFTY=$reg_infty"
126
127 # Install in /usr/local by default
128 prefix='/usr/local'
129
130 # At least on PowerMac, doubles must be aligned on 8 byte boundaries.
131 # I don't know if this is true for all MachTen systems, or how to
132 # determine this automatically.
133 alignbytes=8
134
135 # 4.0.2 and earlier had a problem with perl's use of sigsetjmp and
136 # friends.  Use setjmp and friends instead.
137 expr "$osvers" \< "4.0.3" > /dev/null && d_sigsetjmp='undef'
138
139 # semctl(.., ..,  IPC_STATUS, ..) hangs system: say we don't have semctl()
140 d_semctl='undef'
141
142 # Get rid of some extra libs which it takes Configure a tediously
143 # long time never to find on MachTen
144 set `echo X "$libswanted "|sed -e 's/ net / /' -e 's/ socket / /' \
145     -e 's/ inet / /' -e 's/ nsl / /' -e 's/ nm / /' -e 's/ malloc / /' \
146     -e 's/ ld / /' -e 's/ sun / /' -e 's/ posix / /' \
147     -e 's/ cposix / /' -e 's/ crypt / /' \
148     -e 's/ ucb / /' -e 's/ bsd / /' -e 's/ BSD / /' -e 's/ PW / /'`
149 shift
150 libswanted="$*"
151
152 # While link counts on MachTen 4.1's fast file systems work correctly,
153 # on Macintosh Heirarchical File Systems, (and on HFS+)
154 # MachTen always reports ony two links to directories, even if they
155 # contain subdirectories.  Consequently, we use this variable to stop
156 # File::Find using the link count to determine whether there are
157 # subdirectories to be searched.  This will generate a harmless message:
158 # Hmm...You had some extra variables I don't know about...I'll try to keep 'em.
159 #       Propagating recommended variable dont_use_nlink
160 dont_use_nlink=define
161
162 cat <<EOM >&4
163
164 During Configure, you may see the message
165
166 *** WHOA THERE!!! ***
167     The recommended value for \$d_semctl on this machine was "undef"!
168     Keep the recommended value? [y]
169
170 Select the default answer: semctl() is buggy, and perl should be built
171 without it.
172
173 Similarly, when you see
174
175 *** WHOA THERE!!! ***
176     The recommended value for \$d_vfork on this machine was "define"!
177     Keep the recommended value? [y]
178
179 select the default answer: vfork() works, and avoids expensive data
180 copying.
181
182 At the end of Configure, you will see a harmless message
183
184 Hmm...You had some extra variables I don't know about...I'll try to keep 'em.
185         Propagating recommended variable dont_use_nlink
186         Propagating recommended variable nmopts
187         Propagating recommended variable malloc_cflags...
188         Propagating recommended variable reg_infty
189 Read the File::Find documentation for more information about dont_use_nlink
190
191 Your perl will be built with a stack size of ${stack_size}k and a regular
192 expression repeat count limit of $reg_infty.  If you want alternative
193 values, see the file hints/machten.sh for advice on how to change them.
194
195 Tests
196         io/fs test 4  and
197         op/stat test 3
198 may fail since MachTen may not return a useful nlinks field to stat
199 on directories.
200
201 EOM
202 expr "$osvers" \< "4.1" >/dev/null && test -r ./broken-db.msg && \
203     . ./broken-db.msg
204
205 unset stack_size X