Ticket #12830: ecm-6.3.p5-p6.diff

File ecm-6.3.p5-p6.diff, 17.7 KB (added by leif, 3 years ago)

Diff between my p5 and p6 spkgs. For reference / review only.

  • .hgignore

    diff --git a/.hgignore b/.hgignore
    a b  
    11src 
    2 patches/configure 
    3 patches/configure.in 
  • .hgtags

    diff --git a/.hgtags b/.hgtags
    a b  
    224d6646f19caecfa0810d3341a8a1361cb529a7b4 ecm-6.3.p3 
    3362e5a142f7157c6dfa8ab59fc9228208326507ad ecm-6.3.p4 
    4414c0237361c1ffefdcece11d745f3381ec009a46 ecm-6.3.p5 
     57ac46fc5997fb25668f35b8571f48af69f5859f4 ecm-6.3.p6 
  • SPKG.txt

    diff --git a/SPKG.txt b/SPKG.txt
    a b  
    2121== Dependencies == 
    2222 
    2323 * GMP/MPIR (Note: Python is *not* required for ordinary builds.) 
     24 * GNU patch 
    2425 
    2526== Special Update/Build Instructions == 
    2627 
    27  * src/ contains "stable" upstream code, to which we currently apply 
    28    one upstream patch (to 'configure'). This (i.e., the file 
    29    'patches/configure') should be removed on the next upgrade to a stable 
    30    release. 
     28 * src/ contains "stable" upstream code, to which we currently apply a single 
     29   upstream patch (to 'configure'). The patch should be removed on the next 
     30   upgrade to a stable release. 
     31   Note that all autotools-generated files (and their support files) in src/ 
     32   have been regenerated with newer versions of autotools (autoconf 2.68, 
     33   automake 1.11.3 and libtool 2.4.2), to make the size of the patch to the 
     34   also generated `configure` acceptable.  (See "Patches" section below for 
     35   why we don't patch `configure.in`, from which `configure` is created.) 
    3136 * GMP-ECM comes with a self-tuning feature; we could support 
    3237   that as an option ($SAGE_TUNE_*=yes) in the future. 
    3338 * We currently work around a linker bug on MacOS X 10.5 PPC (with 
     
    3540   This *might* get fixed in later upstream releases. 
    3641 * ECM currently does not (by itself) use the CC and CFLAGS settings 
    3742   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. 
     43   by Sage and might got set by the user.  We now at least partially fix that 
     44   such that "optimized" code generation options ('-mcpu=...', '-mtune=...') 
     45   are used by gcc. 
    4246   Of course a user can also manually enable them by setting the "global" 
    4347   CFLAGS to e.g. '-march=native' on x86[_64] systems, or '-mcpu=...' and 
    4448   '-mtune=...' on other architectures where "native" isn't supported. 
     
    5054   "-mcpu=...", and perhaps pass a more generic "--host=..." to  
    5155   'configure'. (MPIR honors '--enable-fat' to some extent, but this 
    5256   option isn't used on anything other than x86 / x86_64.) 
     57 * Check whether the work-around for GCC 4.7 on ia64 is still appropriate, i.e. 
     58   adapt it in case the issue has been fixed in later GCC versions of the 4.7 
     59   release series.  (Although the bug currently affects only GCC 4.7.0, it 
     60   seems unlikely that it will be fixed soon, hence we apply the work-around 
     61   for any GCC 4.7.x version on ia64.) 
     62   See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48496 for details and the 
     63   current status of that bug. 
     64 * We could save some space by removing the `src/build.vc9/` directory which 
     65   isn't used in Sage.  (It gets probably more worth in case also directories / 
     66   files for later versions of Microsoft Visual C get added.)  
     67 
     68=== Patches === 
     69 * configure.patch: 
     70   - Disable "asm-redc" on 32-bit Darwin PPCs (upstream revision 1516 / bug 
     71     #10646). 
     72     (Note that this upstream patch is likely to slow down GMP-ECM on 64-bit 
     73     PPC CPUs running (32-bit) MacOS X, since the extended instruction set of 
     74     the CPU is no longer exploitet.  A proper fix would just pass an option 
     75     to Apple's assembler to allow the use of the extended instruction set.)   
     76   - Fix compilation error on x86 CPUs supporting SSE2. (Sage trac #10252, 
     77     upstream revision 1546). 
     78   Note that we don't patch `configure.in`, since it is only needed to generate 
     79   automatically-generated files in the source tree.  Patching `configure.in` 
     80   would force `automake` to be run, which could cause build failures on 
     81   systems where autotools aren't installed. 
     82 
    5383 
    5484== Changelog == 
    5585 
     86=== ecm-6.3.p6 (Leif Leonhardy, April 16th 2012) === 
     87 * #12830: Add a work-around for GCC 4.7.x on ia64 (Itanium), since GMP-ECM 
     88   currently won't build with that and anything but `-O0` on that platform. 
     89 * Use `\{1,\}` instead of `\+` in `sed` patterns, which is more portable. 
     90 * Also support newer system-wide MPIR installations for printing their 
     91   settings. 
     92 * Use `patch` to apply patches.  Since the pre-patched `configure` in 
     93   `patches/` was created with a newer version of autotools (or, rather, the 
     94   original `configure` was created with an outdated version), the patch would 
     95   have been almost as large as the patched `configure` file itself.  Hence 
     96   I `autoreconf`ed the source tree with a patched `configure.in` (and almost 
     97   the latest versions of autotools), then created a patch to `configure` 
     98   from the resulting file(s).  Note that therefore `src/` isn't really vanilla 
     99   any more, although just the auto-generated files differ (which are still 
     100   made from vanilla upstream sources, including `configure.in`). 
     101   Add a "Patches" subsection and update "Special Update/Build Instructions". 
     102   Remove files in `patches/` from `.hgignore` (and also remove pre-patched 
     103   files from that directory); the patch to `configure` and the diff of 
     104   `configure.in` are [now] under revision control, which IMHO makes sense. 
     105 * Beautify (and simplify) the output with respect to options passed to 
     106   `configure`; print the settings of a few more environment variables that 
     107   GMP-ECM uses (in case they're set); add some messages, also mention 
     108   `--enable-assert` etc. if `SAGE_DEBUG=yes`. 
     109 * Remove unused test for GCC. 
     110 
    56111=== ecm-6.3.p5 (Leif Leonhardy, April 11th 2012) === 
    57112 * #12830: Don't add `-march=native` if the assembler doesn't understand the 
    58113   instructions the compiler emits with that.  (E.g. the Apple/XCode assembler 
  • new file patches/configure.patch

    diff --git a/patches/configure.patch b/patches/configure.patch
    new file mode 100644
    - +  
     1--- src/configure       2012-04-16 21:51:42.586783117 +0200 
     2+++ src-patched/configure       2012-04-16 22:13:59.096783235 +0200 
     3@@ -12343,7 +12343,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@@ -12351,8 +12351,35 @@ 
     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+cat confdefs.h - <<_ACEOF >conftest.$ac_ext 
     25+/* end confdefs.h.  */ 
     26+ 
     27+#if defined(__ppc__) 
     28+#error 
     29+#endif 
     30+int 
     31+main () 
     32+{ 
     33+ 
     34+  ; 
     35+  return 0; 
     36+} 
     37+_ACEOF 
     38+if ac_fn_c_try_cpp "$LINENO"; then : 
     39+ 
     40+else 
     41+  { $as_echo "$as_me:${as_lineno-$LINENO}: 32-bit PowerPC, disabling asm-redc" >&5 
     42+$as_echo "$as_me: 32-bit PowerPC, disabling asm-redc" >&6;} 
     43+                enable_asm_redc=no 
     44+fi 
     45+rm -f conftest.err conftest.i conftest.$ac_ext 
     46+                          ASMPATH=powerpc64;; 
     47     powerpc64-*-linux*) 
     48  
     49 echo "include(<"$srcdir"/powerpc64/powerpc-defs.m4>)" >> $gmp_tmpconfigm4 
     50@@ -12363,7 +12390,9 @@ 
     51                          ASMPATH=athlon;; 
     52     *) as_fn_error $? "asm redc not available on this machine $host" "$LINENO" 5;; 
     53   esac 
     54+fi 
     55  
     56+if test "x$enable_asm_redc" = xyes; then 
     57 # do the necessary definitions and includes 
     58  
     59 $as_echo "#define NATIVE_REDC 1" >>confdefs.h 
     60@@ -12684,9 +12713,9 @@ 
     61 main () 
     62 { 
     63 #if (defined(__GNUC__) || defined(__ICL)) && defined(__i386__) 
     64-/* When there are no constraints, registers are referred to by 
     65-   single % sign, not double. Argh */ 
     66-asm volatile ("pmuludq %xmm2, %xmm0"); 
     67+/* On some machines, a program without constraints may pass without -msse2 but 
     68+   those with constraints in spv.c fail, thus we test with constraints here. */ 
     69+asm volatile ("pmuludq %%xmm2, %%xmm0" : : :"%xmm0"); 
     70 #else 
     71 #error 
     72 #IRIXdoesnotexitaterrordirective 
     73@@ -12708,9 +12737,9 @@ 
     74 main () 
     75 { 
     76 #if (defined(__GNUC__) || defined(__ICL)) && defined(__i386__) 
     77-/* When there are no constraints, registers are referred to by 
     78-   single % sign, not double. Argh */ 
     79-asm volatile ("pmuludq %xmm2, %xmm0"); 
     80+/* On some machines, a program without constraints may pass without -msse2 but 
     81+   those with constraints in spv.c fail, thus we test with constraints here. */ 
     82+asm volatile ("pmuludq %%xmm2, %%xmm0" : : :"%xmm0"); 
     83 #else 
     84 #error 
     85 #IRIXdoesnotexitaterrordirective 
  • spkg-check

    diff --git a/spkg-check b/spkg-check
    a b  
    66fi 
    77 
    88# Note: Running the test suite should not involve (re)compilation, 
    9 #       so we don't set CFLAGS et al. here. 
     9#       so we don't set CFLAGS et al. here.  (Their settings are 
     10#       stored in the Makefiles created by 'configure' anyway.) 
    1011 
    1112cd src 
    1213 
    13 echo "Running the GMP-ECM test suite..." 
     14echo 
     15echo "Now running GMP-ECM's test suite..." 
    1416 
    1517$MAKE check 
    1618 
    1719if [ $? -ne 0 ]; then 
    18     echo >&2 "Error: The GMP-ECM test suite failed." 
     20    echo >&2 "Error: GMP-ECM's test suite failed." 
    1921    exit 1 
    2022fi 
    2123 
    22 echo "The GMP-ECM test suite passed." 
     24echo "GMP-ECM's test suite passed." 
  • spkg-install

    diff --git a/spkg-install b/spkg-install
    a b  
    55    exit 1 
    66fi 
    77 
     8cd src/ 
     9 
    810############################################################################### 
    911# Apply patches (if any): 
    1012############################################################################### 
    1113 
    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) 
    16 echo "Copying patched files..." 
    17 # Note that we don't patch configure.in here, since it is only needed 
    18 # to generate automatically-generated files in the source tree. 
    19 # Patching configure.in forces automake to be run, which may cause 
    20 # build failures on systems where autotools aren't installed. 
    21 cp -pf patches/configure src/ 
    22 if [ $? -ne 0 ]; then 
    23     echo >&2 "Error copying patched 'configure'." 
    24     exit 1 
    25 fi 
     14ls ../patches/*.patch &>/dev/null && 
     15echo "Applying patches to upstream sources..." && 
     16for patch in ../patches/*.patch; do 
     17    basename "$patch" 
     18    patch -p1 <"$patch" 
     19    if [ $? -ne 0 ]; then 
     20        echo >&2 "Error: '$patch' failed to apply." 
     21        exit 1 
     22    fi 
     23done && 
     24echo 
    2625 
    2726############################################################################### 
    2827# Set up environment variables, depending on SAGE_* settings: 
     
    3433# processor-specific code, since ECM doesn't use them if we set our own: 
    3534# (But currently MPIR doesn't provide optimized settings either if we pass 
    3635# non-empty CFLAGS; of course the user could set such manually though.) 
    37 gmp_cc_pat='/^[         ]*#[    ]*define[       ]\+__GMP_CC[    ]\+/s/.*"\([^"]*\)"/\1/p' 
    38 gmp_cflags_pat='/^[     ]*#[    ]*define[       ]\+__GMP_CFLAGS[        ]\+/s/.*"\([^"]*\)"/\1/p' 
     36gmp_cc_pat='/^[         ]*#[    ]*define[       ]\{1,\}__GMP_CC[        ]\{1,\}/s/.*"\([^"]*\)"/\1/p' 
     37gmp_cflags_pat='/^[     ]*#[    ]*define[       ]\{1,\}__GMP_CFLAGS[    ]\{1,\}/s/.*"\([^"]*\)"/\1/p' 
    3938gmp_header_file="$SAGE_LOCAL"/include/gmp.h 
    4039 
    4140gmp_cc=`sed -n -e "$gmp_cc_pat" "$gmp_header_file"` 
     
    5453    gmp_cflags=`sed -n -e "${gmp_cflags_pat/GMP/MPIR}" "$gmp_header_file"` 
    5554esac 
    5655 
     56# Extract GMP's/MPIR's settings of CC and CFLAGS from a system-wide installation 
     57# (if present); these are only printed, for informational purposes. 
    5758system_gmp_h="" 
    5859for incdir in /usr/include /usr/local/include; do 
    5960    if [ -f $incdir/gmp.h ]; then 
     
    6364if [ -n "$system_gmp_h" ]; then 
    6465    system_gmp_cc=`sed -n -e "$gmp_cc_pat" $system_gmp_h` 
    6566    system_gmp_cflags=`sed -n -e "$gmp_cflags_pat" $system_gmp_h` 
    66 fi 
    67  
    68 cc_is_gcc=false 
    69 if $CC -v 2>&1 | grep -i gcc &>/dev/null; then 
    70     cc_is_gcc=true; 
     67    case "$system_gmp_cc" in __MPIR_CC|"") 
     68        system_gmp_cc=`sed -n -e "${gmp_cc_pat/GMP/MPIR}" $system_gmp_h` 
     69    esac 
     70    case "$system_gmp_cflags" in __MPIR_CFLAGS|"") 
     71        system_gmp_cflags=`sed -n -e "${gmp_cflags_pat/GMP/MPIR}" $system_gmp_h` 
     72    esac 
    7173fi 
    7274 
    7375 
     
    103105    # Add debug symbols and disable optimization: 
    104106    echo >&2 "Warning: Setting SAGE_DEBUG=yes completely disables optimization." 
    105107    CFLAGS="$CFLAGS -g -O0" 
     108    echo "You may in addition (or instead) pass '--enable-assert' and/or" 
     109    echo "'--enable-memory-debug' to GMP-ECM's 'configure' by setting (and" 
     110    echo "of course exporting) ECM_EXTRA_OPTS accordingly." 
    106111else 
    107112    # Enable optimization, may be overridden by user settings: 
    108113    case "`uname -srm | tr ' ' '-'`" in 
     
    115120                "PowerPC because of a linker (?) bug." 
    116121            echo >&2 "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \ 
    117122                "ff. for details." 
    118             echo "" 
     123            echo >&2 
    119124            CFLAGS="-O3 $CFLAGS" 
    120125            ;; 
    121126        *) 
     
    124129fi 
    125130 
    126131 
     132# Work around a bug in GCC 4.7.0 which breaks the build on Itanium CPUs with 
     133# '-O3', '-O2' and '-O1' (cf. #12765, #12751, and the bug URL below.) 
     134if [ "`uname -m`" = ia64 ] && [ "`testcc.sh $CC`" = GCC ]; then 
     135    gcc_version=`$CC -dumpversion` 
     136    case "$gcc_version" in 
     137      4.7.*) 
     138        CFLAGS="$CFLAGS -O0 -finline-functions -fschedule-insns" 
     139        echo >&2 "Warning: Disabling almost all optimization due to a bug in (at least)" 
     140        echo >&2 "         GCC 4.7.0 on Itanium, which otherwise would break the build." 
     141        echo >&2 "         See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48496" 
     142        echo >&2 "         for current status and further details." 
     143        echo >&2 "         (And please report to e.g. sage-devel in case you feel this bug" 
     144        echo >&2 "          should already be fixed in GCC $gcc_version.)" 
     145    esac 
     146fi 
     147 
     148 
    127149if [ "$SAGE_FAT_BINARY" = yes ]; then 
    128150    # XXX Disable SSE2 on x86? (by passing '--enable-sse2=no' to 'configure') 
    129151    # XXX Disable asm-redc? Or pass some "generic" '--host=...' to 'configure'? 
     
    182204fi 
    183205 
    184206 
    185 echo "" 
     207echo 
    186208echo "Settings from SAGE_LOCAL/include/gmp.h:" 
    187 echo "    CC=$gmp_cc" 
    188 echo "    CFLAGS=$gmp_cflags" 
     209echo "  CC=$gmp_cc" 
     210echo "  CFLAGS=$gmp_cflags" 
    189211if [ -n "$system_gmp_h" ]; then 
    190212    echo "Settings found in $system_gmp_h (currently not used):" 
    191     echo "    CC=$system_gmp_cc" 
    192     echo "    CFLAGS=$system_gmp_cflags" 
     213    echo "  CC=$system_gmp_cc" 
     214    echo "  CFLAGS=$system_gmp_cflags" 
    193215fi 
    194216 
    195 echo "Using CC=$CC" 
    196 echo "Using CFLAGS=$CFLAGS" 
    197 echo "Using CPPFLAGS=$CPPFLAGS" 
    198 echo "Using LDFLAGS=$LDFLAGS" 
    199 echo "Using ABI=$ABI" 
    200 echo "(These settings may get overridden by 'configure' or Makefiles.)" 
    201 echo "" 
     217echo "Finally using:" 
     218echo "  CC=$CC" 
     219echo "  CFLAGS=$CFLAGS" 
     220echo "  CPP=$CPP" 
     221echo "  CPPFLAGS=$CPPFLAGS" 
     222test -n "$CCAS" && echo "  CCAS=$CCAS" 
     223test -n "$CCASFLAGS" && echo "  CCASFLAGS=$CCASFLAGS" 
     224echo "  LDFLAGS=$LDFLAGS" 
     225test -n "$LIBS" && echo "  LIBS=$LIBS" 
     226echo "  ABI=$ABI" 
     227echo "  M4=$M4" 
     228echo "(These settings may still get overridden by 'configure' or Makefiles.)" 
    202229 
    203 export CFLAGS # usually redundant, but safe(r) 
     230export CFLAGS # Not exported by 'sage-env'.  LDFLAGS are exported above if 
     231              # necessary.  We currently don't set (or modify) any other 
     232              # environment variables, so don't have to export them here. 
    204233 
    205234unset RM 
    206235 
    207 cd src 
    208  
    209236############################################################################### 
    210237# Now configure ECM: 
    211238# (Note: Building (also) a *shared* library is disabled by default. 
     
    219246 
    220247echo 
    221248if [ -z "$ECM_EXTRA_OPTS" ]; then 
    222     echo "Configuring GMP-ECM with the following options:" 
    223     echo "    --prefix=\"$SAGE_LOCAL\"" 
    224     echo "    --libdir=\"$SAGE_LOCAL/lib\"" 
    225     echo "    --with-gmp=\"$SAGE_LOCAL\"" 
    226     test -n "$SAGE_CONF_OPTS" && echo "    $SAGE_CONF_OPTS" 
     249    echo "Now configuring GMP-ECM with the following options:" 
     250else 
     251    echo "Now configuring GMP-ECM with additional options as specified by" \ 
     252        "ECM_EXTRA_OPTS:" 
     253    echo "  $ECM_EXTRA_OPTS" 
     254    echo "Finally configuring GMP-ECM with the following options:" 
     255fi 
     256echo "  --prefix=\"$SAGE_LOCAL\"" 
     257echo "  --libdir=\"$SAGE_LOCAL/lib\"" 
     258echo "  --with-gmp=\"$SAGE_LOCAL\"" 
     259for opt in $SAGE_CONF_OPTS $ECM_EXTRA_OPTS; do 
     260    echo "  $opt" 
     261done 
     262if [ -z "$ECM_EXTRA_OPTS" ]; then 
    227263    echo "You can set ECM_EXTRA_OPTS to pass additional parameters," 
    228264    echo "e.g. \"--enable-shared\" to also build a *shared* library," 
    229265    echo "or \"--disable-sse2\" if you encounter problems on a Pentium III system." 
    230 else 
    231     echo "Using additional 'configure' options as specified with" \ 
    232         "ECM_EXTRA_OPTS:" 
    233     echo "    $ECM_EXTRA_OPTS" 
    234     echo "Configuring ECM with the following options:" 
    235     echo "    --prefix=\"$SAGE_LOCAL\"" 
    236     echo "    --libdir=\"$SAGE_LOCAL/lib\"" 
    237     echo "    --with-gmp=\"$SAGE_LOCAL\"" 
    238     test -n "$SAGE_CONF_OPTS" && echo "    $SAGE_CONF_OPTS" 
    239     echo "    $ECM_EXTRA_OPTS" 
    240266fi 
    241267echo 
    242268 
     
    245271            $SAGE_CONF_OPTS $ECM_EXTRA_OPTS 
    246272if [ $? -ne 0 ]; then 
    247273    echo >&2 "Error configuring GMP-ECM." 
     274    echo >&2 "(See above for the options passed to its 'configure'.)" 
    248275    exit 1 
    249276fi 
    250277