Ticket #12703: glpk-4.44.p0-4.47.p1.diff

File glpk-4.44.p0-4.47.p1.diff, 14.0 KB (added by leif, 7 years ago)

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

  • .hgtags

    diff --git a/.hgtags b/.hgtags
    a b  
    1155081c23c3dcfea9e1a3e1185348800b4af4b360 glpk-4.44.p0
     2fc66549e7a394431e5bd8c635ac9f5dfce44d9b8 glpk-4.47.p0
     37a79c3733834031335e0c650e44d78ca79e61e02 glpk-4.47.p1
  • SPKG.txt

    diff --git a/SPKG.txt b/SPKG.txt
    a b  
    1 = GLPK 4.42 =
     1= GLPK =
    22
    33== Description ==
    44
    55The GLPK (GNU Linear Programming Kit) package is intended for solving
    66large-scale linear programming (LP), mixed integer programming (MIP),
    77and other related problems. It is a set of routines written in ANSI C
    8 and organized in the form of a callable library. 
     8and organized in the form of a callable library.
    99
    1010GLPK supports the GNU MathProg modelling language, which is a subset of
    11 the AMPL language. 
     11the AMPL language.
    1212
    1313The GLPK package includes the following main components:
    1414
     
    1717 * branch-and-cut method
    1818 * translator for GNU MathProg
    1919 * application program interface (API)
    20  * stand-alone LP/MIP solver 
     20 * stand-alone LP/MIP solver
    2121
    2222== License ==
    2323
     
    2525
    2626== SPKG Maintainers ==
    2727
    28 Nathann Cohen (nathann.cohen@gmail.com)
     28 * Nathann Cohen (nathann.cohen@gmail.com)
    2929
    3030== Upstream Contact ==
    3131
    32 GLPK is currently being maintained by mao@gnu.org, mao@mai2.rcnet.ru
     32GLPK is currently being maintained by:
     33
     34 * Andrew Makhorin (mao@gnu.org, mao@mai2.rcnet.ru)
     35
    3336http://www.gnu.org/software/glpk/#maintainer
    3437
    3538== Dependencies ==
    3639
    37  * zlib
    38  * mpir (as an gmp substitute)
    39  * python
    40  * possibly others.
     40 * GMP/MPIR
     41 * As of version 4.47, zlib is included in the GLPK sources, and *that*
     42   version is unconditionally compiled into the GLPK library, so there's
     43   no "external" dependency on it, and there's furthermore -- at least
     44   currently -- no way to make GLPK use an existing version of it, i.e.,
     45   Sage's.
     46
     47== Special Update/Build Instructions ==
     48
     49 * Note that the upstream source directory (`src/`) currently *isn't*
     50   vanilla, because the autotools used by upstream (and hence their files
     51   included into the tarball) are too old, or at least too old to support
     52   LTO.  (Using the latter, i.e. `-flto`, leads to an error message during
     53   `configure`, but it continues normally and exits *without* an error.
     54   Only later, during the build, a strange syntax error makes the build
     55   finally fail.  This has already been reported upstream and confirmed
     56   by the maintainer, so probably later upstream versions, >=4.47, will be
     57   prepared with newer autotools such that it won't be necessary to modify
     58   the upstream sources again.)
     59   To update the autotools[-generated] files, do the following:
     60
     61     cd src/
     62     libtoolize --copy --force
     63     aclocal -I m4
     64     autoconf
     65     autoheader
     66     automake --add-missing --copy
     67
     68   (You'll of course need current versions of m4, libtool, autoconf and
     69   automake to produce files that support/work with LTO.  To check this,
     70   it is sufficient to try `CFLAGS="-flto" ./configure && make`; you need
     71   a recent version of GCC supporting LTO as well.)
     72
     73   And don't forget to afterwards remove left-over temporary files:
     74
     75     make distclean
     76     rm -rf autom4te.cache config.h.in~
     77
     78   (I used m4 1.4.16, libtool 2.4.2, autoconf 2.68 and automake 1.11.3
     79   to update the files for the glpk-4.47.p0 spkg.) -leif (03/2012)
     80
     81 * Perhaps remove the `src/src/zlib/` directory, since Sage ships zlib
     82   (and GLPK should use that); also the `src/w{32,64}/` directories aren't
     83   needed for Sage, but they only contain a few small files.
     84   Turns out that (as of version 4.47) GLPK always builds and uses its
     85   own copy of zlib, so for now, *don't* remove it from the source tree!
     86
     87 * TODO:
     88   - It should be sufficient to pass `--with-<package>="$SAGE_LOCAL"`
     89     (where <package>={gmp,zlib}) instead of adding Sage's directories
     90     to `CPPFLAGS` and `LDFLAGS`; see comment in `spkg-install`.
     91     Turns out that (as of version 4.47)
     92     1) GLPK unconditionally uses its own copy of zlib (see above),
     93        and the `configure` option `--with-zlib` is no longer valid;
     94     2) `configure` doesn't support specifying the location of the GMP
     95        library to use; only `--with-gmp[=yes]` or `--with-gmp=no`
     96        are valid options.  (So we *have to* add Sage's include and
     97        library directories to `CPPFLAGS` and `LDFLAGS`, respectively.)
     98   - I think we *could* run GLPK's "test suite" (which is -- at least
     99     currently -- tiny, and takes at most a few seconds to run) by
     100     default, i.e., from `spkg-install`.  (See also comment there.)
     101     But I don't really have an opinion on that... -leif
     102   - Do we need the `--disable-static`?  The stand-alone solver presumably
     103     runs faster when built with a static library; also other (stand-alone)
     104     programs using it would.
     105     (Instead, we should perhaps use `--enable-static --enable-shared` to
     106     go safe.)
    41107
    42108== Changelog ==
    43109
    44 === glpk-4.44.p0 (Simon King, 10th December 2011) ==
     110=== glpk-4.47.p1 (Leif Leonhardy, March 22nd 2012) ===
     111 * #12703: Make GLPK work with LTO (`gcc -flto ...`).
     112   Export CPPFLAGS, since `sage-env` currently *doesn't*.
     113
     114=== glpk-4.47.p0 (Leif Leonhardy, March 19th 2012) ===
     115 * #12703: Make GLPK work with LTO (`gcc -flto ...`).
     116   This just involves updating the lib- and autotools files,
     117   but thereby upgrading to the latest version (4.47) shouldn't
     118   hurt either.
     119   Note that the `src/` directory now isn't vanilla, since upstream
     120   hasn't yet fixed the bug (i.e., updated these files).
     121   The "real" source files in contrast of course *are*.
     122   See "Special Update/Build Instructions" above on how to update
     123   the files of a fresh upstream tarball if necessary.
     124 * Cleaned up `spkg-install` and `spkg-check` (and this file ;-)
     125 * Running the test suite now uses `$MAKE` instead of `make` as well.
     126 * `CPPFLAGS` and `LDFLAGS` no longer get overwritten in `spkg-install`.
     127
     128=== glpk-4.44.p0 (Simon King, 10th December 2011) ===
    45129 * #12131: Use --libdir, to make the package work on openSUSE.
    46130
    47 == glpk-4.44 (Nathann Cohen, 5th July 2010) ==
    48 
     131=== glpk-4.44 (Nathann Cohen, 5th July 2010) ===
    49132 * Removed the patch/ directory which was only useful for backward
    50133   compatibility (and had been for some time already), and updated
    51134   consequently several files
  • spkg-check

    diff --git a/spkg-check b/spkg-check
    a b  
    1 if [ "$SAGE_LOCAL" = "" ]; then
    2    echo "SAGE_LOCAL undefined ... exiting";
    3    echo "Maybe run 'sage -sh'?"
    4    exit 1
    5 fi
     1#!/usr/bin/env bash
    62
    7 
    8 # Let the user set an environment variable CFLAG64 to indicate the flag
    9 # for the C compiler to build 64-bit code. If not set, asssume it is -m64
    10 # as that is what is used by both GCC and SunStudio, but -m64 is not used
    11 # by IBM's compiler on AIX or HP's compiier on HP-UX
    12 
    13 if [ -z $CFLAG64 ] ; then
    14   CFLAG64=-m64 # -m64 is used by gcc and SunStudio.
    15 fi
    16 
    17 if [ "x$SAGE64" = xyes ] ; then
    18    echo "Building a 64-bit version of GLPK"
    19    CFLAGS="$CFLAGS $CFLAG64" && export CFLAGS
    20    LDFLAGS="$LDFLAGS $CFLAG64" && export LDFLAGS
    21    CPPFLAGS="$CPPFLAGS $CFLAG64" && export CPPFLAGS # Very rare is CPPFLAGS needed, but sometimes it is.
    22 fi
    23 
    24 cd src
    25 echo "GLPK will now be tested"
    26 make check
    27 if [ $? -ne 0 ]; then
    28     echo "An error occurred whilst testing GLPK"
     3if [[ -z "$SAGE_LOCAL" ]]; then
     4    echo >&2 "SAGE_LOCAL undefined - exiting..."
     5    echo >&2 "Maybe run 'sage -sh'?"
    296    exit 1
    307fi
    318
     9
     10# Let the user set an environment variable CFLAG64 to indicate the flag
     11# for the C compiler to build 64-bit code. If not set, assume it is -m64
     12# as that is what is used by both GCC and SunStudio, but -m64 is not used
     13# by IBM's compiler on AIX or HP's compiler on HP-UX.
     14
     15if [[ -z $CFLAG64 ]]; then
     16    CFLAG64=-m64 # -m64 is used by gcc and SunStudio.
     17fi
     18
     19if [[ "$SAGE64" = yes ]]; then
     20    echo "Building a 64-bit version of GLPK's test suite."
     21    CFLAGS="$CFLAGS $CFLAG64"
     22    LDFLAGS="$LDFLAGS $CFLAG64"
     23    CPPFLAGS="$CPPFLAGS $CFLAG64"
     24    # Very rare is CPPFLAGS needed, but sometimes it is.
     25fi
     26
     27# Let GLPK use Sage's GMP/MPIR (cf. comments in SPKG.txt and spkg-install):
     28CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS"
     29LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
     30
     31# No need to (re)export CFLAGS, LDFLAGS etc., as `sage-env` does this.
     32# But it currently *doesn't* export CPPFLAGS. For safety, export them all:
     33export CFLAGS CPPFLAGS LDFLAGS
     34
     35
     36cd src/
     37
     38echo "Running GLPK's test suite..."
     39$MAKE check
     40if [[ $? -ne 0 ]]; then
     41    echo >&2 "Error running GLPK's test suite."
     42    exit 1
     43else
     44    echo "Apparently GLPK passed its test suite without errors."
     45fi
  • spkg-install

    diff --git a/spkg-install b/spkg-install
    a b  
    1 if [ "$SAGE_LOCAL" = "" ]; then
    2    echo "SAGE_LOCAL undefined ... exiting";
    3    echo "Maybe run 'sage -sh'?"
    4    exit 1
     1#!/usr/bin/env bash
     2
     3if [[ -z "$SAGE_LOCAL" ]]; then
     4    echo >&2 "SAGE_LOCAL undefined - exiting..."
     5    echo >&2 "Maybe run 'sage -sh'?"
     6    exit 1
    57fi
    68
    79# The version of libtool in this glpk package requires that
    8 # RM/MV/CP if they are set include the -f option
     10# RM/MV/CP if they are set include the -f option.
    911# See for example the discussion at:
    1012# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=523750
    1113
    1214# It was agreed some time back to remove these environment variables.
    13 # nobody in their right mind will want to set them.
     15# Nobody in their right mind will want to set them.
    1416
    15 unset MV && export MV
    16 unset RM && export RM
    17 unset CP && export CP
     17unset RM MV CP
    1818
    1919# Let the user set an environment variable CFLAG64 to indicate the flag
    20 # for the C compiler to build 64-bit code. If not set, asssume it is -m64
     20# for the C compiler to build 64-bit code. If not set, assume it is -m64
    2121# as that is what is used by both GCC and SunStudio, but -m64 is not used
    22 # by IBM's compiler on AIX or HP's compiier on HP-UX
     22# by IBM's compiler on AIX or HP's compiler on HP-UX
    2323
    24 if [ -z $CFLAG64 ] ; then
    25   CFLAG64=-m64 # -m64 is used by gcc and SunStudio.
     24if [[ -z $CFLAG64 ]]; then
     25    CFLAG64=-m64 # -m64 is used by gcc and SunStudio.
    2626fi
    2727
    28 CPPFLAGS="-I $SAGE_LOCAL/include" && export CPPFLAGS
    29 LDFLAGS="-L$SAGE_LOCAL/lib" &&  export LDFLAGS
     28# Note: The following doesn't work with spaces in `$SAGE_LOCAL`, but we don't
     29#       support that anyway, since many upstream packages don't.
     30#       On the other hand, the only packages GLPK uses that Sage provides are
     31#       GMP/MPIR and zlib, so we should just use `--with-gmp="$SAGE_LOCAL"` and
     32#       `--with-zlib="$SAGE_LOCAL"` below (which is safe), and omit the fol-
     33#       lowing two lines. (TODO)
     34#
     35#       Turns out that (as of version 4.47)
     36#       1) GLPK unconditionally uses its own copy of zlib (cf. `SPKG.txt`),
     37#          and the `configure` option `--with-zlib` is no longer valid;
     38#       2) `configure` doesn't support specifying the location of the GMP
     39#          library to use; only `--with-gmp[=yes]` or `--with-gmp=no`
     40#          are valid options.  So we *have to* add Sage's include and
     41#          library directories to `CPPFLAGS` and `LDFLAGS`, respectively:
    3042
    31 if [ "x$SAGE64" = xyes ] ; then
    32    echo "Building a 64-bit version of GLPK"
    33    CFLAGS="$CFLAGS $CFLAG64" && export CFLAGS
    34    LDFLAGS="$LDFLAGS $CFLAG64" && export LDFLAGS
    35    CPPFLAGS="$CPPFLAGS $CFLAG64" && export CPPFLAGS
    36    # Very rarly is it needed to add '-m64' to CPPFLAGS,
    37    # but potentially it can be.
    38 fi
    3943
    40 cd src
     44CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS"
     45LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
    4146
    42 ./configure --prefix=$SAGE_LOCAL --libdir="$SAGE_LOCAL/lib" --with-gmp --with-zlib --disable-static
     47if [[ "$SAGE64" = yes ]]; then
     48    echo "Building a 64-bit version of GLPK."
     49    CFLAGS="$CFLAGS $CFLAG64"
     50    LDFLAGS="$LDFLAGS $CFLAG64"
     51    CPPFLAGS="$CPPFLAGS $CFLAG64"
     52    # Very rarely is it needed to add '-m64' to CPPFLAGS,
     53    # but potentially it can be.
     54fi
    4355
    44 if [ $? -ne 0 ]; then
    45     echo "An error occurred whilst configuring GLPK"
     56# CFLAGS and LDFLAGS are already exported by `sage-env`, but CPPFLAGS
     57# are currently *not*.  (Re)Exporting them all here doesn't hurt either,
     58# and is safe(r) in any case:
     59export CFLAGS CPPFLAGS LDFLAGS
     60
     61echo "Using     CC=$CC"
     62echo "  CFLAGS=$CFLAGS"
     63echo "  CPP=$CPP"
     64echo "  CPPFLAGS=$CPPFLAGS"
     65echo "  LD=$LD"
     66echo "  LDFLAGS=$LDFLAGS"
     67echo "  ABI=$ABI"
     68echo "('configure' and/or Makefiles may override these settings though.)"
     69
     70
     71cd src/
     72
     73
     74# We currently don't apply any patches; otherwise do it here (and
     75# update `SPKG.txt` to reflect the dependency on `patch`).
     76
     77
     78# (TODO:) I'd personally use `--enable-static` and `--enable-shared`,
     79#         cf. "Special Update/Build Instructions" in `SPKG.txt`. -leif
     80#
     81# Note: 1) The `configure` option `--with-zlib` is no longer valid.
     82#       2) We can only enable or disable the use of GMP with `--with-gmp`,
     83#          but cannot specify its location (i.e., `...="$SAGE_LOCAL"`).
     84# -leif (03/2012, GLPK version 4.47)
     85
     86echo "Configuring GLPK with GMP enabled, and static libraries disabled..."
     87./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" \
     88            --with-gmp --disable-static
     89if [[ $? -ne 0 ]]; then
     90    echo >&2 "Error configuring GLPK."
    4691    exit 1
    4792fi
    4893
    49 $MAKE
    50 if [ $? -ne 0 ]; then
    51     echo "An error occurred whilst building GLPK"
     94echo "Now building GLPK..."
     95$MAKE
     96if [[ $? -ne 0 ]]; then
     97    echo >&2 "Error building GLPK."
    5298    exit 1
    5399fi
    54100
    55101# There are two cases where this can fail to install - at the point of
    56 # installing the C source code and at the point of using Python.
     102# installing the C source code and at the point of using Python.
     103# ??? GLPK doesn't install any C files (except its library header),
     104#     nor does it use Python in any way...
     105#     -leif
    57106
    58 $MAKE install
    59 if [ $? -ne 0 ]; then
    60     echo "An error occurred whilst installing GLPK (during the \"make install\" process)"
     107echo "Now installing GLPK (glpsol program and the library)..."
     108$MAKE install
     109if [[ $? -ne 0 ]]; then
     110    echo >&2 "Error installing GLPK."
    61111    exit 1
    62112fi
     113
     114# We could run GLPK's "test suite" from here as well, as it is tiny and
     115# running it currently (as of GLPK version 4.47) only takes [milli]seconds.