Ticket #12830: ecm-6.3.p5-p6.diff
| File ecm-6.3.p5-p6.diff, 17.7 KB (added by leif, 13 months ago) |
|---|
-
.hgignore
diff --git a/.hgignore b/.hgignore
a b 1 1 src 2 patches/configure3 patches/configure.in -
.hgtags
diff --git a/.hgtags b/.hgtags
a b 2 2 4d6646f19caecfa0810d3341a8a1361cb529a7b4 ecm-6.3.p3 3 3 62e5a142f7157c6dfa8ab59fc9228208326507ad ecm-6.3.p4 4 4 14c0237361c1ffefdcece11d745f3381ec009a46 ecm-6.3.p5 5 7ac46fc5997fb25668f35b8571f48af69f5859f4 ecm-6.3.p6 -
SPKG.txt
diff --git a/SPKG.txt b/SPKG.txt
a b 21 21 == Dependencies == 22 22 23 23 * GMP/MPIR (Note: Python is *not* required for ordinary builds.) 24 * GNU patch 24 25 25 26 == Special Update/Build Instructions == 26 27 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.) 31 36 * GMP-ECM comes with a self-tuning feature; we could support 32 37 that as an option ($SAGE_TUNE_*=yes) in the future. 33 38 * We currently work around a linker bug on MacOS X 10.5 PPC (with … … 35 40 This *might* get fixed in later upstream releases. 36 41 * ECM currently does not (by itself) use the CC and CFLAGS settings 37 42 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. 42 46 Of course a user can also manually enable them by setting the "global" 43 47 CFLAGS to e.g. '-march=native' on x86[_64] systems, or '-mcpu=...' and 44 48 '-mtune=...' on other architectures where "native" isn't supported. … … 50 54 "-mcpu=...", and perhaps pass a more generic "--host=..." to 51 55 'configure'. (MPIR honors '--enable-fat' to some extent, but this 52 56 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 53 83 54 84 == Changelog == 55 85 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 56 111 === ecm-6.3.p5 (Leif Leonhardy, April 11th 2012) === 57 112 * #12830: Don't add `-march=native` if the assembler doesn't understand the 58 113 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 6 6 fi 7 7 8 8 # 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.) 10 11 11 12 cd src 12 13 13 echo "Running the GMP-ECM test suite..." 14 echo 15 echo "Now running GMP-ECM's test suite..." 14 16 15 17 $MAKE check 16 18 17 19 if [ $? -ne 0 ]; then 18 echo >&2 "Error: The GMP-ECMtest suite failed."20 echo >&2 "Error: GMP-ECM's test suite failed." 19 21 exit 1 20 22 fi 21 23 22 echo " The GMP-ECMtest suite passed."24 echo "GMP-ECM's test suite passed." -
spkg-install
diff --git a/spkg-install b/spkg-install
a b 5 5 exit 1 6 6 fi 7 7 8 cd src/ 9 8 10 ############################################################################### 9 11 # Apply patches (if any): 10 12 ############################################################################### 11 13 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 14 ls ../patches/*.patch &>/dev/null && 15 echo "Applying patches to upstream sources..." && 16 for 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 23 done && 24 echo 26 25 27 26 ############################################################################### 28 27 # Set up environment variables, depending on SAGE_* settings: … … 34 33 # processor-specific code, since ECM doesn't use them if we set our own: 35 34 # (But currently MPIR doesn't provide optimized settings either if we pass 36 35 # 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'36 gmp_cc_pat='/^[ ]*#[ ]*define[ ]\{1,\}__GMP_CC[ ]\{1,\}/s/.*"\([^"]*\)"/\1/p' 37 gmp_cflags_pat='/^[ ]*#[ ]*define[ ]\{1,\}__GMP_CFLAGS[ ]\{1,\}/s/.*"\([^"]*\)"/\1/p' 39 38 gmp_header_file="$SAGE_LOCAL"/include/gmp.h 40 39 41 40 gmp_cc=`sed -n -e "$gmp_cc_pat" "$gmp_header_file"` … … 54 53 gmp_cflags=`sed -n -e "${gmp_cflags_pat/GMP/MPIR}" "$gmp_header_file"` 55 54 esac 56 55 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. 57 58 system_gmp_h="" 58 59 for incdir in /usr/include /usr/local/include; do 59 60 if [ -f $incdir/gmp.h ]; then … … 63 64 if [ -n "$system_gmp_h" ]; then 64 65 system_gmp_cc=`sed -n -e "$gmp_cc_pat" $system_gmp_h` 65 66 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 71 73 fi 72 74 73 75 … … 103 105 # Add debug symbols and disable optimization: 104 106 echo >&2 "Warning: Setting SAGE_DEBUG=yes completely disables optimization." 105 107 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." 106 111 else 107 112 # Enable optimization, may be overridden by user settings: 108 113 case "`uname -srm | tr ' ' '-'`" in … … 115 120 "PowerPC because of a linker (?) bug." 116 121 echo >&2 "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \ 117 122 "ff. for details." 118 echo ""123 echo >&2 119 124 CFLAGS="-O3 $CFLAGS" 120 125 ;; 121 126 *) … … 124 129 fi 125 130 126 131 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.) 134 if [ "`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 146 fi 147 148 127 149 if [ "$SAGE_FAT_BINARY" = yes ]; then 128 150 # XXX Disable SSE2 on x86? (by passing '--enable-sse2=no' to 'configure') 129 151 # XXX Disable asm-redc? Or pass some "generic" '--host=...' to 'configure'? … … 182 204 fi 183 205 184 206 185 echo ""207 echo 186 208 echo "Settings from SAGE_LOCAL/include/gmp.h:" 187 echo " CC=$gmp_cc"188 echo " CFLAGS=$gmp_cflags"209 echo " CC=$gmp_cc" 210 echo " CFLAGS=$gmp_cflags" 189 211 if [ -n "$system_gmp_h" ]; then 190 212 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" 193 215 fi 194 216 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 "" 217 echo "Finally using:" 218 echo " CC=$CC" 219 echo " CFLAGS=$CFLAGS" 220 echo " CPP=$CPP" 221 echo " CPPFLAGS=$CPPFLAGS" 222 test -n "$CCAS" && echo " CCAS=$CCAS" 223 test -n "$CCASFLAGS" && echo " CCASFLAGS=$CCASFLAGS" 224 echo " LDFLAGS=$LDFLAGS" 225 test -n "$LIBS" && echo " LIBS=$LIBS" 226 echo " ABI=$ABI" 227 echo " M4=$M4" 228 echo "(These settings may still get overridden by 'configure' or Makefiles.)" 202 229 203 export CFLAGS # usually redundant, but safe(r) 230 export 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. 204 233 205 234 unset RM 206 235 207 cd src208 209 236 ############################################################################### 210 237 # Now configure ECM: 211 238 # (Note: Building (also) a *shared* library is disabled by default. … … 219 246 220 247 echo 221 248 if [ -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:" 250 else 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:" 255 fi 256 echo " --prefix=\"$SAGE_LOCAL\"" 257 echo " --libdir=\"$SAGE_LOCAL/lib\"" 258 echo " --with-gmp=\"$SAGE_LOCAL\"" 259 for opt in $SAGE_CONF_OPTS $ECM_EXTRA_OPTS; do 260 echo " $opt" 261 done 262 if [ -z "$ECM_EXTRA_OPTS" ]; then 227 263 echo "You can set ECM_EXTRA_OPTS to pass additional parameters," 228 264 echo "e.g. \"--enable-shared\" to also build a *shared* library," 229 265 echo "or \"--disable-sse2\" if you encounter problems on a Pentium III system." 230 else231 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"240 266 fi 241 267 echo 242 268 … … 245 271 $SAGE_CONF_OPTS $ECM_EXTRA_OPTS 246 272 if [ $? -ne 0 ]; then 247 273 echo >&2 "Error configuring GMP-ECM." 274 echo >&2 "(See above for the options passed to its 'configure'.)" 248 275 exit 1 249 276 fi 250 277
