Commit | Line | Data |
---|---|---|
9c12f1e5 RGS |
1 | # |
2 | # Hints for the Cray XT4 Catamount/Qk system: | |
3 | # cross-compilation host is a SuSE x86_64-linux, | |
4 | # execution at the target with the 'yod' utility, | |
5 | # linux.sh will run this hints file when necessary. | |
6 | # | |
7 | # cc.sh: compiles the code with the cross-compiler, patches main/exit/_exit | |
8 | # (and traps signals) to be wrappers that echo the exit code. | |
9 | # | |
10 | # run.sh: runs the executable with yod and collects the exit status, | |
11 | # and exits with that status. | |
12 | # | |
13 | # You probably should do the compilation in non-Lustre filesystem | |
14 | # because Lustre does not support all the POSIX system calls, which may | |
15 | # cause weird errors during the Perl build: | |
16 | # 1182003549.604836:3-24:(super.c:1516:llu_iop_fcntl()): unsupported fcntl cmd 2 | |
17 | # | |
18 | # As of 2007-Jun (pre-5.9.5) miniperl and libperl.a can be successfully built; | |
19 | # building any extensions would be hard since Perl cannot run anything | |
20 | # external (which breaks MakeMaker, and confuses ext/util/make_ext). | |
21 | # | |
22 | # To build libperl.a (which also gets miniperl built): | |
23 | # | |
24 | # sh Configure -des -Dusedevel | |
25 | # make libperl.a | |
26 | # | |
27 | # The -Dusedevel is required for Perl 5.9, it is not required for Perl 5.10 | |
28 | # sources, once they come out. You will need to have the run.sh execution | |
29 | # wrapper around (it gets created in the Perl build directory) if you want to | |
30 | # run the miniperl in the XT4. It collects the exit status (note that yod | |
31 | # is run with "-sz 1", so only one instance is run), and possible crash status. | |
32 | # For example: | |
33 | # | |
34 | # sh run.sh ./miniperl -le 'print 42' | |
35 | # | |
36 | ||
37 | case "$prefix" in | |
38 | '') prefix=/opt/perl-catamount ;; | |
39 | esac | |
40 | cat >&4 <<__EOF1__ | |
41 | *** | |
42 | *** You seem to be compiling in Linux for the Catamount/Qk environment. | |
43 | *** I'm therefore not going to install perl as /usr/bin/perl. | |
44 | *** Perl will be installed under $prefix. | |
45 | *** | |
46 | __EOF1__ | |
47 | ||
48 | archname='x86_64-catamount' | |
49 | archobjs='cata.o' | |
50 | d_mmap='undef' | |
51 | d_setlocale='undef' # There is setlocale() but no locales. | |
52 | d_vprintf='define' | |
53 | hintfile='catamount' | |
54 | i_arpainet='undef' | |
55 | i_db='undef' | |
56 | i_netdb='undef' | |
57 | i_niin='undef' | |
58 | incpth=' ' | |
59 | installusrbinperl='undef' | |
60 | libswanted="m crypt c" | |
61 | libpth=' ' | |
62 | locincpth='' | |
63 | onlyextensions='Fcntl' # Not that we can build this, really. | |
64 | osname='catamount' | |
65 | procselfexe='undef' | |
66 | usedl='undef' | |
67 | useithreads='undef' | |
68 | uselargefiles='define' | |
69 | usenm='undef' | |
70 | usethreads='undef' | |
71 | use64bitall='define' | |
72 | ||
73 | BUILD=$PWD | |
74 | ||
75 | case "`yod -Version 2>&1`" in | |
76 | Red*) ;; # E.g. "Red Storm Protocol Release 2.1.0" | |
77 | *) echo >&4 "Could not find 'yod', aborting." | |
78 | exit 1 ;; | |
79 | esac | |
80 | run=$BUILD/run.sh | |
81 | cat > $run <<'__EOF2__' | |
82 | #!/bin/sh | |
83 | # | |
84 | # $run | |
85 | # | |
86 | yod -sz 1 "$@" 2> .yod$$e > .yod$$o | |
87 | status=`awk '/^cata: exe .* pid [0-9][0-9]* (main|exit|_exit) [0-9][0-9]*$/ {print $NF}' .yod$$o|tail -1` | |
88 | grep -v "sz is 1" .yod$$e | |
89 | grep -v "^cata: exe .* pid [0-9][0-9]* " .yod$$o | |
90 | grep "^cata: exe .* signal " .yod$$o | |
91 | rm -f .yod$$o .yod$$e | |
92 | exit $status | |
93 | __EOF2__ | |
94 | chmod 755 $run | |
95 | case "`cc -V 2>&1`" in | |
96 | *catamount*) ;; # E.g. "/opt/xt-pe/1.5.41/bin/snos64/cc: INFO: catamount target is being used" | |
97 | *) echo "Could not find 'cc' for catamount, aborting." | |
98 | exit 1 ;; | |
99 | esac | |
100 | ||
101 | cc=$BUILD/cc.sh | |
102 | cat > $cc <<__EOF3a__ | |
103 | #!/bin/sh | |
104 | # | |
105 | # $0 | |
106 | # | |
107 | # This is essentially a frontend driver for the Catamount cc. | |
108 | # We arrange for (1) the main(), exit(), _exit() being wrapped (cpp-defined) | |
109 | # catamain(), cataexit(), and _cataexit() (2) the actual main() etc. are in | |
110 | # cata.c, and cata.o is linked in when needed (3) signals being caught | |
111 | # All this mostly for being able to catch the exit status (or crash cause). | |
112 | # | |
113 | argv='' | |
114 | srco='' | |
115 | srct='' | |
116 | exe='' | |
117 | defs='-Dmain=catamain -Dexit=cataexit -D_exit=_cataexit' | |
118 | argv='' | |
119 | BUILD=/wrk/jhi/perl-5.9.x@31393+cata | |
120 | __EOF3a__ | |
121 | cat >> $cc <<'__EOF3b__' | |
122 | case "$1" in | |
123 | --cata_o) ;; | |
124 | *) if test ! -f cata.o | |
125 | then | |
126 | if test ! -f cata.c | |
127 | then | |
128 | if test -f ../cata.c # If compiling in UU during Configure. | |
129 | then | |
130 | cp ../cata.c cata.c | |
131 | cp ../cata.h cata.h | |
132 | fi | |
133 | fi | |
134 | $0 --cata_o -c cata.c || exit 1 | |
135 | fi | |
136 | ;; | |
137 | esac | |
138 | while test $# -ne 0 | |
139 | do | |
140 | i=$1 | |
141 | shift | |
142 | case "$i" in | |
143 | --cata_o) ;; | |
144 | *.c) | |
145 | argv="$argv $defs" | |
146 | defs="" | |
147 | if test ! -f $i | |
148 | then | |
149 | echo "$0: $i: No such file or directory" | |
150 | exit 1 | |
151 | fi | |
152 | j=$i$$.c | |
153 | rm -f $j | |
154 | if grep -q -s '#include "cata.h"' $i | |
155 | then | |
156 | : | |
157 | else | |
158 | cat >>$j<<__EOF4__ | |
159 | #include "cata.h" | |
160 | # 1 "$i" | |
161 | __EOF4__ | |
162 | fi | |
163 | cat $i >>$j | |
164 | if grep -q -s 'int main()' $i | |
165 | then | |
166 | argv="$argv -Dmain0" | |
167 | else | |
168 | if grep -q -s 'int main([^,]*,[^,]*)' $i | |
169 | then | |
170 | argv="$argv -Dmain2" | |
171 | else | |
172 | if grep -q -s 'int main([^,]*,[^,]*,[^,]*)' $i | |
173 | then | |
174 | argv="$argv -Dmain3" | |
175 | fi | |
176 | fi | |
177 | fi | |
178 | argv="$argv $j" | |
179 | srct="$j" | |
180 | srco="$i" | |
181 | ;; | |
182 | *.o) | |
183 | if test ! -f "$i" | |
184 | then | |
185 | c=$(echo $i|sed 's/\.o$/.c/') | |
186 | $0 -c $c || exit 1 | |
187 | fi | |
188 | argv="$argv $i" | |
189 | ;; | |
190 | -o) | |
191 | exe="$1" | |
192 | argv="$argv -o $exe -Dargv0=$exe" | |
193 | shift | |
194 | ;; | |
195 | *) | |
196 | argv="$argv $i" | |
197 | ;; | |
198 | esac | |
199 | done | |
200 | case "$exe" in | |
201 | '') ;; | |
202 | *) case "$argv" in | |
203 | *cata.o*) ;; | |
204 | *) argv="$argv cata.o" ;; | |
205 | esac | |
206 | ;; | |
207 | esac | |
208 | cc -I$BUILD $argv 2> .cc$$e > .cc$$o | |
209 | status=$? | |
210 | egrep -v 'catamount target|'$$'\.c:$' .cc$$e 1>&2 | |
211 | case "`grep "is not implemented" .cc$$e`" in | |
212 | *"will always fail"*) status=1 ;; | |
213 | esac | |
214 | cat .cc$$o | |
215 | rm -f .cc$$o | |
216 | case "$status" in | |
217 | 0) rm -f .cc$$e $srct | |
218 | ;; | |
219 | esac | |
220 | objt=`echo $srct|sed -e 's/\.c$/.o/'` | |
221 | objo=`echo $srco|sed -e 's/\.c$/.o/'` | |
222 | if test -n "$objt" -a -f "$objt" | |
223 | then | |
224 | mv -f $objt $objo | |
225 | fi | |
226 | exit $status | |
227 | __EOF3b__ | |
228 | chmod 755 $cc | |
229 | ||
230 | cat >cata.h<<__EOF6__ | |
231 | #ifndef CATA_H | |
232 | #define CATA_H | |
233 | void cataexit(int status); | |
234 | void _cataexit(int status); | |
235 | void catasigsetup(); | |
236 | void catasighandle(int signum); | |
237 | #ifdef main0 | |
238 | int catamain(); | |
239 | #else | |
240 | #ifdef main2 | |
241 | int main(int argc, char **argv); | |
242 | #else | |
243 | int main(int argc, char **argv, char **env); | |
244 | #endif | |
245 | #endif | |
246 | #endif | |
247 | __EOF6__ | |
248 | ||
249 | cat >cata.c<<__EOF7__ | |
250 | #include <stdio.h> | |
251 | #include <signal.h> | |
252 | #undef printf | |
253 | #undef main | |
254 | #undef exit | |
255 | #undef _exit | |
256 | #include "cata.h" | |
257 | #ifndef STRINGIFY | |
258 | #define STRINGIFY(a) #a | |
259 | #endif | |
260 | #ifdef argv0 | |
261 | #define ARGV0 STRINGIFY(argv0) | |
262 | #else | |
263 | static char* argv0; | |
264 | #define ARGV0 argv0 | |
265 | #endif | |
266 | void cataexit(int status) { | |
267 | printf("cata: exe %s pid %d exit %d\n", ARGV0, getpid(), status); | |
268 | exit(status); | |
269 | } | |
270 | void _cataexit(int status) { | |
271 | printf("cata: exe %s pid %d _exit %d\n", ARGV0, getpid(), status); | |
272 | _exit(status); | |
273 | } | |
274 | void catasighandle(int signum) { | |
275 | int core = 0; | |
276 | printf("cata: exe %s pid %d signal %d\n", ARGV0, getpid(), signum); | |
277 | switch (signum) { | |
278 | case SIGQUIT: | |
279 | case SIGILL: | |
280 | case SIGTRAP: | |
281 | case SIGABRT: | |
282 | case SIGBUS: | |
283 | case SIGSEGV: | |
284 | case SIGXCPU: | |
285 | case SIGXFSZ: | |
286 | core = 0200; | |
287 | break; | |
288 | default: | |
289 | break; | |
290 | } | |
291 | cataexit(core << 8 | signum); | |
292 | } | |
293 | void catasigsetup() { | |
294 | signal(SIGHUP, catasighandle); | |
295 | signal(SIGINT, catasighandle); | |
296 | signal(SIGQUIT, catasighandle); | |
297 | signal(SIGILL, catasighandle); | |
298 | signal(SIGTRAP, catasighandle); | |
299 | signal(SIGABRT, catasighandle); | |
300 | signal(SIGIOT, catasighandle); | |
301 | /* KILL */ | |
302 | signal(SIGBUS, catasighandle); | |
303 | signal(SIGFPE, catasighandle); | |
304 | signal(SIGUSR1, catasighandle); | |
305 | signal(SIGUSR2, catasighandle); | |
306 | signal(SIGSEGV, catasighandle); | |
307 | signal(SIGPIPE, catasighandle); | |
308 | signal(SIGALRM, catasighandle); | |
309 | signal(SIGTERM, catasighandle); | |
310 | signal(SIGSTKFLT, catasighandle); | |
311 | signal(SIGCHLD, catasighandle); | |
312 | signal(SIGCONT, catasighandle); | |
313 | /* STOP */ | |
314 | signal(SIGTSTP, catasighandle); | |
315 | signal(SIGTTIN, catasighandle); | |
316 | signal(SIGTTOU, catasighandle); | |
317 | signal(SIGURG, catasighandle); | |
318 | signal(SIGXCPU, catasighandle); | |
319 | signal(SIGXFSZ, catasighandle); | |
320 | signal(SIGVTALRM, catasighandle); | |
321 | signal(SIGPROF, catasighandle); | |
322 | signal(SIGWINCH, catasighandle); | |
323 | signal(SIGIO, catasighandle); | |
324 | signal(SIGPWR, catasighandle); | |
325 | signal(SIGSYS, catasighandle); | |
326 | } | |
327 | int main(int argc, char *argv[], char *envv[]) { | |
328 | int status; | |
329 | #ifndef argv0 | |
330 | argv0 = argv[0]; | |
331 | #endif | |
332 | catasigsetup(); | |
333 | status = | |
334 | #ifdef main0 | |
335 | catamain(); | |
336 | #else | |
337 | #ifdef main2 | |
338 | catamain(argc, argv); | |
339 | #else | |
340 | catamain(argc, argv, envv); | |
341 | #endif | |
342 | #endif | |
343 | printf("cata: exe %s pid %d main %d\n", ARGV0, getpid(), status); | |
344 | return status; | |
345 | } | |
346 | __EOF7__ | |
347 | ||
348 | echo "Faking DynaLoader" | |
349 | touch DynaLoader.o # Oh, the agony. | |
350 | ||
351 | # That's it. |