This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [ID 20000906.004] segfault with bad perl statement
[perl5.git] / hints / dec_osf.sh
CommitLineData
a0d0e21e 1# hints/dec_osf.sh
8e964347 2
b971f6e4 3# * If you want to debug perl or want to send a
8e964347
AB
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#
8a019ce7
JH
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#
b971f6e4 13# * gcc can always have both -g and optimisation on.
8a019ce7 14#
b971f6e4 15# * debugging optimised code, no matter what compiler
8a019ce7
JH
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#
b971f6e4 22# * Configure will automatically add the often quoted
f2c69087
JH
23# -DDEBUGGING for you if the -g is specified.
24#
b971f6e4 25# * There is even more optimisation available in the new
f2c69087
JH
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.
8e964347 33#
b971f6e4 34# * The -std is needed because the following compiled
e60a08f8
JH
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#
b971f6e4 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#
8e964347 53
e60a08f8
JH
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
a68015de
JH
61cc=${cc:-cc}
62
b691c02f
JH
63# do NOT, I repeat, *NOT* take away the leading tabs
64# Configure Black Magic (TM)
b971f6e4 65 # reset
e60a08f8 66 _DEC_cc_style=
8d5a0f9f 67case "`$cc -v 2>&1 | grep cc`" in
f931c1d2 68*gcc*) _gcc_version=`$cc --version 2>&1 | tr . ' '`
2cae8c0d 69 set $_gcc_version
3f8b8817 70 if test "$1" -lt 2 -o \( "$1" -eq 2 -a \( "$2" -lt 95 -o \( "$2" -eq 95 -a "$3" -lt 2 \) \) \); then
2cae8c0d
JH
71 cat >&4 <<EOF
72
3f8b8817
JH
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.)
2cae8c0d
JH
80
81Cannot continue, aborting.
82
83EOF
84 exit 1
85 fi
3f8b8817
JH
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
96Since you explicitly chose gcc, I assume that you know what are doing.
97
98EOF
99 fi
2cae8c0d 100 ;;
e60a08f8 101*) # compile something small: taint.c is fine for this.
eaa5a4a2 102 ccversion=`cc -V | grep -E '(Compaq|DEC) C' | awk '{print $3}'`
e60a08f8 103 # the main point is the '-v' flag of 'cc'.
52c7d5b6 104 case "`cc -v -I. -c taint.c -o taint$$.o 2>&1`" in
e60a08f8 105 */gemc_cc*) # we have the new DEC GEM CC
dfa3a3d3 106 _DEC_cc_style=new
8a019ce7 107 ;;
e60a08f8 108 *) # we have the old MIPS CC
dfa3a3d3 109 _DEC_cc_style=old
8a019ce7 110 ;;
e60a08f8
JH
111 esac
112 # cleanup
52c7d5b6 113 rm -f taint$$.o
e60a08f8
JH
114 ;;
115esac
116
b971f6e4 117# be nauseatingly ANSI
8d5a0f9f 118case "`$cc -v 2>&1 | grep gcc`" in
9607fc9c 119*gcc*) ccflags="$ccflags -ansi"
b971f6e4 120 ;;
121*) ccflags="$ccflags -std"
122 ;;
123esac
124
125# for gcc the Configure knows about the -fpic:
126# position-independent code for dynamic loading
127
e60a08f8
JH
128# we want optimisation
129
130case "$optimize" in
8d5a0f9f 131'') case "`$cc -v 2>&1 | grep gcc`" in
e60a08f8
JH
132 *gcc*)
133 optimize='-O3' ;;
134 *) case "$_DEC_cc_style" in
313489a2
SB
135 new) optimize='-O4'
136 ccflags="$ccflags -fprm d -ieee"
137 ;;
e60a08f8
JH
138 old) optimize='-O2 -Olimit 3200' ;;
139 esac
b971f6e4 140 ccflags="$ccflags -D_INTRINSICS"
e60a08f8 141 ;;
8e964347
AB
142 esac
143 ;;
1fc4cb55 144esac
28757baa 145
313489a2
SB
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.
b0362887
SB
154glibpth="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc"
155glibpth="$glibpth /usr/lib /usr/local/lib /var/shlib"
313489a2 156
8e964347
AB
157# dlopen() is in libc
158libswanted="`echo $libswanted | sed -e 's/ dl / /'`"
159
b971f6e4 160# libPW contains nothing useful for perl
8a019ce7
JH
161libswanted="`echo $libswanted | sed -e 's/ PW / /'`"
162
723e14d4
SB
163# libnet contains nothing useful for perl here, and doesn't work
164libswanted="`echo $libswanted | sed -e 's/ net / /'`"
165
b971f6e4 166# libbsd contains nothing used by perl that is not already in libc
8a019ce7
JH
167libswanted="`echo $libswanted | sed -e 's/ bsd / /'`"
168
b971f6e4 169# libc need not be separately listed
8a019ce7
JH
170libswanted="`echo $libswanted | sed -e 's/ c / /'`"
171
b971f6e4 172# ndbm is already in libc
173libswanted="`echo $libswanted | sed -e 's/ ndbm / /'`"
8a019ce7
JH
174
175# the basic lddlflags used always
176lddlflags='-shared -expect_unresolved "*"'
177
b971f6e4 178# Fancy compiler suites use optimising linker as well as compiler.
179# <spider@Orb.Nashua.NH.US>
b8f0c030 180case "`uname -r`" in
b971f6e4 181*[123].*) # old loader
182 lddlflags="$lddlflags -O3"
183 ;;
a07564da
KS
184*) if $test "X$optimize" = "X$undef"; then
185 lddlflags="$lddlflags -msym"
186 else
baa8820a 187 case "`/usr/sbin/sizer -v`" in
e3159d07
JH
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.
baa8820a 198 lddlflags="$lddlflags -msym -std"
a07564da 199 fi
b971f6e4 200 ;;
201esac
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
8a019ce7 205
b971f6e4 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.
8a019ce7
JH
209case "$optimize" in
210 *-g*) ;; # left intentionally blank
b8f0c030 211*) case "`uname -r`" in
b971f6e4 212 *[123].*)
213 case "$useshrplib" in
214 false|undef|'') lddlflags="$lddlflags -s" ;;
215 esac
216 ;;
8a019ce7 217 *) lddlflags="$lddlflags -s"
b971f6e4 218 ;;
219 esac
220 ;;
8a019ce7 221esac
8e964347
AB
222
223#
313489a2
SB
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
2bf2710f
GS
229case "$_DEC_cc_style.$useshrplib" in
230 new.) useshrplib="$define" ;;
231esac
313489a2 232
85ab1d1d
JH
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().
5ff3f7a4 237
baa8820a
JH
238# Fixed in V5.0A.
239case "`/usr/sbin/sizer -v`" in
f60a5d46 240*5.0[A-Z]*|*5.[1-9]*|*[6-9].[0-9]*)
baa8820a
JH
241 : ok
242 ;;
243*)
244# V5.0 or previous
5ff3f7a4 245pp_sys_cflags='ccflags="$ccflags -DNO_EFF_ONLY_OK"'
baa8820a
JH
246 ;;
247esac
5ff3f7a4 248
6b8eaf93
JH
249# The off_t is already 8 bytes, so we do have largefileness.
250
f60a5d46 251cat > UU/usethreads.cbu <<'EOCBU'
104d25b7
JH
252# This script UU/usethreads.cbu will get 'called-back' by Configure
253# after it has prompted the user for whether to use threads.
104d25b7
JH
254case "$usethreads" in
255$define|true|[yY]*)
75d72f2c 256 # Threads interfaces changed with V4.0.
8d5a0f9f 257 case "`$cc -v 2>&1 | grep gcc`" in
75d72f2c
JH
258 *gcc*)ccflags="-D_REENTRANT $ccflags" ;;
259 *) case "`uname -r`" in
260 *[123].*) ccflags="-threads $ccflags" ;;
261 *) ccflags="-pthread $ccflags" ;;
262 esac
104d25b7 263 ;;
75d72f2c
JH
264 esac
265 case "`uname -r`" in
266 *[123].*) libswanted="$libswanted pthreads mach exc c_r" ;;
267 *) libswanted="$libswanted pthread exc" ;;
268 esac
e883c329 269
baa8820a
JH
270 case "$usemymalloc" in
271 '')
272 usemymalloc='n'
273 ;;
274 esac
104d25b7
JH
275 ;;
276esac
277EOCBU
278
f60a5d46
JH
279cat > 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.
282case "$uselongdouble" in
283$define|true|[yY]*) d_Gconvert='sprintf((b),"%.*Lg",(n),(x))' ;;
284esac
285EOCBU
286
313489a2 287#
e60a08f8
JH
288# Unset temporary variables no more needed.
289#
290
291unset _DEC_cc_style
292
293#
8e964347
AB
294# History:
295#
85ab1d1d
JH
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#
313489a2
SB
302# perl5.004_57:
303#
304# 19-Dec-1997 Spider Boardman <spider@Orb.Nashua.NH.US>
305#
85ab1d1d 306# * Newer Digital UNIX compilers enforce signaling for NaN without
313489a2
SB
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#
723e14d4
SB
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#
b971f6e4 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#
e60a08f8
JH
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#
dfa3a3d3
CS
358# perl5.003_26:
359#
360# 15-Feb-1997 Jarkko Hietaniemi <jhi@iki.fi>
361#
e60a08f8 362# * -std and -ansi.
dfa3a3d3
CS
363#
364#
f2c69087
JH
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#
8a019ce7
JH
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#
8e964347
AB
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#