| 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-Sep (pre-5.10) miniperl, libperl.a, and perl can be successfully |
| 19 | # built; no extensions are built. It would be hard since Perl cannot run |
| 20 | # anything external (pipes, system(), backticks or fork/exec, or globbing) |
| 21 | # (which breaks MakeMaker, and confuses ext/util/make_ext). |
| 22 | # |
| 23 | # To build: |
| 24 | # |
| 25 | # sh Configure -des |
| 26 | # make perl |
| 27 | # |
| 28 | # "make install" won't work since it assumes file globbing (see above). |
| 29 | # You can try the following manual way: |
| 30 | # |
| 31 | # mkdir -p /opt/perl-catamount |
| 32 | # mkdir -p /opt/perl-catamount/include |
| 33 | # mkdir -p /opt/perl-catamount/lib |
| 34 | # mkdir -p /opt/perl-catamount/lib/perl5/5.27.1 |
| 35 | # mkdir -p /opt/perl-catamount/bin |
| 36 | # cp *.h /opt/perl-catamount/include |
| 37 | # cp libperl.a /opt/perl-catamount/lib |
| 38 | # cp -pr lib/* /opt/perl-catamount/lib/perl5/5.27.1 |
| 39 | # cp miniperl perl run.sh cc.sh /opt/perl-catamount/lib |
| 40 | # |
| 41 | # With the headers and the libperl.a you can embed Perl to your Catamount |
| 42 | # application, see pod/perlembed.pod. You can do for example: |
| 43 | # |
| 44 | # cc -I/opt/perl-catamount/include -L/opt/perl-catamount/lib -o embed embed.c |
| 45 | # yod -sz 1 ./embed -le 'print sqrt(2)' |
| 46 | # |
| 47 | # You might want to have the run.sh execution wrapper around (it gets created |
| 48 | # in the Perl build directory) if you want to run the miniperl or perl in |
| 49 | # the XT4. It collects the exit status (note that yod is run with "-sz 1", |
| 50 | # so only one instance is run), and possible crash status (bare yod does |
| 51 | # not collect the exit status). For example: |
| 52 | # |
| 53 | # sh /opt/perl-catamount/bin/run.sh /opt/perl-catamount/bin/perl -le 'print 42' |
| 54 | # |
| 55 | # or if you are still in the build directory: |
| 56 | # |
| 57 | # sh run.sh ./perl -le 'print 2*3*7' |
| 58 | # |
| 59 | # The cc.sh is a wrapper for the Catamount cc used when building Perl |
| 60 | # (and before that, when running Configure), it arranges for the main() |
| 61 | # exit(), _exit() to be wrapped so that the exit/crash status can be |
| 62 | # collected (by run.sh). |
| 63 | # |
| 64 | |
| 65 | case "$prefix" in |
| 66 | '') prefix=/opt/perl-catamount ;; |
| 67 | esac |
| 68 | cat >&4 <<__EOF1__ |
| 69 | *** |
| 70 | *** You seem to be compiling in Linux for the Catamount/Qk environment. |
| 71 | *** I'm therefore not going to install perl as /usr/bin/perl. |
| 72 | *** Perl will be installed under $prefix. |
| 73 | *** |
| 74 | __EOF1__ |
| 75 | |
| 76 | archname='x86_64-catamount' |
| 77 | archobjs='catalib.o' |
| 78 | d_mmap='undef' |
| 79 | d_setlocale='undef' # There is setlocale() but no locales. |
| 80 | d_vprintf='define' |
| 81 | hintfile='catamount' |
| 82 | i_arpainet='undef' |
| 83 | i_db='undef' |
| 84 | i_netdb='undef' |
| 85 | i_niin='undef' |
| 86 | incpth=' ' |
| 87 | installusrbinperl='undef' |
| 88 | libswanted="m crypt c" |
| 89 | libpth=' ' |
| 90 | locincpth=' ' |
| 91 | nonxs_ext=' ' |
| 92 | osname='catamount' |
| 93 | procselfexe='undef' |
| 94 | static_ext=' ' |
| 95 | usedl='undef' |
| 96 | useithreads='undef' |
| 97 | uselargefiles='define' |
| 98 | usenm='undef' |
| 99 | usethreads='undef' |
| 100 | use64bitall='define' |
| 101 | |
| 102 | BUILD=$PWD |
| 103 | |
| 104 | case "`yod -Version 2>&1`" in |
| 105 | Red*) ;; # E.g. "Red Storm Protocol Release 2.1.0" |
| 106 | *) echo >&4 "Could not find 'yod', aborting." |
| 107 | exit 1 ;; |
| 108 | esac |
| 109 | run=$BUILD/run.sh |
| 110 | cat > $run <<'__EOF2__' |
| 111 | #!/bin/sh |
| 112 | # |
| 113 | # $run |
| 114 | # |
| 115 | yod -sz 1 "$@" 2> .yod$$e > .yod$$o |
| 116 | status=`awk '/^cata: exe .* pid [0-9][0-9]* (main|exit|_exit) [0-9][0-9]*$/ {print $NF}' .yod$$o|tail -1` |
| 117 | grep -v "sz is 1" .yod$$e |
| 118 | grep -v "^cata: exe .* pid [0-9][0-9]* " .yod$$o |
| 119 | grep "^cata: exe .* signal " .yod$$o |
| 120 | rm -f .yod$$o .yod$$e |
| 121 | exit $status |
| 122 | __EOF2__ |
| 123 | chmod 755 $run |
| 124 | case "`cc -V 2>&1`" in |
| 125 | *catamount*) ;; # E.g. "/opt/xt-pe/1.5.41/bin/snos64/cc: INFO: catamount target is being used" |
| 126 | *) echo "Could not find 'cc' for catamount, aborting." |
| 127 | exit 1 ;; |
| 128 | esac |
| 129 | |
| 130 | cc=$BUILD/cc.sh |
| 131 | cat > $cc <<__EOF3a__ |
| 132 | #!/bin/sh |
| 133 | # |
| 134 | # $0 |
| 135 | # |
| 136 | # This is essentially a frontend driver for the Catamount cc. |
| 137 | # We arrange for |
| 138 | # (1) the main(), exit(), _exit() being wrapped (cpp-defined) |
| 139 | # catamain(), cataexit(), and _cataexit() |
| 140 | # (2) the actual main() etc. are in cata.c, and cata*.o are |
| 141 | # linked in when needed |
| 142 | # (3) signals being caught |
| 143 | # All this mostly for being able to catch the exit status (or crash cause). |
| 144 | # |
| 145 | argv='' |
| 146 | srco='' |
| 147 | srct='' |
| 148 | exe='' |
| 149 | defs='-Dmain=catamain -Dexit=cataexit -D_exit=_cataexit' |
| 150 | argv='' |
| 151 | BUILD=$BUILD |
| 152 | __EOF3a__ |
| 153 | cat >> $cc <<'__EOF3b__' |
| 154 | case "$1" in |
| 155 | --cata_o) ;; |
| 156 | *) if test ! -f catalib.o |
| 157 | then |
| 158 | if test ! -f catalib.c |
| 159 | then |
| 160 | if test -f ../catalib.c # If compiling in UU during Configure. |
| 161 | then |
| 162 | cp ../catalib.c catalib.c |
| 163 | cp ../catamain.c catamain.c |
| 164 | cp ../cata.h cata.h |
| 165 | fi |
| 166 | fi |
| 167 | $0 --cata_o -c catalib.c || exit 1 |
| 168 | $0 --cata_o -c catamain.c || exit 1 |
| 169 | fi |
| 170 | ;; |
| 171 | esac |
| 172 | while test $# -ne 0 |
| 173 | do |
| 174 | i=$1 |
| 175 | shift |
| 176 | case "$i" in |
| 177 | --cata_o) ;; |
| 178 | *.c) |
| 179 | argv="$argv $defs" |
| 180 | defs="" |
| 181 | if test ! -f $i |
| 182 | then |
| 183 | echo "$0: $i: No such file or directory" |
| 184 | exit 1 |
| 185 | fi |
| 186 | j=$i$$.c |
| 187 | rm -f $j |
| 188 | if grep -q -s '#include "cata.h"' $i |
| 189 | then |
| 190 | : |
| 191 | else |
| 192 | cat >>$j<<__EOF4__ |
| 193 | #include "cata.h" |
| 194 | # 1 "$i" |
| 195 | __EOF4__ |
| 196 | fi |
| 197 | cat $i >>$j |
| 198 | if grep -q -s 'int main()' $i |
| 199 | then |
| 200 | argv="$argv -Dmain0" |
| 201 | else |
| 202 | if grep -q -s 'int main([^,]*,[^,]*)' $i |
| 203 | then |
| 204 | argv="$argv -Dmain2" |
| 205 | else |
| 206 | if grep -q -s 'int main([^,]*,[^,]*,[^,]*)' $i |
| 207 | then |
| 208 | argv="$argv -Dmain3" |
| 209 | fi |
| 210 | fi |
| 211 | fi |
| 212 | argv="$argv $j" |
| 213 | srct="$j" |
| 214 | srco="$i" |
| 215 | ;; |
| 216 | *.o) |
| 217 | if test ! -f "$i" |
| 218 | then |
| 219 | c=$(echo $i|sed 's/\.o$/.c/') |
| 220 | $0 -c $c || exit 1 |
| 221 | fi |
| 222 | argv="$argv $i" |
| 223 | ;; |
| 224 | -o) |
| 225 | exe="$1" |
| 226 | argv="$argv -o $exe -Dargv0=$exe" |
| 227 | shift |
| 228 | ;; |
| 229 | *) |
| 230 | argv="$argv $i" |
| 231 | ;; |
| 232 | esac |
| 233 | done |
| 234 | case "$exe" in |
| 235 | '') ;; |
| 236 | *) case "$argv" in |
| 237 | *catalib.o*|*" perlmain.o "*) ;; |
| 238 | *) argv="$argv catalib.o" ;; |
| 239 | esac |
| 240 | case "$argv" in |
| 241 | *catamain.o*) ;; |
| 242 | *) argv="$argv catamain.o" ;; |
| 243 | esac |
| 244 | ;; |
| 245 | esac |
| 246 | cc -I$BUILD $argv 2> .cc$$e > .cc$$o |
| 247 | status=$? |
| 248 | egrep -v 'catamount target|'$$'\.c:$' .cc$$e 1>&2 |
| 249 | case "`grep "is not implemented" .cc$$e`" in |
| 250 | *"will always fail"*) status=1 ;; |
| 251 | esac |
| 252 | cat .cc$$o |
| 253 | rm -f .cc$$o |
| 254 | case "$status" in |
| 255 | 0) rm -f .cc$$e $srct |
| 256 | ;; |
| 257 | esac |
| 258 | objt=`echo $srct|sed -e 's/\.c$/.o/'` |
| 259 | objo=`echo $srco|sed -e 's/\.c$/.o/'` |
| 260 | if test -n "$objt" -a -f "$objt" |
| 261 | then |
| 262 | mv -f $objt $objo |
| 263 | fi |
| 264 | exit $status |
| 265 | __EOF3b__ |
| 266 | chmod 755 $cc |
| 267 | |
| 268 | cat >cata.h<<__EOF6__ |
| 269 | #ifndef CATA_H |
| 270 | #define CATA_H |
| 271 | void cataexit(int status); |
| 272 | void _cataexit(int status); |
| 273 | void catasigsetup(); |
| 274 | void catasighandle(int signum); |
| 275 | #ifdef main0 |
| 276 | int catamain(); |
| 277 | #else |
| 278 | #ifdef main2 |
| 279 | int main(int argc, char **argv); |
| 280 | #else |
| 281 | int main(int argc, char **argv, char **env); |
| 282 | #endif |
| 283 | #endif |
| 284 | #endif |
| 285 | #ifdef argv0 |
| 286 | #define ARGV0 STRINGIFY(argv0) |
| 287 | #else |
| 288 | #define ARGV0 argv0 |
| 289 | #endif |
| 290 | __EOF6__ |
| 291 | |
| 292 | cat >catalib.c<<__EOF7__ |
| 293 | #include <stdio.h> |
| 294 | #include <signal.h> |
| 295 | #undef printf |
| 296 | #undef main |
| 297 | #undef exit |
| 298 | #undef _exit |
| 299 | #include "cata.h" |
| 300 | char* argv0; |
| 301 | void cataexit(int status) { |
| 302 | printf("cata: exe %s pid %d exit %d\n", ARGV0, getpid(), status); |
| 303 | exit(status); |
| 304 | } |
| 305 | void _cataexit(int status) { |
| 306 | printf("cata: exe %s pid %d _exit %d\n", ARGV0, getpid(), status); |
| 307 | _exit(status); |
| 308 | } |
| 309 | void catasighandle(int signum) { |
| 310 | int core = 0; |
| 311 | printf("cata: exe %s pid %d signal %d\n", ARGV0, getpid(), signum); |
| 312 | switch (signum) { |
| 313 | case SIGQUIT: |
| 314 | case SIGILL: |
| 315 | case SIGTRAP: |
| 316 | case SIGABRT: |
| 317 | case SIGBUS: |
| 318 | case SIGSEGV: |
| 319 | case SIGXCPU: |
| 320 | case SIGXFSZ: |
| 321 | core = 0200; |
| 322 | break; |
| 323 | default: |
| 324 | break; |
| 325 | } |
| 326 | cataexit(core << 8 | signum); |
| 327 | } |
| 328 | void catasigsetup() { |
| 329 | signal(SIGHUP, catasighandle); |
| 330 | signal(SIGINT, catasighandle); |
| 331 | signal(SIGQUIT, catasighandle); |
| 332 | signal(SIGILL, catasighandle); |
| 333 | signal(SIGTRAP, catasighandle); |
| 334 | signal(SIGABRT, catasighandle); |
| 335 | signal(SIGIOT, catasighandle); |
| 336 | /* KILL */ |
| 337 | signal(SIGBUS, catasighandle); |
| 338 | signal(SIGFPE, catasighandle); |
| 339 | signal(SIGUSR1, catasighandle); |
| 340 | signal(SIGUSR2, catasighandle); |
| 341 | signal(SIGSEGV, catasighandle); |
| 342 | signal(SIGPIPE, catasighandle); |
| 343 | signal(SIGALRM, catasighandle); |
| 344 | signal(SIGTERM, catasighandle); |
| 345 | signal(SIGSTKFLT, catasighandle); |
| 346 | signal(SIGCHLD, catasighandle); |
| 347 | signal(SIGCONT, catasighandle); |
| 348 | /* STOP */ |
| 349 | signal(SIGTSTP, catasighandle); |
| 350 | signal(SIGTTIN, catasighandle); |
| 351 | signal(SIGTTOU, catasighandle); |
| 352 | signal(SIGURG, catasighandle); |
| 353 | signal(SIGXCPU, catasighandle); |
| 354 | signal(SIGXFSZ, catasighandle); |
| 355 | signal(SIGVTALRM, catasighandle); |
| 356 | signal(SIGPROF, catasighandle); |
| 357 | signal(SIGWINCH, catasighandle); |
| 358 | signal(SIGIO, catasighandle); |
| 359 | signal(SIGPWR, catasighandle); |
| 360 | signal(SIGSYS, catasighandle); |
| 361 | } |
| 362 | void boot_DynaLoader (void* cv) { } |
| 363 | __EOF7__ |
| 364 | cat >catamain.c<<__EOF8__ |
| 365 | #include <stdio.h> |
| 366 | #undef printf |
| 367 | #undef main |
| 368 | #undef exit |
| 369 | #undef _exit |
| 370 | #include "cata.h" |
| 371 | extern char* argv0; |
| 372 | int main(int argc, char *argv[], char *envv[]) { |
| 373 | int status; |
| 374 | #ifndef argv0 |
| 375 | argv0 = argv[0]; |
| 376 | #endif |
| 377 | catasigsetup(); |
| 378 | status = |
| 379 | #ifdef main0 |
| 380 | catamain(); |
| 381 | #else |
| 382 | #ifdef main2 |
| 383 | catamain(argc, argv); |
| 384 | #else |
| 385 | catamain(argc, argv, envv); |
| 386 | #endif |
| 387 | #endif |
| 388 | printf("cata: exe %s pid %d main %d\n", ARGV0, getpid(), status); |
| 389 | return status; |
| 390 | } |
| 391 | __EOF8__ |
| 392 | |
| 393 | echo "Faking DynaLoader" |
| 394 | touch DynaLoader.o # Oh, the agony. |
| 395 | |
| 396 | # That's it. |