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

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

Diff between the previous spkg in Sage and my new p5 spkg. For reference / review only.

  • .hgtags

    diff --git a/.hgtags b/.hgtags
    a b  
    114fb2b9ca03a2973d035fad8c9cfe6062c79cc6f2 ecm-6.3.p2 
    224d6646f19caecfa0810d3341a8a1361cb529a7b4 ecm-6.3.p3 
    3362e5a142f7157c6dfa8ab59fc9228208326507ad ecm-6.3.p4 
     414c0237361c1ffefdcece11d745f3381ec009a46 ecm-6.3.p5 
  • SPKG.txt

    diff --git a/SPKG.txt b/SPKG.txt
    a b  
    2525== Special Update/Build Instructions == 
    2626 
    2727 * 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. 
     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. 
    3131 * GMP-ECM comes with a self-tuning feature; we could support 
    3232   that as an option ($SAGE_TUNE_*=yes) in the future. 
    3333 * We currently work around a linker bug on MacOS X 10.5 PPC (with 
     
    5353 
    5454== Changelog == 
    5555 
     56=== ecm-6.3.p5 (Leif Leonhardy, April 11th 2012) === 
     57 * #12830: Don't add `-march=native` if the assembler doesn't understand the 
     58   instructions the compiler emits with that.  (E.g. the Apple/XCode assembler 
     59   on Darwin doesn't yet support AVX.) 
     60 * Fix extraction of `__GMP_CC` and `__GMP_CFLAGS` (from `gmp.h`) for newer 
     61   versions of MPIR, which define these to preprocessor macros rather than 
     62   strings. 
     63 * Redirect warnings and error messages to `stderr`; add some messages. 
     64 * Correct `SPKG.txt` w.r.t. applied patches. 
     65 
    5666=== ecm-6.3.p4 (Jeroen Demeyer, 13 February 2012) === 
    5767 * #12501: Do not patch configure.in in spkg-install (to prevent 
    5868   automake from running). 
  • spkg-check

    diff --git a/spkg-check b/spkg-check
    a b  
    11#!/usr/bin/env bash 
    22 
    33if [ -z "$SAGE_LOCAL" ]; then 
    4     echo "Error: SAGE_LOCAL undefined - exiting..." 
     4    echo >&2 "Error: SAGE_LOCAL undefined - exiting..." 
    55    exit 1 
    66fi 
    77 
     
    1515$MAKE check 
    1616 
    1717if [ $? -ne 0 ]; then 
    18     echo "Error: The GMP-ECM test suite failed." 
     18    echo >&2 "Error: The GMP-ECM test suite failed." 
    1919    exit 1 
    2020fi 
    2121 
  • spkg-install

    diff --git a/spkg-install b/spkg-install
    a b  
    11#!/usr/bin/env bash 
    22 
    33if [ -z "$SAGE_LOCAL" ]; then 
    4     echo "Error: SAGE_LOCAL undefined - exiting..." 
     4    echo >&2 "Error: SAGE_LOCAL undefined - exiting..." 
    55    exit 1 
    66fi 
    77 
     
    1818# to generate automatically-generated files in the source tree. 
    1919# Patching configure.in forces automake to be run, which may cause 
    2020# build failures on systems where autotools aren't installed. 
    21 cp -p patches/configure src/ 
     21cp -pf patches/configure src/ 
    2222if [ $? -ne 0 ]; then 
    23     echo "Error copying patched configure." 
     23    echo >&2 "Error copying patched 'configure'." 
    2424    exit 1 
    2525fi 
    2626 
     
    3636# non-empty CFLAGS; of course the user could set such manually though.) 
    3737gmp_cc_pat='/^[         ]*#[    ]*define[       ]\+__GMP_CC[    ]\+/s/.*"\([^"]*\)"/\1/p' 
    3838gmp_cflags_pat='/^[     ]*#[    ]*define[       ]\+__GMP_CFLAGS[        ]\+/s/.*"\([^"]*\)"/\1/p' 
     39gmp_header_file="$SAGE_LOCAL"/include/gmp.h 
    3940 
    40 gmp_cc=`sed -n -e "$gmp_cc_pat" "$SAGE_LOCAL"/include/gmp.h` 
    41 gmp_cflags=`sed -n -e "$gmp_cflags_pat" "$SAGE_LOCAL"/include/gmp.h` 
     41gmp_cc=`sed -n -e "$gmp_cc_pat" "$gmp_header_file"` 
     42gmp_cflags=`sed -n -e "$gmp_cflags_pat" "$gmp_header_file"` 
     43# At least /some/ newer versions of MPIR define __GMP_CC and __GMP_CFLAGS 
     44# (also in gmp.h! -- how compatible is that?) to (literally) __MPIR_CC and 
     45# __MPIR_CFLAGS, respectively, i.e., to preprocessor variables, so we might 
     46# have to get the real strings from their definitions: 
     47# (Since we currently only match string literals above, both variables would 
     48# be empty in that case, and not contain the names of preprocessor variables. 
     49# We could change the patterns to actually match any definition / "value".)  
     50case "$gmp_cc" in __MPIR_CC|"") 
     51    gmp_cc=`sed -n -e "${gmp_cc_pat/GMP/MPIR}" "$gmp_header_file"` 
     52esac 
     53case "$gmp_cflags" in __MPIR_CFLAGS|"") 
     54    gmp_cflags=`sed -n -e "${gmp_cflags_pat/GMP/MPIR}" "$gmp_header_file"` 
     55esac 
    4256 
    4357system_gmp_h="" 
    4458for incdir in /usr/include /usr/local/include; do 
     
    5872 
    5973 
    6074if [ "$SAGE64" = yes ]; then 
    61     echo "Building a 64-bit version of GMP-ECM" 
     75    echo "Building a 64-bit version of GMP-ECM." 
    6276    if [ -z "$CFLAG64" ]; then 
    6377        CFLAG64=-m64 
    6478    fi 
    6579    CFLAGS="$CFLAGS $CFLAG64" 
    6680    LDFLAGS="$LDFLAGS $CFLAG64"; export LDFLAGS 
    67 else 
    68     :; 
    6981fi 
    7082 
    7183 
     
    89101 
    90102if [ "$SAGE_DEBUG" = yes ]; then 
    91103    # Add debug symbols and disable optimization: 
     104    echo >&2 "Warning: Setting SAGE_DEBUG=yes completely disables optimization." 
    92105    CFLAGS="$CFLAGS -g -O0" 
    93106else 
    94107    # Enable optimization, may be overridden by user settings: 
     
    98111            # fails due to a bus error in Apple's 'ld' when trying 
    99112            # to determine if global symbols are prefixed with an 
    100113            # underscore (cf. http://trac.sagemath.org/sage_trac/ticket/5847#comment:35 ff.): 
    101             echo "Warning: Disabling debug symbols on MacOS X 10.5" \ 
     114            echo >&2 "Warning: Disabling debug symbols on MacOS X 10.5" \ 
    102115                "PowerPC because of a linker (?) bug." 
    103             echo "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \ 
     116            echo >&2 "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \ 
    104117                "ff. for details." 
    105118            echo "" 
    106119            CFLAGS="-O3 $CFLAGS" 
     
    114127if [ "$SAGE_FAT_BINARY" = yes ]; then 
    115128    # XXX Disable SSE2 on x86? (by passing '--enable-sse2=no' to 'configure') 
    116129    # XXX Disable asm-redc? Or pass some "generic" '--host=...' to 'configure'? 
    117     echo "Warning: SAGE_FAT_BINARY is currently not really supported by this package." 
    118     echo "         Add e.g. '--disable-asm-redc' and/or '--enable-sse2=no'" 
    119     echo "         to ECM_EXTRA_OPTS if you run into problems." 
     130    echo >&2 "Warning: SAGE_FAT_BINARY is currently not really supported by this package." 
     131    echo >&2 "         Add e.g. '--disable-asm-redc' and/or '--enable-sse2=no'" 
     132    echo >&2 "         to ECM_EXTRA_OPTS if you run into problems." 
    120133else 
    121134    # Tune the code generation to the machine we build on: 
    122135    cpu_params=""; other_gmp_cflags="" 
     
    124137    # Some gcc 4.0.x versions don't support '-march=native', and it's currently 
    125138    # not supported on all platforms supported by Sage: 
    126139    if touch foo.c && $CC -march=native -c foo.c &>/dev/null; then 
    127         cpu_params="-march=native" 
    128     else 
     140        # The compiler supports '-march=native', but the assembler might not 
     141        # support (some of) the instructions emitted with this (e.g. the 
     142        # Apple assembler doesn't know AVX yet). 
     143        cat >foo.c <<-"EOF" 
     144                double d; 
     145                unsigned long fancy_insns() { return (unsigned long) d; } 
     146                int main () { return 0; } 
     147        EOF 
     148        if $CC -march=native -o foo foo.c &>/dev/null && ./foo >/dev/null; then 
     149            cpu_params="-march=native" 
     150        else 
     151            echo >&2 "Warning: Your assembler apparently doesn't understand the instructions" 
     152            echo >&2 "         your compiler ($CC) generates with '-march=native'." 
     153            echo >&2 "         You might also try to compile GMP-ECM with (e.g.)" 
     154            echo >&2 "             CFLAGS=\"-march=native -mno-avx\"" 
     155            echo >&2 "         to disable specific instruction set extension (in this case, AVX)." 
     156        fi 
     157    fi 
     158    if [ -z "$cpu_params" ]; then 
    129159        # 'native' not supported, see if GMP / MPIR provides us some CPU type: 
    130160        for opt in $gmp_cflags; do 
    131161            case $opt in 
     
    138168            esac 
    139169        done 
    140170    fi 
    141     rm -f foo.* 
     171    rm -f foo.* foo 
    142172    # Only add them if CFLAGS do not already contain similar: 
    143173    if [ -n "$cpu_params" ] && 
    144174        ! (echo "$CFLAGS" | egrep -- '-march=|-mcpu=|-mtune=' >/dev/null); 
     
    185215#        adapt the logic regarding '-fPIC' above. 
    186216############################################################################### 
    187217 
    188 SAGE_CONF_OPTS="" 
     218SAGE_CONF_OPTS="" # XXX Move this up in case you add options above! 
    189219 
    190 echo "" 
     220echo 
    191221if [ -z "$ECM_EXTRA_OPTS" ]; then 
    192222    echo "Configuring GMP-ECM with the following options:" 
    193     echo "    --prefix=\"$SAGE_LOCAL\" --libdir=\"$SAGE_LOCAL/lib\" --with-gmp=\"$SAGE_LOCAL\"" \ 
    194         "$SAGE_CONF_OPTS" 
     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" 
    195227    echo "You can set ECM_EXTRA_OPTS to pass additional parameters," 
    196228    echo "e.g. \"--enable-shared\" to also build a *shared* library," 
    197229    echo "or \"--disable-sse2\" if you encounter problems on a Pentium III system." 
     
    200232        "ECM_EXTRA_OPTS:" 
    201233    echo "    $ECM_EXTRA_OPTS" 
    202234    echo "Configuring ECM with the following options:" 
    203     echo "    --prefix=\"$SAGE_LOCAL\" --libdir=\"$SAGE_LOCAL/lib\" --with-gmp=\"$SAGE_LOCAL\"" \ 
    204         "$SAGE_CONF_OPTS $ECM_EXTRA_OPTS" 
     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" 
    205240fi 
    206 echo "" 
     241echo 
    207242 
    208 ./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" --with-gmp="$SAGE_LOCAL" \ 
    209     $SAGE_CONF_OPTS $ECM_EXTRA_OPTS 
     243./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" \ 
     244            --with-gmp="$SAGE_LOCAL" \ 
     245            $SAGE_CONF_OPTS $ECM_EXTRA_OPTS 
    210246if [ $? -ne 0 ]; then 
    211     echo "Error configuring GMP-ECM." 
     247    echo >&2 "Error configuring GMP-ECM." 
    212248    exit 1 
    213249fi 
    214250 
     
    216252# Now build ECM: 
    217253############################################################################### 
    218254 
     255echo 
     256echo "Now building GMP-ECM..." 
    219257$MAKE 
    220258if [ $? -ne 0 ]; then 
    221     echo "Error building GMP-ECM." 
     259    echo >&2 "Error building GMP-ECM." 
    222260    exit 1 
    223261fi 
    224262 
    225263############################################################################### 
    226264# Remove old executable/header/libraries/manpage: 
    227265############################################################################### 
    228 echo "Build succeeded, removing old binary, header file, manual page and libraries..." 
     266 
     267echo 
     268echo "Build succeeded.  Now removing old binary, header file, manual page and libraries..." 
    229269rm -f "$SAGE_LOCAL"/bin/ecm 
    230270rm -f "$SAGE_LOCAL"/lib/libecm.* 
    231271rm -f "$SAGE_LOCAL"/include/ecm.h 
     
    235275# Now install ECM: 
    236276############################################################################### 
    237277 
     278echo "Now installing GMP-ECM..." 
    238279$MAKE install 
    239280if [ $? -ne 0 ]; then 
    240     echo "Error installing GMP-ECM (though it appears to have built fine)." 
     281    echo >&2 "Error installing GMP-ECM (though it appears to have built fine)." 
    241282    exit 1 
    242283fi