Ticket #5847: trac_5847-ecm-6.3.p1-p2.patch

File trac_5847-ecm-6.3.p1-p2.patch, 36.4 KB (added by leif, 9 years ago)

Mercurial patch to get the p2 from the p1 spkg. Except for the commit messages perhaps less readable. (6 changesets.)

  • SPKG.txt

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1290555801 -3600
    # Node ID 99fc2b00777525115b5b97ca3946a08c8a513ecc
    # Parent  093673613ed723ecf64c210e3775a3e7758bf2be
    #5847: ecm-6.3.p2: Fix SSE2 issue (upstream patch), work around Darwin linker bug, further improvements.
    
    === ecm-6.3.p2 (Leif Leonhardy, November 23rd, 2010) ===
     * Apply another patch from upstream to 'configure.in' to fix compilation
       on 32-bit x86 processors supporting SSE2. (#10252)
       (There's only a single, cumulative patch file since both patches are to
       'configure.in'.)
     * Work around linker bug on MacOS X 10.5 PPC (see Special Update/Build
       Instructions above, and #5847 comment 35 ff.).
     * Allow passing extra arguments to 'configure' through ECM_EXTRA_OPTS.
     * Add "-march=native" to CFLAGS on platforms that support it if CFLAGS
       do not already contain similar.
     * Print settings of CC, CFLAGS etc. and how we configure.
     * Print settings of CC and CFLAGS found in 'SAGE_LOCAL/include/gmp.h'
       and eventually a system-wide 'gmp.h'; these aren't yet used though.
     * Further clean-up.
    
    
    == Special Update/Build Instructions ==
    
     * src/ contains "stable" upstream code, to which we currently apply
       two upstream patches (both to 'configure.in'). These (i.e. the
       files 'patches/configure.in' and 'patches/configure') should be
       removed on the next upgrade to a stable release.
     * GMP-ECM comes with a self-tuning feature; we could support
       that as an option ($SAGE_TUNE_*=yes) in the future.
     * We currently work around a linker bug on MacOS X 10.5 PPC (with
       GCC 4.2.1) which breaks 'configure' if debug symbols are enabled.
       This *might* get fixed in later upstream releases.
     * ECM currently does not use the CC and CFLAGS settings from 'gmp.h'
       since we pass (other) options in CFLAGS (though MPIR currently doesn't
       use its own CFLAGS for the same reason); we could fix that somehow
       s.t. "optimized" code generation options ('-mcpu=...', '-mtune=...')
       are used by gcc. Of course a user can also manually enable them by
       setting the "global" CFLAGS to e.g. "-march=native" on x86 systems.
       Note that this doesn't affect the packages' selection of processor-
       specific optimized [assembly] code.
       'spkg-install' already reads those settings now, but doesn't yet
       use them.
       If SAGE_FAT_BINARY="yes", we should avoid too specific settings of
       "-mcpu=...", and perhaps pass a more generic "--host=..." to
       'configure'.
    
    diff -r 093673613ed7 -r 99fc2b007775 SPKG.txt
    a b  
    2424
    2525== Special Update/Build Instructions ==
    2626
    27  * src/ contains upstream code, no patches were applied.
     27 * src/ contains "stable" upstream code, to which we currently apply
     28   two upstream patches (both to 'configure.in'). These (i.e. the
     29   files 'patches/configure.in' and 'patches/configure') should be
     30   removed on the next upgrade to a stable release.
    2831 * GMP-ECM comes with a self-tuning feature; we could support
    2932   that as an option ($SAGE_TUNE_*=yes) in the future.
     33 * We currently work around a linker bug on MacOS X 10.5 PPC (with
     34   GCC 4.2.1) which breaks 'configure' if debug symbols are enabled.
     35   This *might* get fixed in later upstream releases.
     36 * ECM currently does not use the CC and CFLAGS settings from 'gmp.h'
     37   since we pass (other) options in CFLAGS (though MPIR currently doesn't
     38   use its own CFLAGS for the same reason); we could fix that somehow
     39   s.t. "optimized" code generation options ('-mcpu=...', '-mtune=...')
     40   are used by gcc. Of course a user can also manually enable them by
     41   setting the "global" CFLAGS to e.g. "-march=native" on x86 systems.
     42   Note that this doesn't affect the packages' selection of processor-
     43   specific optimized [assembly] code.
     44   'spkg-install' already reads those settings now, but doesn't yet
     45   use them.
     46   If SAGE_FAT_BINARY="yes", we should avoid too specific settings of
     47   "-mcpu=...", and perhaps pass a more generic "--host=..." to
     48   'configure'.
    3049
    3150== Changelog ==
    3251
     52=== ecm-6.3.p2 (Leif Leonhardy, November 23rd, 2010) ===
     53 * Apply another patch from upstream to 'configure.in' to fix compilation
     54   on 32-bit x86 processors supporting SSE2. (#10252)
     55   (There's only a single, cumulative patch file since both patches are to
     56   'configure.in'.)
     57 * Work around linker bug on MacOS X 10.5 PPC (see Special Update/Build
     58   Instructions above, and #5847 comment 35 ff.).
     59 * Allow passing extra arguments to 'configure' through ECM_EXTRA_OPTS.
     60 * Add "-march=native" to CFLAGS on platforms that support it if CFLAGS
     61   do not already contain similar.
     62 * Print settings of CC, CFLAGS etc. and how we configure.
     63 * Print settings of CC and CFLAGS found in 'SAGE_LOCAL/include/gmp.h'
     64   and eventually a system-wide 'gmp.h'; these aren't yet used though.
     65 * Further clean-up.
     66
    3367=== ecm-6.3.p1 (Jeroen Demeyer, November 10th, 2010) ===
    3468 * Apply a patch from upstream to configure.in to fix compilation
    3569   on 32-bit PowerPC processors.
  • spkg-install

    diff -r 093673613ed7 -r 99fc2b007775 spkg-install
    a b  
    77
    88# Note that GMP-ECM is written in C (and assembler) - no C++ sources.
    99
     10
     11# We could use / add these settings (or parts of them) later to "our" CFLAGS,
     12# e.g. "-march=..." or "-mcpu=..." and "-mtune=..." to let gcc generate better,
     13# processor-specific code, since ECM doesn't use them if we set our own:
     14# (But currently MPIR doesn't provide optimized settings either if we pass
     15# non-empty CFLAGS; of course the user could set such manually though.)
     16gmp_cc_pat='/^[         ]*#[    ]*define[       ]\+__GMP_CC[    ]\+/s/.*"\([^"]*\)"/\1/p'
     17gmp_cflags_pat='/^[     ]*#[    ]*define[       ]\+__GMP_CFLAGS[        ]\+/s/.*"\([^"]*\)"/\1/p'
     18
     19gmp_cc=`sed -n -e "$gmp_cc_pat" "$SAGE_LOCAL"/include/gmp.h`
     20gmp_cflags=`sed -n -e "$gmp_cflags_pat" "$SAGE_LOCAL"/include/gmp.h`
     21
     22system_gmp_h=""
     23for incdir in /usr/include /usr/local/include; do
     24    if [ -f $incdir/gmp.h ]; then
     25        system_gmp_h=$incdir/gmp.h
     26    fi
     27done
     28if [ -n "$system_gmp_h" ]; then
     29    system_gmp_cc=`sed -n -e "$gmp_cc_pat" $system_gmp_h`
     30    system_gmp_cflags=`sed -n -e "$gmp_cflags_pat" $system_gmp_h`
     31fi
     32
     33
    1034if [ "$SAGE64" = yes ]; then
    1135    echo "Building a 64-bit version of GMP-ECM"
    1236    if [ -z "$CFLAG64" ]; then
    1337        CFLAG64=-m64
    1438    fi
    15     CFLAGS="$CFLAGS $CFLAG64 -fPIC"
    16     LDFLAGS="$CFLAG64"; export LDFLAGS
     39    # CFLAGS="$CFLAGS $CFLAG64 -fPIC"
     40    CFLAGS="$CFLAGS $CFLAG64"
     41    LDFLAGS="$LDFLAGS $CFLAG64"; export LDFLAGS
    1742else
    18     CFLAGS="$CFLAGS -fPIC"
     43    # libtool should add the proper flags:
     44    # CFLAGS="$CFLAGS -fPIC"
     45    :;
    1946fi
    2047
    21 # We add debug symbols by default;
     48
    2249if [ "$SAGE_DEBUG" = yes ]; then
    23     # Disable optimization:
     50    # Add debug symbols and disable optimization:
    2451    CFLAGS="$CFLAGS -g -O0"
    2552else
    2653    # Enable optimization, may be overridden by user settings:
    27     CFLAGS="-g -O3 $CFLAGS"
     54    case "`uname -srm | tr ' ' '-'`" in
     55        Darwin-9*-[Pp]ower*)
     56            # Don't add debug symbols because configure otherwise
     57            # fails due to a bus error in Apple's 'ld' when trying
     58            # to determine if global symbols are prefixed with an
     59            # underscore (cf. http://trac.sagemath.org/sage_trac/ticket/5847#comment:35 ff.):
     60            echo "Warning: Disabling debug symbols on MacOS X 10.5" \
     61                "PowerPC because of a linker (?) bug."
     62            echo "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \
     63                "ff. for details."
     64            echo ""
     65            CFLAGS="-O3 $CFLAGS"
     66            ;;
     67        *)
     68            CFLAGS="-g -O3 $CFLAGS"
     69    esac
    2870fi
    2971
     72
     73if [ "$SAGE_FAT_BINARY" = yes ]; then
     74    echo "Warning: SAGE_FAT_BINARY is currently not really supported by this package."
     75else
     76    # XXX We don't yet test if CC is really gcc here.
     77    # gcc's "-march=native" only works on some platforms:
     78    case "`uname -m`" in
     79        i[3456]86|i86pc|x86_64|amd64)
     80            # Only add it if CFLAGS do not already contain similar:
     81            if ! (echo "$CFLAGS" | egrep -- '-march=|-mcpu=|-mtune=' >/dev/null);
     82            then
     83                CFLAGS="-march=native $CFLAGS"
     84            fi;;
     85    esac
     86fi
     87
     88
    3089export CFLAGS # usually redundant, but safe(r)
    3190
     91echo ""
     92echo "Settings from SAGE_LOCAL/include/gmp.h (currently not used):"
     93echo "    CC=$gmp_cc"
     94echo "    CFLAGS=$gmp_cflags"
     95if [ -n "$system_gmp_h" ]; then
     96    echo "Settings found in $system_gmp_h (also currently not used):"
     97    echo "    CC=$system_gmp_cc"
     98    echo "    CFLAGS=$system_gmp_cflags"
     99fi
     100
     101echo "Using CC=$CC"
     102echo "Using CFLAGS=$CFLAGS"
     103echo "Using CPPFLAGS=$CPPFLAGS"
     104echo "Using LDFLAGS=$LDFLAGS"
     105echo "Using ABI=$ABI"
     106echo "(These settings may get overridden by 'configure' or Makefiles.)"
     107echo ""
     108
    32109
    33110# Remove old executable/header/libraries/manpage:
    34 
    35111echo "Removing old binary, header file, manual page and libraries..."
    36112rm -f "$SAGE_LOCAL"/bin/ecm
    37113rm -f "$SAGE_LOCAL"/lib/libecm.*
     
    39115rm -f "$SAGE_LOCAL"/share/man/man1/ecm.1
    40116
    41117
     118unset RM
     119
     120
    42121cd src
    43122
    44 # Patch configure (and configure.in)
     123
     124# Patch configure (and configure.in):
     125# - Disable asm-redc on 32-bit Darwin PPCs (upstream revision 1516 / bug #10646)
     126# - Fix compilation error on x86 CPUs supporting SSE2. (Sage trac #10252,
     127#   upstream revision 1546)
     128echo "Copying patched files..."
    45129cp -p ../patches/configure ../patches/configure.in .
    46 if [ $? != 0 ]; then
    47         echo >&2 "Error patching configure and configure.in"
    48         exit 1
     130if [ $? -ne 0 ]; then
     131    echo "Error copying patched configure and configure.in."
     132    exit 1
    49133fi
    50134
    51135
    52 unset RM
     136# Note: Building (also) a *shared* library is disabled by default.
     137#       Add "--enable-shared" below if you want it, though one can
     138#       now pass extra 'configure' options through ECM_EXTRA_OPTS.
    53139
    54 # Note: Building (also) a *shared* library is disabled by default.
    55 #       Add "--enable-shared" below if you want it.
     140SAGE_CONF_OPTS=""
    56141
    57 ./configure --with-gmp="$SAGE_LOCAL"  --prefix="$SAGE_LOCAL"
     142echo ""
     143if [ -z "$ECM_EXTRA_OPTS" ]; then
     144    echo "Configuring GMP-ECM with the following options:"
     145    echo "    --prefix=\"$SAGE_LOCAL\" --with-gmp=\"$SAGE_LOCAL\"" \
     146        "$SAGE_CONF_OPTS"
     147    echo "You can set ECM_EXTRA_OPTS to pass additional parameters,"
     148    echo "e.g. \"--enable-shared\" to also build a *shared* library,"
     149    echo "or \"--disable-sse2\" if you encounter problems on a Pentium III system."
     150else
     151    echo "Using additional 'configure' options as specified with" \
     152        "ECM_EXTRA_OPTS:"
     153    echo "    $ECM_EXTRA_OPTS"
     154    echo "Configuring ECM with the following options:"
     155    echo "    --prefix=\"$SAGE_LOCAL\" --with-gmp=\"$SAGE_LOCAL\"" \
     156        "$SAGE_CONF_OPTS $ECM_EXTRA_OPTS"
     157fi
     158echo ""
    58159
     160./configure --prefix="$SAGE_LOCAL" --with-gmp="$SAGE_LOCAL" \
     161    $SAGE_CONF_OPTS $ECM_EXTRA_OPTS
    59162if [ $? -ne 0 ]; then
    60163    echo "Error configuring GMP-ECM."
    61164    exit 1
    62165fi
    63166
    64167$MAKE
    65 
    66168if [ $? -ne 0 ]; then
    67169    echo "Error building GMP-ECM."
    68170    exit 1
    69171fi
    70172
    71 
    72173$MAKE install
    73 
    74174if [ $? -ne 0 ]; then
    75175    echo "Error installing GMP-ECM (though it appears to have built fine)."
    76176    exit 1
  • deleted file patches/configure.patch

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1290555928 -3600
    # Node ID b3b13116961942342cb445f02518ca13d0d77803
    # Parent  99fc2b00777525115b5b97ca3946a08c8a513ecc
    Tell Mercurial the obsolete patches/configure.patch has been removed.
    
    diff -r 99fc2b007775 -r b3b131169619 patches/configure.patch
    + -  
    1 diff -r -u src.old/configure src/configure
    2 --- src.old/configure   2010-04-18 22:17:12.000000000 +0200
    3 +++ src/configure       2010-11-10 11:21:04.000000000 +0100
    4 @@ -12340,7 +12340,7 @@
    5  # asm_redc enabled by default for x86_64 and 64 bit PowerPC
    6  if test "x$enable_asm_redc" = x; then
    7    case $host in
    8 -    x86_64* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
    9 +    x86_64*-*-* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
    10      *) enable_asm_redc=no;;
    11    esac
    12  fi
    13 @@ -12348,8 +12348,59 @@
    14  if test "x$enable_asm_redc" = xyes; then
    15    case $host in
    16      pentium4-*-* | pentium3-*-* | viac7-*-* | i786-*-*) ASMPATH=pentium4;;
    17 -    x86_64-*-*)  ASMPATH=x86_64;;
    18 -    powerpc-apple-darwin*) ASMPATH=powerpc64;;
    19 +    x86_64*-*-*)  ASMPATH=x86_64;;
    20 +# warning: with powerpc-apple-darwin* we can have ABI=32
    21 +# see bug #10646 on the bug tracker, where config.guess says
    22 +# powerpc-apple-darwin8.11.0 (this a 64-bit machine, but most applications
    23 +# are compiled in 32 bits). It works with --disable-asm-redc.
    24 +    powerpc-apple-darwin*)
    25 +cat >conftest.$ac_ext <<_ACEOF
    26 +/* confdefs.h.  */
    27 +_ACEOF
    28 +cat confdefs.h >>conftest.$ac_ext
    29 +cat >>conftest.$ac_ext <<_ACEOF
    30 +/* end confdefs.h.  */
    31 +
    32 +#if defined(__ppc__)
    33 +#error
    34 +#endif
    35 +int
    36 +main ()
    37 +{
    38 +
    39 +  ;
    40 +  return 0;
    41 +}
    42 +_ACEOF
    43 +if { (ac_try="$ac_cpp conftest.$ac_ext"
    44 +case "(($ac_try" in
    45 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
    46 +  *) ac_try_echo=$ac_try;;
    47 +esac
    48 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
    49 +$as_echo "$ac_try_echo") >&5
    50 +  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
    51 +  ac_status=$?
    52 +  grep -v '^ *+' conftest.er1 >conftest.err
    53 +  rm -f conftest.er1
    54 +  cat conftest.err >&5
    55 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
    56 +  (exit $ac_status); } >/dev/null && {
    57 +        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
    58 +        test ! -s conftest.err
    59 +       }; then
    60 +  :
    61 +else
    62 +  $as_echo "$as_me: failed program was:" >&5
    63 +sed 's/^/| /' conftest.$ac_ext >&5
    64 +
    65 +  { $as_echo "$as_me:$LINENO: 32-bit PowerPC, disabling asm-redc" >&5
    66 +$as_echo "$as_me: 32-bit PowerPC, disabling asm-redc" >&6;}
    67 +                enable_asm_redc=no
    68 +fi
    69 +
    70 +rm -f conftest.err conftest.$ac_ext
    71 +                          ASMPATH=powerpc64;;
    72      powerpc64-*-linux*)
    73  
    74  echo "include(<"$srcdir"/powerpc64/powerpc-defs.m4>)" >> $gmp_tmpconfigm4
    75 @@ -12362,7 +12413,9 @@
    76  $as_echo "$as_me: error: asm redc not available on this machine $host" >&2;}
    77     { (exit 1); exit 1; }; };;
    78    esac
    79 +fi
    80  
    81 +if test "x$enable_asm_redc" = xyes; then
    82  # do the necessary definitions and includes
    83  
    84  cat >>confdefs.h <<\_ACEOF
    85 diff -r -u src.old/configure.in src/configure.in
    86 --- src.old/configure.in        2010-04-18 22:03:10.000000000 +0200
    87 +++ src/configure.in    2010-11-10 11:20:51.000000000 +0100
    88 @@ -195,7 +195,7 @@
    89  # asm_redc enabled by default for x86_64 and 64 bit PowerPC
    90  if test "x$enable_asm_redc" = x; then
    91    case $host in
    92 -    x86_64* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
    93 +    x86_64*-*-* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
    94      *) enable_asm_redc=no;;
    95    esac
    96  fi
    97 @@ -203,8 +203,18 @@
    98  if test "x$enable_asm_redc" = xyes; then
    99    case $host in
    100      pentium4-*-* | pentium3-*-* | viac7-*-* | i786-*-*) ASMPATH=pentium4;;
    101 -    x86_64-*-*)  ASMPATH=x86_64;;
    102 -    powerpc-apple-darwin*) ASMPATH=powerpc64;;
    103 +    x86_64*-*-*)  ASMPATH=x86_64;;
    104 +# warning: with powerpc-apple-darwin* we can have ABI=32
    105 +# see bug #10646 on the bug tracker, where config.guess says
    106 +# powerpc-apple-darwin8.11.0 (this a 64-bit machine, but most applications
    107 +# are compiled in 32 bits). It works with --disable-asm-redc.
    108 +    powerpc-apple-darwin*)
    109 +AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
    110 +#if defined(__ppc__)
    111 +#error
    112 +#endif])], [], [AC_MSG_NOTICE([32-bit PowerPC, disabling asm-redc])
    113 +                enable_asm_redc=no])
    114 +                          ASMPATH=powerpc64;;
    115      powerpc64-*-linux*)
    116                           ECM_INCLUDE([<"$srcdir"/powerpc64/powerpc-defs.m4>])
    117                           ASMPATH=powerpc64;;
    118 @@ -213,7 +223,9 @@
    119                           ASMPATH=athlon;;
    120      *) AC_MSG_ERROR([[asm redc not available on this machine $host]]);;
    121    esac
    122 +fi
    123  
    124 +if test "x$enable_asm_redc" = xyes; then
    125  # do the necessary definitions and includes
    126    AC_DEFINE([NATIVE_REDC],1,[Define to 1 to use asm redc])
    127    test "x$CCAS" != x || CCAS="$CC -c"
  • new file patches/configure.in.patch

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1290556611 -3600
    # Node ID d01a29372b9f5afe21e77e6d4bc30d3725fcafc3
    # Parent  b3b13116961942342cb445f02518ca13d0d77803
    Add patches/configure.in.patch to the repo, which Mercurial completely ignored.
    
    This is the cumulative patch (2 upstream fixes) to 'configure.in' only, not 'configure'.
    
    Note that the patched 'configure' created from that is not under revision control.
    
    diff -r b3b131169619 -r d01a29372b9f patches/configure.in.patch
    - +  
     1--- configure.in.orig   2010-04-18 22:03:10.000000000 +0200
     2+++ configure.in        2010-11-23 20:03:33.000000000 +0100
     3@@ -195,7 +195,7 @@
     4 # asm_redc enabled by default for x86_64 and 64 bit PowerPC
     5 if test "x$enable_asm_redc" = x; then
     6   case $host in
     7-    x86_64* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
     8+    x86_64*-*-* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
     9     *) enable_asm_redc=no;;
     10   esac
     11 fi
     12@@ -203,8 +203,18 @@
     13 if test "x$enable_asm_redc" = xyes; then
     14   case $host in
     15     pentium4-*-* | pentium3-*-* | viac7-*-* | i786-*-*) ASMPATH=pentium4;;
     16-    x86_64-*-*)  ASMPATH=x86_64;;
     17-    powerpc-apple-darwin*) ASMPATH=powerpc64;;
     18+    x86_64*-*-*)  ASMPATH=x86_64;;
     19+# warning: with powerpc-apple-darwin* we can have ABI=32
     20+# see bug #10646 on the bug tracker, where config.guess says
     21+# powerpc-apple-darwin8.11.0 (this a 64-bit machine, but most applications
     22+# are compiled in 32 bits). It works with --disable-asm-redc.
     23+    powerpc-apple-darwin*)
     24+AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
     25+#if defined(__ppc__)
     26+#error
     27+#endif])], [], [AC_MSG_NOTICE([32-bit PowerPC, disabling asm-redc])
     28+                enable_asm_redc=no])
     29+                          ASMPATH=powerpc64;;
     30     powerpc64-*-linux*)
     31                          ECM_INCLUDE([<"$srcdir"/powerpc64/powerpc-defs.m4>])
     32                          ASMPATH=powerpc64;;
     33@@ -213,7 +223,9 @@
     34                          ASMPATH=athlon;;
     35     *) AC_MSG_ERROR([[asm redc not available on this machine $host]]);;
     36   esac
     37+fi
     38 
     39+if test "x$enable_asm_redc" = xyes; then
     40 # do the necessary definitions and includes
     41   AC_DEFINE([NATIVE_REDC],1,[Define to 1 to use asm redc])
     42   test "x$CCAS" != x || CCAS="$CC -c"
     43@@ -275,9 +287,9 @@
     44   AC_MSG_CHECKING([for SSE2 support])
     45   m4_define([SSE2_TEST_PROG], [AC_LANG_PROGRAM([], dnl
     46 [#if (defined(__GNUC__) || defined(__ICL)) && defined(__i386__)
     47-/* When there are no constraints, registers are referred to by
     48-   single % sign, not double. Argh */
     49-asm volatile ("pmuludq %xmm2, %xmm0");
     50+/* On some machines, a program without constraints may pass without -msse2 but
     51+   those with constraints in spv.c fail, thus we test with constraints here. */
     52+asm volatile ("pmuludq %%xmm2, %%xmm0" : : :"%xmm0");
     53 #else
     54 #error
     55 #IRIXdoesnotexitaterrordirective
  • spkg-install

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1290675503 -3600
    # Node ID 83c1224d374850e7ccbbbdf2e58f9e005bdb5647
    # Parent  d01a29372b9f5afe21e77e6d4bc30d3725fcafc3
    #5847 (ecm-6.3.p2): Put back '-fPIC', don't add '-march=native' on older GCC versions, add some tuning parameters from MPIR if available.
    
    We in fact need the '-fPIC' flags unless we build a shared library (where
    libtool adds this). Alternatively, not very much tested, we could use the
    '--with-pic' option to configure. Either is optimal if we do it uncondi-
    tionally.
    
    '-march=native' now only gets added if the compliler really supports it
    (not necessarily limited to 'gcc'), since some older GCC 4.0.x versions
    don't support it. If '-march=native' isn't supported, we try to get the
    processor-specific settings from GMP / MPIR, recorded in Sage's 'gmp.h'.
    
    Some cosmetic changes. Deletion of previous installation is still per-
    formed before we know the (re)build succeeded.
    
    Selection of effective CFLAGS can be improved further, still respecting
    user-specified settings though. If the user didn't specify any, we can
    use the full set of CFLAGS from 'gmp.h' with some additions if required.
    (There'll be an MPIR 2.1.3.p2 spkg that exactly does such, so we can
    adopt more from there later, also in the MPFR spkg.)
    
    diff -r d01a29372b9f -r 83c1224d3748 spkg-install
    a b  
    55    exit 1
    66fi
    77
     8###############################################################################
     9# Apply patches (if any):
     10###############################################################################
     11
     12# Patch configure (and configure.in):
     13# - Disable asm-redc on 32-bit Darwin PPCs (upstream revision 1516 / bug #10646)
     14# - Fix compilation error on x86 CPUs supporting SSE2. (Sage trac #10252,
     15#   upstream revision 1546)
     16echo "Copying patched files..."
     17cp -p patches/configure patches/configure.in src/
     18if [ $? -ne 0 ]; then
     19    echo "Error copying patched configure and configure.in."
     20    exit 1
     21fi
     22
     23# XXX MOVE THIS DOWN (after *successful* build)!!!
     24###############################################################################
     25# Remove old executable/header/libraries/manpage:
     26###############################################################################
     27echo "Removing old binary, header file, manual page and libraries..."
     28rm -f "$SAGE_LOCAL"/bin/ecm
     29rm -f "$SAGE_LOCAL"/lib/libecm.*
     30rm -f "$SAGE_LOCAL"/include/ecm.h
     31rm -f "$SAGE_LOCAL"/share/man/man1/ecm.1
     32
     33###############################################################################
     34# Set up environment variables, depending on SAGE_* settings:
    835# Note that GMP-ECM is written in C (and assembler) - no C++ sources.
     36###############################################################################
    937
    10 
    11 # We could use / add these settings (or parts of them) later to "our" CFLAGS,
     38# We eventually use / add these settings (or parts of them) to "our" CFLAGS,
    1239# e.g. "-march=..." or "-mcpu=..." and "-mtune=..." to let gcc generate better,
    1340# processor-specific code, since ECM doesn't use them if we set our own:
    1441# (But currently MPIR doesn't provide optimized settings either if we pass
     
    3057    system_gmp_cflags=`sed -n -e "$gmp_cflags_pat" $system_gmp_h`
    3158fi
    3259
     60cc_is_gcc=false
     61if $CC -v 2>&1 | grep -i gcc &>/dev/null; then
     62    cc_is_gcc=true;
     63fi
     64
    3365
    3466if [ "$SAGE64" = yes ]; then
    3567    echo "Building a 64-bit version of GMP-ECM"
    3668    if [ -z "$CFLAG64" ]; then
    3769        CFLAG64=-m64
    3870    fi
    39     # CFLAGS="$CFLAGS $CFLAG64 -fPIC"
    4071    CFLAGS="$CFLAGS $CFLAG64"
    4172    LDFLAGS="$LDFLAGS $CFLAG64"; export LDFLAGS
    4273else
    43     # libtool should add the proper flags:
    44     # CFLAGS="$CFLAGS -fPIC"
    4574    :;
    4675fi
    4776
    4877
     78# libtool should add the proper flags, but doesn't use "-fPIC"
     79# for the *static* library (which the Sage library links to unless
     80# we also build the shared one):
     81CFLAGS="$CFLAGS -fPIC" # alternatively add '--with-pic' to 'configure' options
     82
     83
    4984if [ "$SAGE_DEBUG" = yes ]; then
    5085    # Add debug symbols and disable optimization:
    5186    CFLAGS="$CFLAGS -g -O0"
     
    71106
    72107
    73108if [ "$SAGE_FAT_BINARY" = yes ]; then
     109    # XXX Disable SSE2 on x86? (by passing '--enable-sse2=no' to 'configure')
     110    # XXX Disable asm-redc? Or pass some "generic" '--host=...' to 'configure'?
    74111    echo "Warning: SAGE_FAT_BINARY is currently not really supported by this package."
     112    echo "         Add e.g. '--disable-asm-redc' and/or '--enable-sse2=no'"
     113    echo "         to ECM_EXTRA_OPTS if you run into problems."
    75114else
    76     # XXX We don't yet test if CC is really gcc here.
    77     # gcc's "-march=native" only works on some platforms:
    78     case "`uname -m`" in
    79         i[3456]86|i86pc|x86_64|amd64)
    80             # Only add it if CFLAGS do not already contain similar:
    81             if ! (echo "$CFLAGS" | egrep -- '-march=|-mcpu=|-mtune=' >/dev/null);
    82             then
    83                 CFLAGS="-march=native $CFLAGS"
    84             fi;;
    85     esac
     115    # Tune the code generation to the machine we build on:
     116    cpu_params=""; other_gmp_cflags=""
     117
     118    # Some gcc 4.0.x versions don't support '-march=native', and it's currently
     119    # not supported on all platforms supported by Sage:
     120    if false && touch foo.c && $CC -march=native -c foo.c &>/dev/null; then
     121        cpu_params="-march=native"
     122    else
     123        # 'native' not supported, see if GMP / MPIR provides us some CPU type:
     124        for opt in $gmp_cflags; do
     125            case $opt in
     126                -march=*|-mcpu=*|-mtune*)
     127                    echo "Found CPU parameter in gmp.h: $opt"
     128                    cpu_params="$cpu_params $opt"
     129                    ;;
     130                 # perhaps add other options, too (e.g. for different compilers)
     131                 *) other_gmp_cflags="$other_gmp_cflags $opt"
     132            esac
     133        done
     134    fi
     135    rm -f foo.*
     136    # Only add them if CFLAGS do not already contain similar:
     137    if [ -n "$cpu_params" ] &&
     138        ! (echo "$CFLAGS" | egrep -- '-march=|-mcpu=|-mtune=' >/dev/null);
     139    then
     140        echo "Using additional host-specific CFLAGS: $cpu_params"
     141        CFLAGS="$cpu_params $CFLAGS"
     142    fi
     143    if [ -n "$other_gmp_cflags" ]; then
     144        echo "Not using other CFLAGS provided by gmp.h: $other_gmp_cflags"
     145    fi
    86146fi
    87147
    88148
    89 export CFLAGS # usually redundant, but safe(r)
    90 
    91149echo ""
    92 echo "Settings from SAGE_LOCAL/include/gmp.h (currently not used):"
     150echo "Settings from SAGE_LOCAL/include/gmp.h:"
    93151echo "    CC=$gmp_cc"
    94152echo "    CFLAGS=$gmp_cflags"
    95153if [ -n "$system_gmp_h" ]; then
    96     echo "Settings found in $system_gmp_h (also currently not used):"
     154    echo "Settings found in $system_gmp_h (currently not used):"
    97155    echo "    CC=$system_gmp_cc"
    98156    echo "    CFLAGS=$system_gmp_cflags"
    99157fi
     
    106164echo "(These settings may get overridden by 'configure' or Makefiles.)"
    107165echo ""
    108166
    109 
    110 # Remove old executable/header/libraries/manpage:
    111 echo "Removing old binary, header file, manual page and libraries..."
    112 rm -f "$SAGE_LOCAL"/bin/ecm
    113 rm -f "$SAGE_LOCAL"/lib/libecm.*
    114 rm -f "$SAGE_LOCAL"/include/ecm.h
    115 rm -f "$SAGE_LOCAL"/share/man/man1/ecm.1
    116 
     167export CFLAGS # usually redundant, but safe(r)
    117168
    118169unset RM
    119170
    120 
    121171cd src
    122172
    123 
    124 # Patch configure (and configure.in):
    125 # - Disable asm-redc on 32-bit Darwin PPCs (upstream revision 1516 / bug #10646)
    126 # - Fix compilation error on x86 CPUs supporting SSE2. (Sage trac #10252,
    127 #   upstream revision 1546)
    128 echo "Copying patched files..."
    129 cp -p ../patches/configure ../patches/configure.in .
    130 if [ $? -ne 0 ]; then
    131     echo "Error copying patched configure and configure.in."
    132     exit 1
    133 fi
    134 
    135 
    136 # Note: Building (also) a *shared* library is disabled by default.
    137 #       Add "--enable-shared" below if you want it, though one can
    138 #       now pass extra 'configure' options through ECM_EXTRA_OPTS.
     173###############################################################################
     174# Now configure ECM:
     175# (Note: Building (also) a *shared* library is disabled by default.
     176#        Add "--enable-shared" below if you want it, though one can
     177#        now pass extra 'configure' options through ECM_EXTRA_OPTS.)
     178###############################################################################
    139179
    140180SAGE_CONF_OPTS=""
    141181
     
    164204    exit 1
    165205fi
    166206
     207###############################################################################
     208# Now build and install ECM:
     209###############################################################################
     210
    167211$MAKE
    168212if [ $? -ne 0 ]; then
    169213    echo "Error building GMP-ECM."
  • SPKG.txt

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1290678500 -3600
    # Node ID e6f67cda5d40639fb77e25ee31459adae5d1b750
    # Parent  83c1224d374850e7ccbbbdf2e58f9e005bdb5647
    #5847 (ecm-6.3.p2): Moved deletion of previous installs (*below* building), updated SPKG.txt.
    
    diff -r 83c1224d3748 -r e6f67cda5d40 SPKG.txt
    a b  
    3333 * We currently work around a linker bug on MacOS X 10.5 PPC (with
    3434   GCC 4.2.1) which breaks 'configure' if debug symbols are enabled.
    3535   This *might* get fixed in later upstream releases.
    36  * ECM currently does not use the CC and CFLAGS settings from 'gmp.h'
    37    since we pass (other) options in CFLAGS (though MPIR currently doesn't
    38    use its own CFLAGS for the same reason); we could fix that somehow
    39    s.t. "optimized" code generation options ('-mcpu=...', '-mtune=...')
    40    are used by gcc. Of course a user can also manually enable them by
    41    setting the "global" CFLAGS to e.g. "-march=native" on x86 systems.
     36 * ECM currently does not (by itself) use the CC and CFLAGS settings
     37   from 'gmp.h' since we pass (other) options in CFLAGS, and CC is set
     38   by Sage and might got set by the user (though MPIR currently doesn't
     39   use its own CFLAGS for the same reason, which is fixed in an MPIR
     40   2.1.3.p2 spkg). We now at least partially fix that s.t. "optimized"
     41   code generation options ('-mcpu=...', '-mtune=...') are used by gcc.
     42   Of course a user can also manually enable them by setting the "global"
     43   CFLAGS to e.g. '-march=native' on x86[_64] systems, or '-mcpu=...' and
     44   '-mtune=...' on other architectures where "native" isn't supported.
    4245   Note that this doesn't affect the packages' selection of processor-
    4346   specific optimized [assembly] code.
    44    'spkg-install' already reads those settings now, but doesn't yet
    45    use them.
     47   'spkg-install' already reads the settings from Sage's and also a
     48   system-wide GMP / MPIR now, but doesn't (yet) use all of them.
    4649   If SAGE_FAT_BINARY="yes", we should avoid too specific settings of
    4750   "-mcpu=...", and perhaps pass a more generic "--host=..." to
    48    'configure'.
     51   'configure'. (MPIR honors '--enable-fat' to some extent, but this
     52   option isn't used on anything other than x86 / x86_64.)
    4953
    5054== Changelog ==
    5155
    52 === ecm-6.3.p2 (Leif Leonhardy, November 23rd, 2010) ===
    53  * Apply another patch from upstream to 'configure.in' to fix compilation
    54    on 32-bit x86 processors supporting SSE2. (#10252)
     56=== ecm-6.3.p2 (Leif Leonhardy, November 25th, 2010) ===
     57 * #5847: Apply another patch from upstream to 'configure.in' to fix com-
     58   pilation on 32-bit x86 processors supporting SSE2. (Also #10252.)
    5559   (There's only a single, cumulative patch file since both patches are to
    5660   'configure.in'.)
    5761 * Work around linker bug on MacOS X 10.5 PPC (see Special Update/Build
    5862   Instructions above, and #5847 comment 35 ff.).
    5963 * Allow passing extra arguments to 'configure' through ECM_EXTRA_OPTS.
    60  * Add "-march=native" to CFLAGS on platforms that support it if CFLAGS
    61    do not already contain similar.
     64 * Add "-march=native" to CFLAGS on platforms that support it, or use
     65   processor-specific CFLAGS from GMP's / MPIR's 'gmp.h' if available,
     66   but only if CFLAGS do not already contain similar (i.e., don't over-
     67   ride a user's choice). [Subject to further improvement.]
    6268 * Print settings of CC, CFLAGS etc. and how we configure.
    6369 * Print settings of CC and CFLAGS found in 'SAGE_LOCAL/include/gmp.h'
    64    and eventually a system-wide 'gmp.h'; these aren't yet used though.
     70   and eventually a system-wide 'gmp.h', although the latter aren't (yet)
     71   used at all, and only processor-specific parts of the former.
     72 * Don't delete previous installations unless the build succeeded.
    6573 * Further clean-up.
    6674
    6775=== ecm-6.3.p1 (Jeroen Demeyer, November 10th, 2010) ===
    68  * Apply a patch from upstream to configure.in to fix compilation
     76 * #5847: Apply a patch from upstream to configure.in to fix compilation
    6977   on 32-bit PowerPC processors.
    7078
    7179=== ecm-6.3.p0 (Leif Leonhardy, November 4th, 2010) ===
  • spkg-install

    diff -r 83c1224d3748 -r e6f67cda5d40 spkg-install
    a b  
    2020    exit 1
    2121fi
    2222
    23 # XXX MOVE THIS DOWN (after *successful* build)!!!
    24 ###############################################################################
    25 # Remove old executable/header/libraries/manpage:
    26 ###############################################################################
    27 echo "Removing old binary, header file, manual page and libraries..."
    28 rm -f "$SAGE_LOCAL"/bin/ecm
    29 rm -f "$SAGE_LOCAL"/lib/libecm.*
    30 rm -f "$SAGE_LOCAL"/include/ecm.h
    31 rm -f "$SAGE_LOCAL"/share/man/man1/ecm.1
    32 
    3323###############################################################################
    3424# Set up environment variables, depending on SAGE_* settings:
    3525# Note that GMP-ECM is written in C (and assembler) - no C++ sources.
     
    205195fi
    206196
    207197###############################################################################
    208 # Now build and install ECM:
     198# Now build ECM:
    209199###############################################################################
    210200
    211201$MAKE
     
    214204    exit 1
    215205fi
    216206
     207###############################################################################
     208# Remove old executable/header/libraries/manpage:
     209###############################################################################
     210echo "Build succeeded, removing old binary, header file, manual page and libraries..."
     211rm -f "$SAGE_LOCAL"/bin/ecm
     212rm -f "$SAGE_LOCAL"/lib/libecm.*
     213rm -f "$SAGE_LOCAL"/include/ecm.h
     214rm -f "$SAGE_LOCAL"/share/man/man1/ecm.1
     215
     216###############################################################################
     217# Now install ECM:
     218###############################################################################
     219
    217220$MAKE install
    218221if [ $? -ne 0 ]; then
    219222    echo "Error installing GMP-ECM (though it appears to have built fine)."
  • SPKG.txt

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1290683969 -3600
    # Node ID 13cc8339d10bc43ee23e6e1ee7996ad1e1f5f677
    # Parent  e6f67cda5d40639fb77e25ee31459adae5d1b750
    #5847 (ecm-6.3.p2): Don't unconditionally add '-fPIC'; remove code from testing ("if false...").
    
    Only add '-fPIC' to CFLAGS if we're not building a shared library and '--with-pic'
    was not given. (libtool correctly builds the shared library without that.)
    
    Not using PIC is usually faster, so we don't build the *static* library with PIC
    in case the Sage library uses a shared one (which of course uses PIC).
    
    diff -r e6f67cda5d40 -r 13cc8339d10b SPKG.txt
    a b  
    6969 * Print settings of CC and CFLAGS found in 'SAGE_LOCAL/include/gmp.h'
    7070   and eventually a system-wide 'gmp.h', although the latter aren't (yet)
    7171   used at all, and only processor-specific parts of the former.
     72 * Add '-fPIC' conditionally, i.e. not if we're also building a shared
     73   library (or '--with-pic' was given).
    7274 * Don't delete previous installations unless the build succeeded.
    7375 * Further clean-up.
    7476
  • spkg-install

    diff -r e6f67cda5d40 -r 13cc8339d10b spkg-install
    a b  
    6767
    6868# libtool should add the proper flags, but doesn't use "-fPIC"
    6969# for the *static* library (which the Sage library links to unless
    70 # we also build the shared one):
    71 CFLAGS="$CFLAGS -fPIC" # alternatively add '--with-pic' to 'configure' options
     70# we also build the shared one). The following only handles the
     71# most common cases, not all variations with '=yes' or '=no' etc.:
     72if ! (echo $ECM_EXTRA_OPTS | egrep -- "--enable-shared|--with-pic" >/dev/null) ||
     73     (echo $ECM_EXTRA_OPTS | egrep -- "--disable-shared" >/dev/null);
     74then
     75    echo "Adding '-fPIC' to CFLAGS since we don't (also) build a shared library."
     76    CFLAGS="$CFLAGS -fPIC" # alternatively add '--with-pic' to 'configure' options
     77else
     78    # PIC usually slows down the execution, so don't use it for the *static*
     79    # library (unless '--with-pic' was given). libtool does the right thing
     80    # for the shared one we also build, which then will be used by Sage.
     81    echo "Not adding '-fPIC' since we also build a shared library Sage will link"
     82    echo "to, or '--with-pic' was given in ECM_EXTRA_OPTS."
     83fi
    7284
    7385
    7486if [ "$SAGE_DEBUG" = yes ]; then
     
    107119
    108120    # Some gcc 4.0.x versions don't support '-march=native', and it's currently
    109121    # not supported on all platforms supported by Sage:
    110     if false && touch foo.c && $CC -march=native -c foo.c &>/dev/null; then
     122    if touch foo.c && $CC -march=native -c foo.c &>/dev/null; then
    111123        cpu_params="-march=native"
    112124    else
    113125        # 'native' not supported, see if GMP / MPIR provides us some CPU type:
     
    165177# (Note: Building (also) a *shared* library is disabled by default.
    166178#        Add "--enable-shared" below if you want it, though one can
    167179#        now pass extra 'configure' options through ECM_EXTRA_OPTS.)
     180#        If you do so, i.e. add '--enable-shared' by default, also
     181#        adapt the logic regarding '-fPIC' above.
    168182###############################################################################
    169183
    170184SAGE_CONF_OPTS=""