Ticket #9053: avoid-crash.diff

File avoid-crash.diff, 5.4 KB (added by vinc17@…, 16 years ago)

patch to avoid the crash in config.guess on PowerPC: keep the Mac OS X test only

  • files/patch-config.guess.diff

     
     1--- config.guess.old    2008-08-12 00:49:38.000000000 +0200
     2+++ config.guess        2009-03-06 23:55:14.000000000 +0100
     3@@ -325,144 +325,6 @@
     4   # (as noted below).  But the man page says the command is still "under
     5   # development", so it doesn't seem wise to use it just yet, not while
     6   # there's an alternative.
     7-  #
     8-  # Try to read the PVR.  mfpvr is a protected instruction, NetBSD, MacOS
     9-  # and AIX don't allow it in user mode, but the Linux kernel does.
     10-  #
     11-  # Using explicit bytes for mfpvr avoids worrying about assembler syntax
     12-  # and underscores.  "char"s are used instead of "int"s to avoid worrying
     13-  # whether sizeof(int)==4 or if it's the right endianness.
     14-  #
     15-  # Note this is no good on AIX, since a C function there is the address of
     16-  # a function descriptor, not actual code.  But this doesn't matter since
     17-  # AIX doesn't allow mfpvr anyway.
     18-  #
     19-  cat >$dummy.c <<\EOF
     20-#include <stdio.h>
     21-struct {
     22-  int   n;  /* force 4-byte alignment */
     23-  char  a[8];
     24-} getpvr = {
     25-  0,
     26-  {
     27-    0x7c, 0x7f, 0x42, 0xa6,  /* mfpvr r3 */
     28-    0x4e, 0x80, 0x00, 0x20,  /* blr      */
     29-  }
     30-};
     31-int
     32-main ()
     33-{
     34-  unsigned  (*fun)();
     35-  unsigned  pvr;
     36-
     37-  /* a separate "fun" variable is necessary for gcc 2.95.2 on MacOS,
     38-     it gets a compiler error on a combined cast and call */
     39-  fun = (unsigned (*)()) getpvr.a;
     40-  pvr = (*fun) ();
     41-
     42-  switch (pvr >> 16) {
     43-  case 0x0001: puts ("powerpc601");  break;
     44-  case 0x0003: puts ("powerpc603");  break;
     45-  case 0x0004: puts ("powerpc604");  break;
     46-  case 0x0006: puts ("powerpc603e"); break;
     47-  case 0x0007: puts ("powerpc603e"); break;  /* 603ev */
     48-  case 0x0008: puts ("powerpc750");  break;
     49-  case 0x0009: puts ("powerpc604e"); break;
     50-  case 0x000a: puts ("powerpc604e"); break;  /* 604ev5 */
     51-  case 0x000c: puts ("powerpc7400"); break;
     52-  case 0x0041: puts ("powerpc630");  break;
     53-  case 0x0050: puts ("powerpc860");  break;
     54-  case 0x8000: puts ("powerpc7450"); break;
     55-  case 0x8001: puts ("powerpc7455"); break;
     56-  case 0x8002: puts ("powerpc7457"); break;
     57-  case 0x8003: puts ("powerpc7447"); break; /* really 7447A */
     58-  case 0x800c: puts ("powerpc7410"); break;
     59-  }
     60-  return 0;
     61-}
     62-EOF
     63-  if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
     64-    # This style construct is needed on AIX 4.3 to suppress the SIGILL error
     65-    # from (*fun)().  Using $SHELL -c ./$dummy 2>/dev/null doesn't work.
     66-    { x=`./$dummy`; } 2>/dev/null
     67-    if test -n "$x"; then
     68-      exact_cpu=$x
     69-    fi
     70-  fi
     71-  rm -f $dummy.c $dummy.o $dummy $dummy.core
     72-
     73-  # Grep the linux kernel /proc/cpuinfo pseudo-file.
     74-  # Anything unrecognised is ignored, since of course we mustn't spit out
     75-  # a cpu type config.sub doesn't know.
     76-  if test -z "$exact_cpu" && test -f /proc/cpuinfo; then
     77-    x=`grep "^cpu[     ]" /proc/cpuinfo | head -n 1`
     78-    x=`echo $x | sed -n 's/^cpu[       ]*:[    ]*\([A-Za-z0-9]*\).*/\1/p'`
     79-    x=`echo $x | sed 's/PPC//'`
     80-    case $x in
     81-      601)     exact_cpu="power" ;;
     82-      603ev)   exact_cpu="powerpc603e" ;;
     83-      604ev5)  exact_cpu="powerpc604e" ;;
     84-      603 | 603e | 604 | 604e | 750 | 821 | 860 | 970)
     85-        exact_cpu="powerpc$x" ;;
     86-      POWER[4-9])
     87-        exact_cpu=`echo $x | sed "s;POWER;power;"` ;;
     88-    esac
     89-  fi
     90-
     91-  if test -z "$exact_cpu"; then
     92-    # On AIX, try looking at _system_configuration.  This is present in
     93-    # version 4 at least.
     94-    cat >$dummy.c <<EOF
     95-#include <stdio.h>
     96-#include <sys/systemcfg.h>
     97-int
     98-main ()
     99-{
     100-  switch (_system_configuration.implementation) {
     101-  /* Old versions of AIX don't have all these constants,
     102-     use ifdef for safety. */
     103-#ifdef POWER_RS2
     104-  case POWER_RS2:    puts ("power2");     break;
     105-#endif
     106-#ifdef POWER_601
     107-  case POWER_601:    puts ("power");      break;
     108-#endif
     109-#ifdef POWER_603
     110-  case POWER_603:    puts ("powerpc603"); break;
     111-#endif
     112-#ifdef POWER_604
     113-  case POWER_604:    puts ("powerpc604"); break;
     114-#endif
     115-#ifdef POWER_620
     116-  case POWER_620:    puts ("powerpc620"); break;
     117-#endif
     118-#ifdef POWER_630
     119-  case POWER_630:    puts ("powerpc630"); break;
     120-#endif
     121-  /* Dunno what this is, leave it out for now.
     122-  case POWER_A35:    puts ("powerpca35"); break;
     123-  */
     124-  /* This is waiting for a bit more info.
     125-  case POWER_RS64II: puts ("powerpcrs64ii"); break;
     126-  */
     127-  default:
     128-    if (_system_configuration.architecture == POWER_RS)
     129-      puts ("power");
     130-    else if (_system_configuration.width == 64)
     131-      puts ("powerpc64");
     132-  }
     133-  return 0;
     134-}
     135-EOF
     136-    if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
     137-      x=`./$dummy`
     138-      if test -n "$x"; then
     139-        exact_cpu=$x
     140-      fi
     141-    fi
     142-    rm -f $dummy.c $dummy.o $dummy
     143-  fi
     144-
     145   if test -z "$exact_cpu"; then
     146     # On MacOS X (or any Mach-O presumably), NXGetLocalArchInfo cpusubtype
     147     # can tell us the exact cpu.
  • Portfile

     
    3232use_bzip2       yes
    3333use_parallel_build yes
    3434
     35patchfiles      patch-config.guess.diff
     36
    3537configure.args  --infodir=${prefix}/share/info \
    3638                --enable-cxx
    3739