SYN SYN
[p5sagit/p5-mst-13.2.git] / hints / dec_osf.sh
1 # hints/dec_osf.sh
2
3 #       * If you want to debug perl or want to send a
4 #       stack trace for inclusion into an bug report, call
5 #       Configure with the additional argument  -Doptimize=-g2
6 #       or uncomment this assignment to "optimize":
7 #
8 #optimize=-g2
9 #
10 #       If you want both to optimise and debug with the DEC cc
11 #       you must have -g3, e.g. "-O4 -g3", and (re)run Configure.
12 #
13 #       * gcc can always have both -g and optimisation on.
14 #
15 #       * debugging optimised code, no matter what compiler
16 #       one is using, can be surprising and confusing because of
17 #       the optimisation tricks like code motion, code removal,
18 #       loop unrolling, and inlining. The source code and the
19 #       executable code simply do not agree any more while in
20 #       mid-execution, the optimiser only cares about the results.
21 #
22 #       * Configure will automatically add the often quoted
23 #       -DDEBUGGING for you if the -g is specified.
24 #
25 #       * There is even more optimisation available in the new
26 #       (GEM) DEC cc: -O5 and -fast. "man cc" will tell more about them.
27 #       The jury is still out whether either or neither help for Perl
28 #       and how much. Based on very quick testing, -fast boosts
29 #       raw data copy by about 5-15% (-fast brings in, among other
30 #       things, inlined, ahem, fast memcpy()), while on the other
31 #       hand searching things (index, m//, s///), seems to get slower.
32 #       Your mileage will vary.
33 #
34 #       * The -std is needed because the following compiled
35 #       without the -std and linked with -lm
36 #
37 #       #include <math.h>
38 #       #include <stdio.h>
39 #       int main(){short x=10,y=sqrt(x);printf("%d\n",y);}
40 #
41 #       will in Digital UNIX 3.* and 4.0b print 0 -- and in Digital
42 #       UNIX 4.0{,a} dump core: Floating point exception in the printf(),
43 #       the y has become a signaling NaN.
44 #
45 #       * Compilation warnings like:
46 #
47 #       "Undefined the ANSI standard macro ..."
48 #
49 #       can be ignored, at least while compiling the POSIX extension
50 #       and especially if using the sfio (the latter is not a standard
51 #       part of Perl, never mind if it says little to you).
52 #
53
54 # If using the DEC compiler we must find out the DEC compiler style:
55 # the style changed between Digital UNIX (aka DEC OSF/1) 3 and
56 # Digital UNIX 4. The old compiler was originally from Ultrix and
57 # the MIPS company, the new compiler is originally from the VAX world
58 # and it is called GEM. Many of the options we are going to use depend
59 # on the compiler style.
60
61 cc=${cc:-cc}
62
63 # do NOT, I repeat, *NOT* take away the leading tabs
64 # Configure Black Magic (TM)
65         # reset
66         _DEC_cc_style=
67 case "`$cc -v 2>&1 | grep cc`" in
68 *gcc*)  _gcc_version=`$cc --version 2>&1 | tr . ' '`
69         set $_gcc_version
70         if test "$1" -lt 2 -o \( "$1" -eq 2 -a \( "$2" -lt 95 -o \( "$2" -eq 95 -a "$3" -lt 2 \) \) \); then
71             cat >&4 <<EOF
72
73 *** Your cc seems to be gcc and its version seems to be less than 2.95.2.
74 *** This is not a good idea since old versions of gcc are known to produce
75 *** buggy code when compiling Perl (and no doubt for other programs, too).
76 ***
77 *** Therefore, I strongly suggest upgrading your gcc.  (Why don't you
78 *** use the vendor cc is also a good question.  It comes with the operating
79 *** system and produces good code.)
80
81 Cannot continue, aborting.
82
83 EOF
84             exit 1
85         fi
86         if test "$1" -eq 2 -a "$2" -eq 95 -a "$3" -le 2; then
87             cat >&4 <<EOF
88
89 *** Note that as of gcc 2.95.2 (19991024) and Perl 5.6.0 (March 2000)
90 *** if the said Perl is compiled with the said gcc the lib/sdbm test
91 *** dumps core (meaning  that the SDBM_File is unusable).  As this core
92 *** dump doesn't happen with the vendor cc, this is most probably
93 *** a lingering bug in gcc.  Therefore unless you have a better gcc
94 *** you are still better off using the vendor cc.
95
96 Since you explicitly chose gcc, I assume that you know what are doing.
97
98 EOF
99         fi
100         ;;
101 *)      # compile something small: taint.c is fine for this.
102         ccversion=`cc -V | awk '/(Compaq|DEC) C/ {print $3}'`
103         # the main point is the '-v' flag of 'cc'.
104         case "`cc -v -I. -c taint.c -o taint$$.o 2>&1`" in
105         */gemc_cc*)     # we have the new DEC GEM CC
106                         _DEC_cc_style=new
107                         ;;
108         *)              # we have the old MIPS CC
109                         _DEC_cc_style=old
110                         ;;
111         esac
112         # cleanup
113         rm -f taint$$.o
114         ;;
115 esac
116
117 # be nauseatingly ANSI
118 case "`$cc -v 2>&1 | grep gcc`" in
119 *gcc*)  ccflags="$ccflags -ansi"
120         ;;
121 *)      ccflags="$ccflags -std"
122         ;;
123 esac
124
125 # for gcc the Configure knows about the -fpic:
126 # position-independent code for dynamic loading
127
128 # we want optimisation
129
130 case "$optimize" in
131 '')     case "`$cc -v 2>&1 | grep gcc`" in
132         *gcc*)  
133                 optimize='-O3'                          ;;
134         *)      case "$_DEC_cc_style" in
135                 new)    optimize='-O4'
136                         ccflags="$ccflags -fprm d -ieee"
137                         ;;
138                 old)    optimize='-O2 -Olimit 3200'     ;;
139                 esac
140                 ccflags="$ccflags -D_INTRINSICS"
141                 ;;
142         esac
143         ;;
144 esac
145
146 # Make glibpth agree with the compiler suite.  Note that /shlib
147 # is not here.  That's on purpose.  Even though that's where libc
148 # really lives from V4.0 on, the linker (and /sbin/loader) won't
149 # look there by default.  The sharable /sbin utilities were all
150 # built with "-Wl,-rpath,/shlib" to get around that.  This makes
151 # no attempt to figure out the additional location(s) searched by
152 # gcc, since not all versions of gcc are easily coerced into
153 # revealing that information.
154 glibpth="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc"
155 glibpth="$glibpth /usr/lib /usr/local/lib /var/shlib"
156
157 # dlopen() is in libc
158 libswanted="`echo $libswanted | sed -e 's/ dl / /'`"
159
160 # libPW contains nothing useful for perl
161 libswanted="`echo $libswanted | sed -e 's/ PW / /'`"
162
163 # libnet contains nothing useful for perl here, and doesn't work
164 libswanted="`echo $libswanted | sed -e 's/ net / /'`"
165
166 # libbsd contains nothing used by perl that is not already in libc
167 libswanted="`echo $libswanted | sed -e 's/ bsd / /'`"
168
169 # libc need not be separately listed
170 libswanted="`echo $libswanted | sed -e 's/ c / /'`"
171
172 # ndbm is already in libc
173 libswanted="`echo $libswanted | sed -e 's/ ndbm / /'`"
174
175 # the basic lddlflags used always
176 lddlflags='-shared -expect_unresolved "*"'
177
178 # Fancy compiler suites use optimising linker as well as compiler.
179 # <spider@Orb.Nashua.NH.US>
180 case "`uname -r`" in
181 *[123].*)       # old loader
182                 lddlflags="$lddlflags -O3"
183                 ;;
184 *)            if $test "X$optimize" = "X$undef"; then
185                       lddlflags="$lddlflags -msym"
186               else
187                   case "`/usr/sbin/sizer -v`" in
188                   *4.0D*)
189                       # QAR 56761: -O4 + .so may produce broken code,
190                       # fixed in 4.0E or better.
191                       ;;
192                   *)    
193                       lddlflags="$lddlflags $optimize"
194                       ;;
195                   esac
196                   # -msym: If using a sufficiently recent /sbin/loader,
197                   # keep the module symbols with the modules.
198                   lddlflags="$lddlflags -msym -std"
199               fi
200                 ;;
201 esac
202 # Yes, the above loses if gcc does not use the system linker.
203 # If that happens, let me know about it. <jhi@iki.fi>
204
205
206 # If debugging or (old systems and doing shared)
207 # then do not strip the lib, otherwise, strip.
208 # As noted above the -DDEBUGGING is added automagically by Configure if -g.
209 case "$optimize" in
210         *-g*) ;; # left intentionally blank
211 *)      case "`uname -r`" in
212         *[123].*)
213                 case "$useshrplib" in
214                 false|undef|'') lddlflags="$lddlflags -s"       ;;
215                 esac
216                 ;;
217         *) lddlflags="$lddlflags -s"
218                 ;;
219         esac
220         ;;
221 esac
222
223 #
224 # Make embedding in things like INN and Apache more memory friendly.
225 # Keep it overridable on the Configure command line, though, so that
226 # "-Uuseshrplib" prevents this default.
227 #
228
229 case "$_DEC_cc_style.$useshrplib" in
230         new.)   useshrplib="$define"    ;;
231 esac
232
233 # The EFF_ONLY_OK from <sys/access.h> is present but dysfunctional for
234 # [RWX]_OK as of Digital UNIX 4.0[A-D]?.  If and when this gets fixed,
235 # please adjust this appropriately.  See also pp_sys.c just before the
236 # emulate_eaccess().
237
238 # Fixed in V5.0A.
239 case "`/usr/sbin/sizer -v`" in
240 *5.0[A-Z]*|*5.[1-9]*|*[6-9].[0-9]*)
241         : ok
242         ;;
243 *)
244 # V5.0 or previous
245 pp_sys_cflags='ccflags="$ccflags -DNO_EFF_ONLY_OK"'
246         ;;
247 esac
248
249 # The off_t is already 8 bytes, so we do have largefileness.
250
251 cat > UU/usethreads.cbu <<'EOCBU'
252 # This script UU/usethreads.cbu will get 'called-back' by Configure 
253 # after it has prompted the user for whether to use threads.
254 case "$usethreads" in
255 $define|true|[yY]*)
256         # Threads interfaces changed with V4.0.
257         case "`$cc -v 2>&1 | grep gcc`" in
258         *gcc*)ccflags="-D_REENTRANT $ccflags" ;;
259         *)  case "`uname -r`" in
260             *[123].*)   ccflags="-threads $ccflags" ;;
261             *)          ccflags="-pthread $ccflags" ;;
262             esac
263             ;;
264         esac    
265         case "`uname -r`" in
266         *[123].*) libswanted="$libswanted pthreads mach exc c_r" ;;
267         *)        libswanted="$libswanted pthread exc" ;;
268         esac
269
270         case "$usemymalloc" in
271         '')
272                 usemymalloc='n'
273                 ;;
274         esac
275         ;;
276 esac
277 EOCBU
278
279 cat > UU/uselongdouble.cbu <<'EOCBU'
280 # This script UU/uselongdouble.cbu will get 'called-back' by Configure 
281 # after it has prompted the user for whether to use long doubles.
282 case "$uselongdouble" in
283 $define|true|[yY]*) d_Gconvert='sprintf((b),"%.*Lg",(n),(x))' ;;
284 esac
285 EOCBU
286
287 #
288 # Unset temporary variables no more needed.
289 #
290
291 unset _DEC_cc_style
292     
293 #
294 # History:
295 #
296 # perl5.005_51:
297 #
298 #       September-1998 Jarkko Hietaniemi <jhi@iki.fi>
299 #
300 #       * Added the -DNO_EFF_ONLY_OK flag ('use filetest;' support).
301 #
302 # perl5.004_57:
303 #
304 #       19-Dec-1997 Spider Boardman <spider@Orb.Nashua.NH.US>
305 #
306 #       * Newer Digital UNIX compilers enforce signaling for NaN without
307 #         -ieee.  Added -fprm d at the same time since it's friendlier for
308 #         embedding.
309 #
310 #       * Fixed the library search path to match cc, ld, and /sbin/loader.
311 #
312 #       * Default to building -Duseshrplib on newer systems.  -Uuseshrplib
313 #         still overrides.
314 #
315 #       * Fix -pthread additions for useshrplib.  ld has no -pthread option.
316 #
317 #
318 # perl5.004_04:
319 #
320 #       19-Sep-1997 Spider Boardman <spider@Orb.Nashua.NH.US>
321 #
322 #       * libnet on Digital UNIX is for JAVA, not for sockets.
323 #
324 #
325 # perl5.003_28:
326 #
327 #       22-Feb-1997 Jarkko Hietaniemi <jhi@iki.fi>
328 #
329 #       * Restructuring Spider's suggestions.
330 #
331 #       * Older Digital UNIXes cannot handle -Olimit ... for $lddlflags.
332 #       
333 #       * ld -s cannot be used in older Digital UNIXes when doing shared.
334 #
335 #
336 #       21-Feb-1997 Spider Boardman <spider@Orb.Nashua.NH.US>
337 #
338 #       * -hidden removed.
339 #       
340 #       * -DSTANDARD_C removed.
341 #
342 #       * -D_INTRINSICS added. (that -fast does not seem to buy much confirmed)
343 #
344 #       * odbm not in libc, only ndbm. Therefore dbm back to $libswanted.
345 #
346 #       * -msym for the newer runtime loaders.
347 #
348 #       * $optimize also in $lddflags.
349 #
350 #
351 # perl5.003_27:
352 #
353 #       18-Feb-1997 Jarkko Hietaniemi <jhi@iki.fi>
354 #
355 #       * unset _DEC_cc_style and more commentary on -std.
356 #
357 #
358 # perl5.003_26:
359 #
360 #       15-Feb-1997 Jarkko Hietaniemi <jhi@iki.fi>
361 #
362 #       * -std and -ansi.
363 #
364 #
365 # perl5.003_24:
366 #
367 #       30-Jan-1997 Jarkko Hietaniemi <jhi@iki.fi>
368 #
369 #       * Fixing the note on -DDEBUGGING.
370 #
371 #       * Note on -O5 -fast.
372 #
373 #
374 # perl5.003_23:
375 #
376 #       26-Jan-1997 Jarkko Hietaniemi <jhi@iki.fi>
377 #
378 #       * Notes on how to do both optimisation and debugging.
379 #
380 #
381 #       25-Jan-1997 Jarkko Hietaniemi <jhi@iki.fi>
382 #
383 #       * Remove unneeded libraries from $libswanted: PW, bsd, c, dbm
384 #
385 #       * Restructure the $lddlflags build.
386 #
387 #       * $optimize based on which compiler we have.
388 #
389 #
390 # perl5.003_22:
391 #
392 #       23-Jan-1997 Achim Bohnet <ach@rosat.mpe-garching.mpg.de>
393 #
394 #       * Added comments 'how to create a debugging version of perl'
395 #
396 #       * Fixed logic of this script to prevent stripping of shared
397 #         objects by the loader (see ld man page for -s) is debugging
398 #         is set via the -g switch.
399 #
400 #
401 #       21-Jan-1997 Achim Bohnet <ach@rosat.mpe-garching.mpg.de>
402 #
403 #       * now 'dl' is always removed from libswanted. Not only if
404 #         optimize is an empty string.
405 #        
406 #
407 #       17-Jan-1997 Achim Bohnet <ach@rosat.mpe-garching.mpg.de>
408 #
409 #       * Removed 'dl' from libswanted: When the FreePort binary
410 #         translator for Sun binaries is installed Configure concludes
411 #         that it should use libdl.x.yz.fpx.so :-(
412 #         Because the dlopen, dlclose,... calls are in the
413 #         C library it not necessary at all to check for the
414 #         dl library.  Therefore dl is removed from libswanted.
415 #       
416 #
417 #       1-Jan-1997 Achim Bohnet <ach@rosat.mpe-garching.mpg.de>
418 #       
419 #       * Set -Olimit to 3200 because perl_yylex.c got too big
420 #         for the optimizer.
421 #