Ticket #12433: zn_poly-0.9.p7-p8.diff

File zn_poly-0.9.p7-p8.diff, 15.1 KB (added by leif, 10 years ago)

Diff between my p7 and p8 spkgs. For reference / review only.

  • .hgtags

    diff --git a/.hgtags b/.hgtags
    a b  
    1140715bfe3e31624feb49ab44e843d827c455c3c4 zn_poly-0.9.p6
    22fc80a3f545307b03c99bd426949ffd8d7e1a77b6 zn_poly-0.9.p7
     36cadbc959f3c65759e4b28d3fa5dc2f14af27b97 zn_poly-0.9.p8
  • SPKG.txt

    diff --git a/SPKG.txt b/SPKG.txt
    a b  
    2828 * NTL apparently only if we configured zn_poly differently (same for FLINT)
    2929
    3030== Special Update/Build Instructions ==
     31
    3132 * Make sure the patches still apply.
    3233   Especially changes in `makemakefile.py` may also require changes to
    3334   `spkg-install` (and perhaps also `spkg-check`).
    34  * Don't forget to change the (shared library) version number(s) in
    35    `spkg-install` in case it changed; the current one is `0.9`.
    36    (TODO: Just take the version from upstream automatically instead of
    37     hardcoding it; it's [currently] in `src/VERSION`.)
    38  * Although this is configured with `--ntl-prefix="$SAGE_LOCAL"`,
    39    apparently NTL is only used if specific targets are created, so this
    40    can probably be removed. (Did so. -leif 04/2012)
    4135 * There's also a `--use-flint` option to `configure`; no idea what it does,
    4236   and we currently don't use it either.
     37 * Check whether the work-around for GCC 4.7 on ia64 is still appropriate, i.e.
     38   adapt it in case the issue has been fixed in later GCC versions of the 4.7
     39   release series.  (Although the bug currently affects only GCC 4.7.0, it
     40   seems unlikely that it will be fixed soon, hence we apply the work-around
     41   for any GCC 4.7.x version on ia64.)
     42   See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48496 for details and the
     43   current status of that bug.
    4344 * TODO:
    4445   - Use `make install` instead of manually "installing" (copying and sym-
    4546     linking) the [shared] libraries and header files.  This requires further
     
    4950     ly some code I currently just commented out can certainly be removed.   
    5051     (-leif, 04/2012)
    5152
     53=== Patches ===
     54
     55 * makemakefile.py.patch:
     56   Improves the Python script creating the Makeefile for better use at least
     57   within Sage; see patch for details.  (Last modified at #12433, which added
     58   and changed a lot.)
     59 * profiler.c.patch, zn_poly.h.patch:
     60   Fix potential redefinition of `ulong` (in combination with other headers).
     61 * mpn_mulmid-tune.c.patch, mulmid-tune.c.patch, mul-tune.c.patch:
     62   Fix "jump into scope of identifier with variably modified type" errors.
     63   (See #8771).
     64
    5265== Changelog ==
    5366
     67=== zn_poly-0.9.p8 (Leif Leonhardy, April 20th, 2012) ===
     68 * #12433: Further reviewer changes / additions.
     69 * Work around GCC 4.7.0 bug on ia64 (by almost completely disabling optimi-
     70   zation if the compiler is GCC 4.7.x, of course only on that platform); cf.
     71   #12751, #12765.
     72 * Add a patch to avoid conflicting definitions (i.e., redundant `typedefs`)
     73   of `ulong`, by changing `ulong` to a macro.
     74 * Don't hardcode the zn_poly version number in `spkg-install`; instead read
     75   it from the file `VERSION`, like the generated `makefile` does.
     76 * Remove some of the code previously just commented out, as well as some
     77   obsolete comments.
     78 * Document patches (and correct ticket reference in an old changelog entry).
     79
    5480=== zn_poly-0.9.p7 (Leif Leonhardy, April 8th, 2012) ===
    5581 * #12433: Reviewer changes.
    5682 * Restore upstream sources. (One file in `src/tune/` was already patched.)
     
    94120   longer uses GMP.
    95121 
    96122=== zn_poly-0.9.p4 (Willem Jan Palenstijn, William Stein, April 26th, 2010) ===
    97  * Ticket #8711: Fix build error on gcc 4.5, and check if make tune succeeded.
     123 * Ticket #8771: Fix build error on gcc 4.5, and check if make tune succeeded.
    98124 * Added more checks for errors in spkg-install.
    99125
    100126=== zn_poly-0.9.p3 (Jaap Spies, February 21th, 2010) ===
  • new file patches/profiler.c.patch

    diff --git a/patches/profiler.c.patch b/patches/profiler.c.patch
    new file mode 100644
    - +  
     1--- src/profile/profiler.c      2008-09-19 17:37:47.000000000 +0200
     2+++ patches/profiler.c  2012-04-20 03:44:42.854102915 +0200
     3@@ -20,13 +20,13 @@
     4 
     5 */
     6 
     7+/* Include system headers *before* 'ulong' gets (re)defined: */
     8 #include <math.h>
     9-#include "profiler.h"
     10-
     11-
     12 #include <sys/time.h>
     13 #include <sys/resource.h>
     14 
     15+#include "profiler.h"  /* Includes zn_poly.h, which defines 'ulong'. */
     16+
     17 
     18 double cycle_scale_factor;
     19 
  • new file patches/zn_poly.h.patch

    diff --git a/patches/zn_poly.h.patch b/patches/zn_poly.h.patch
    new file mode 100644
    - +  
     1--- src/include/zn_poly.h       2008-09-19 19:51:09.000000000 +0200
     2+++ patches/zn_poly.h   2012-04-20 02:40:11.274100880 +0200
     3@@ -57,9 +57,9 @@
     4 /*
     5    ULONG_BITS = number of bits per unsigned long
     6 */
     7-#if ULONG_MAX == 4294967295U
     8+#if ULONG_MAX == 4294967295UL
     9 #define ULONG_BITS 32
     10-#elif ULONG_MAX == 18446744073709551615U
     11+#elif ULONG_MAX == 18446744073709551615UL
     12 #define ULONG_BITS 64
     13 #else
     14 #error zn_poly requires that unsigned long is either 32 bits or 64 bits
     15@@ -69,7 +69,13 @@
     16 /*
     17    I get really sick of typing unsigned long.
     18 */
     19+#if 0  /* Avoid conflicts with other (equivalent) definitions of 'ulong'. */
     20+       /* Note that <sys/types.h> might even already have typedef'ed it.  */
     21 typedef unsigned long  ulong;
     22+#else
     23+#undef ulong
     24+#define        ulong   unsigned long
     25+#endif
     26 
     27 
     28 #include "wide_arith.h"
  • spkg-check

    diff --git a/spkg-check b/spkg-check
    a b  
    2525    CPPFLAGS="$CPPFLAGS $CFLAG64"
    2626    CXXFLAGS="$CXXFLAGS $CFLAG64"
    2727    LDFLAGS="$LDFLAGS $CFLAG64"
    28     # This should really have happened in advance from 'spkg-install':
    29     # cp patches/makemakefile.py src/makemakefile.py
    30     # if [ $? -ne 0 ]; then
    31     #     echo >&2 "Error copying over patched 'makemakefile.py'."
    32     #     exit 1
    33     # fi
    34     # (Also no need to re-'sed' it in case we're using the Sun linker.)
    3528fi
    3629
    3730if [ "$SAGE_DEBUG" = yes ]; then
     
    4235    CFLAGS="-O3 -g $CFLAGS -fPIC"
    4336    CXXFLAGS="-O3 -g $CXXFLAGS -fPIC"
    4437fi
    45 # LDFLAGS="-L. $LDFLAGS" # Not needed. (-leif, 04/2012)
     38
     39# Work around a bug in GCC 4.7.0 which breaks the build on Itanium CPUs with
     40# '-O3', '-O2' and '-O1' (cf. #12765, #12751, and the bug URL below.)
     41if [ "`uname -m`" = ia64 ] && [ "`testcc.sh $CC`" = GCC ]; then
     42    gcc_version=`$CC -dumpversion`
     43    case "$gcc_version" in
     44      4.7.*)
     45        CFLAGS="$CFLAGS -O0 -finline-functions -fschedule-insns"
     46        CXXFLAGS="$CXXFLAGS -O0 -finline-functions -fschedule-insns"
     47        echo >&2 "Warning: Disabling almost all optimization due to a bug in (at least)"
     48        echo >&2 "         GCC 4.7.0 on Itanium, which otherwise would break the build."
     49        echo >&2 "         See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48496"
     50        echo >&2 "         for current status and further details."
     51        echo >&2 "         (And please report to e.g. sage-devel in case you feel this bug"
     52        echo >&2 "          should already be fixed in GCC $gcc_version.)"
     53    esac
     54fi
    4655
    4756export CFLAGS CPPFLAGS CXXFLAGS LDFLAGS # Partially redundant, but safe.
    4857
     
    5160# ones in the Makefile (which was generated from a patched 'makemakefile.py').
    5261# -leif 04/2012
    5362
     63case "$UNAME" in
     64    SunOS)
     65      if ! (ld --version  2>&1 | grep GNU >/dev/null); then
     66          # Assume it's the Sun linker; change '-soname' to '-h':
     67          # The following is only supported by the Makefile generated by our
     68          # patched 'makemakefile.py':
     69          export SONAME_FLAG=-h
     70      fi;;
     71    *) unset SONAME_FLAG # Leave the Makefile default; for safety.
     72esac
     73
     74unset SHARED_FLAG # Currently leave the Makefile default ('-shared'); for safety.
     75
    5476###############################################################################
    5577# Build the 'test' program (if it's not already built) and run it:
    5678###############################################################################
     
    7597
    7698echo
    7799echo "Now building zn_poly's extensive test suite (if not already built)..."
    78 # $MAKE test CC="$CC" # See comment above. We don't have to pass CC.
     100# $MAKE test CC="$CC" CXX="$CXX" # See comment above. We don't have to pass these.
    79101$MAKE test # Make sure the test program is built.
    80102if [ $? -ne 0 ] || [ ! -x test/test ]; then
    81103    echo >&2 "Error: zn_poly failed to build its 'test' program,"
  • spkg-install

    diff --git a/spkg-install b/spkg-install
    a b  
    1616# Set up environment variables:
    1717###############################################################################
    1818
     19zn_poly_version=`cat src/VERSION` # Only used in 'spkg-install'.
     20if [ -z "$zn_poly_version" ]; then
     21    echo >&2 "Error: Couldn't retrieve zn_poly's version from '`pwd`/src/VERSION'."
     22    exit 1
     23fi
     24
    1925if [ "$SAGE64" = yes ]; then
    2026    echo "Building a 64-bit version of zn_poly."
    2127    if [ -z "$CFLAG64" ]; then
     
    2531    CPPFLAGS="$CPPFLAGS $CFLAG64"
    2632    CXXFLAGS="$CXXFLAGS $CFLAG64"
    2733    LDFLAGS="$LDFLAGS $CFLAG64"
    28     # We now do this unconditionally below (actually by patching):
    29     # cp -f patches/makemakefile.py src/makemakefile.py
    30     # if [ $? -ne 0 ]; then
    31     #     echo >&2 "Error copying over patched 'makemakefile.py'."
    32     #     exit 1
    33     # fi
    3434fi
    3535
    3636if [ "$SAGE_DEBUG" = yes ]; then
     
    4141    CFLAGS="-O3 -g $CFLAGS -fPIC"
    4242    CXXFLAGS="-O3 -g $CXXFLAGS -fPIC"
    4343fi
    44 # LDFLAGS="-L. $LDFLAGS" # Not needed. (-leif, 04/2012)
     44
     45# Work around a bug in GCC 4.7.0 which breaks the build on Itanium CPUs with
     46# '-O3', '-O2' and '-O1' (cf. #12765, #12751, and the bug URL below.)
     47if [ "`uname -m`" = ia64 ] && [ "`testcc.sh $CC`" = GCC ]; then
     48    gcc_version=`$CC -dumpversion`
     49    case "$gcc_version" in
     50      4.7.*)
     51        CFLAGS="$CFLAGS -O0 -finline-functions -fschedule-insns"
     52        CXXFLAGS="$CXXFLAGS -O0 -finline-functions -fschedule-insns"
     53        echo >&2 "Warning: Disabling almost all optimization due to a bug in (at least)"
     54        echo >&2 "         GCC 4.7.0 on Itanium, which otherwise would break the build."
     55        echo >&2 "         See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48496"
     56        echo >&2 "         for current status and further details."
     57        echo >&2 "         (And please report to e.g. sage-devel in case you feel this bug"
     58        echo >&2 "          should already be fixed in GCC $gcc_version.)"
     59    esac
     60fi
    4561
    4662export CFLAGS CPPFLAGS CXXFLAGS LDFLAGS # Partially redundant, but safe.
    4763
    48 # (Actually the currently generated Makefile won't use any of them from the
     64# (Actually the currently generated Makefile won't use any of the above from the
    4965# environment; instead we have to pass them with special options to 'configure',
    5066# which we do below.  Furthermore, CPPFLAGS and CXXFLAGS are only supported by
    5167# our patched 'makemakefile.py', which is called by 'configure'.)
    5268
     69case "$UNAME" in
     70    SunOS)
     71      if ! (ld --version  2>&1 | grep GNU >/dev/null); then
     72          # Assume it's the Sun linker; change '-soname' to '-h':
     73          # The following is only supported by the Makefile generated by our
     74          # patched 'makemakefile.py':
     75          export SONAME_FLAG=-h
     76      fi;;
     77    *) unset SONAME_FLAG # Leave the Makefile default; for safety.
     78esac
     79
     80unset SHARED_FLAG # Currently leave the Makefile default ('-shared'); for safety.
     81
    5382###############################################################################
    5483# Apply patches (if any):
    5584###############################################################################
    5685
    57 # cp patches/mpn_mulmid-tune.c patches/mul-tune.c patches/mulmid-tune.c src/tune
    58 # if [ $? -ne 0 ]; then
    59 #     echo >&2 "Error copying over patched upstream source files."
    60 #     exit 1
    61 # fi
    62 
    63 # We now also always patch 'makemakefile.py' below, since the changes are
    64 # independent of the setting of SAGE64.
    65 
    6686cd src/
    6787
    68 echo "Applying patches (if any) to upstream sources..."
     88ls ../patches/*.patch &>/dev/null &&
     89echo "Applying patches to upstream sources..." &&
    6990for patch in ../patches/*.patch; do
    7091    basename "$patch"
    7192    patch -p1 <"$patch"
     
    7394        echo >&2 "Error: '$patch' failed to apply."
    7495        exit 1
    7596    fi
    76 done
    77 
    78 case "$UNAME" in SunOS)
    79     if ! (ld --version  2>&1 | grep GNU >/dev/null); then
    80         # Assume it's the Sun linker; change '-soname' to '-h':
    81         # echo "Patching 'makemakefile.py' for the Sun linker..."
    82         # sed 's/-soname/-h/g' makemakefile.py > makemakefile.py.$$ &&
    83         # mv -f makemakefile.py.$$ makemakefile.py
    84         # if [ $? -ne 0 ]; then
    85         #     echo >&2 "Error patching 'makemakefile.py' (with 'sed')."
    86         #     exit 1
    87         # fi
    88         # The following is only supported by the Makefile generated by our
    89         # patched 'makemakefile.py':
    90         export SONAME_FLAG=-h
    91     fi;;
    92     *) unset SONAME_FLAG # Leave the Makefile default; for safety.
    93 esac
    94 
    95 unset SHARED_FLAG # Currently leave the Makefile default ('-shared'); for safety.
     97done &&
     98echo
    9699
    97100###############################################################################
    98101# Configure, tune, build and test zn_poly:
     
    113116fi
    114117
    115118# Run the tuning program, only takes 1 minute or so:
     119echo
    116120echo "Now building zn_poly's self-tuning program..."
    117 $MAKE tune # CC="$CC"
     121$MAKE tune # CC="$CC" CXX="$CXX"
    118122if [ $? -ne 0 ] || [ ! -x tune/tune ]; then
    119123    echo >&2 "Error building zn_poly's tuning program."
    120124    exit 1
    121125fi
     126echo
    122127echo "Now running zn_poly's self-tuning program..."
    123128tune/tune > src/tuning.c
    124129if [ $? -ne 0 ]; then
     
    126131    exit 1
    127132fi
    128133
     134echo
    129135echo "Now building zn_poly with its tuning parameters..."
    130 $MAKE # CC="$CC"
     136$MAKE # CC="$CC" CXX="$CXX"
    131137if [ $? -ne 0 ]; then
    132138    echo >&2 "Error building zn_poly."
    133139    exit 1
    134140fi
    135141
    136142# Run the brief test suite:
     143echo
    137144echo "Now building and running zn_poly's quick self-test..."
    138 $MAKE check # CC="$CC"
     145$MAKE check # CC="$CC" CXX="$CXX"
    139146if [ $? -ne 0 ]; then
    140147    echo >&2 "Error running zn_poly's quick test suite ('make check')."
    141148    exit 1
     
    151158# Build and manually install the shared library:
    152159###############################################################################
    153160
     161echo
    154162echo "Now building and installing zn_poly's shared library..."
    155163
    156164if [ "$UNAME" != Darwin ]; then
    157165    # Linux, SunOS/Solaris, Cygwin etc.:
    158     $MAKE libzn_poly.so # CC="$CC"
     166    $MAKE libzn_poly.so # CC="$CC" CXX="$CXX"
    159167    if [ $? -ne 0 ]; then
    160168        echo >&2 "Error building zn_poly's shared library."
    161169        exit 1
    162170    fi
    163     cp -f libzn_poly-0.9.so "$SAGE_LOCAL"/lib/ &&
    164     (cd "$SAGE_LOCAL"/lib/ && ln -sf libzn_poly-0.9.so libzn_poly.so)
     171    cp -f libzn_poly-"$zn_poly_version".so "$SAGE_LOCAL"/lib/ &&
     172    (cd "$SAGE_LOCAL"/lib/ && ln -sf libzn_poly-"$zn_poly_version".so libzn_poly.so)
    165173    if [ $? -ne 0 ]; then
    166174        echo >&2 "Error installing zn_poly's shared library."
    167175        exit 1
     
    186194    #     target=libzn_poly.dylib
    187195    # fi
    188196    # $MAKE $target # CC="$CC"
    189     $MAKE libzn_poly.dylib # CC="$CC"
     197    $MAKE libzn_poly.dylib # CC="$CC" CXX="$CXX"
    190198    if [ ! -f libzn_poly.dylib ]; then
    191199        echo >&2 "Error building zn_poly's dylib (shared library)."
    192200        exit 1
     
    202210# Manually install the header files:
    203211###############################################################################
    204212
     213echo
    205214echo "Now installing zn_poly's header files..."
    206215
    207216mkdir -p "$SAGE_LOCAL"/include/zn_poly/ &&