Ticket #12954: mpir-2.4.0.p4.diff

File mpir-2.4.0.p4.diff, 11.2 KB (added by jdemeyer, 10 years ago)

Diff between the 2.4.0.p3 and 2.4.0.p4 spkgs. For reference / review only.

  • SPKG.txt

    diff --git a/SPKG.txt b/SPKG.txt
    a b  
    5757
    5858== Changelog ==
    5959
     60=== mpir-2.4.0.p4 (Jeroen Demeyer, 26 May 2012) ===
     61 * Trac #12954: when SAGE_FAT_BINARY=yes on systems which don't support
     62   --enable-fat, compile a generic binary (not assuming any particular
     63   CPU) by passing the output of configfsf.guess to the --build option
     64   of ./configure.
     65 * Disable SAGE_FAT_BINARY when bootstrapping GCC.
     66 * Rename MPIR_EXTRA_OPTS to MPIR_CONFIGURE.
     67 * Add configure options directly to MPIR_CONFIGURE, no longer use
     68   SAGE_CONF_OPTS for this.
     69 * When user specifies CFLAGS, append them to MPIR's flags instead of
     70   completely replacing MPIR's flags.
     71 * Remove $default_cflags and get_processor_specific_cflags().
     72
    6073=== mpir-2.4.0.p3 (Jeroen Demeyer, April 26th, 2012) ===
    6174 Trac #11616, reviewer fixes:
    6275 * When the first configure run (with CFLAGS unset) of MPIR fails, bail
  • spkg-install

    diff --git a/spkg-install b/spkg-install
    a b  
    5858    cd "$saved"
    5959}
    6060
    61 get_processor_specific_cflags() # Extract some processor-specific CFLAGS.
    62 {
    63     # Internal sanity check:
    64     if [ $# -lt 1 ]; then
    65         echo >&2 "Error: get_processor_specific_cflags() requires 'CFLAGS' parameter."
    66         exit 1
    67     fi
    68     flags=$*
    69     arch_flags=""
    70     for opt in $flags; do
    71         case $opt in
    72             -march=*|-mcpu=*|-mtune=*|-mpower*|-mno-power*)
    73                 arch_flags="$arch_flags $opt"
    74                 ;;
    75             # We could add further '-m' or '-f' options here, but note that
    76             # this function is also used to determine if the user specified
    77             # some, which we don't want to override.
    78         esac
    79     done
    80     echo $arch_flags
    81 }
    82 
    8361###############################################################################
    8462# Set up environment variables:
    8563###############################################################################
     
    9775
    9876user_cflags=$CFLAGS # Save them. 'sage-env' sets CC, but not CFLAGS.
    9977required_cflags=""  # Additional mandatory settings required by Sage, accumulated below.
    100 default_cflags=""   # Spkg defaults that can and might get overridden.
    10178user_ldflags=$LDFLAGS # Save them.
    10279required_ldflags=""   # Additional mandatory settings required by Sage, accumulated below.
    10380user_abi=$ABI # Just save it.
     
    10582# We don't have to add (e.g.) '-m64' to CFLAGS/CPPFLAGS/CXXFLAGS/LDFLAGS, since
    10683# MPIR's 'configure' is smart enough to add it if necessary or appropriate.
    10784
    108 SAGE_CONF_OPTS="" # Clear them. (Further options to `configure` are added below.)
    109 
    11085
    11186if [ -z "$CFLAG32" ]; then
    11287    CFLAG32="-m32" # Only used in this script, no need to export it.
     
    12196    required_cflags="$required_cflags -g -O0"
    12297    echo >&2 "Warning: Building MPIR with SAGE_DEBUG=yes disables optimization."
    12398else
    124     # Add debug symbols by default, enable optimization, but do not (yet)
    125     # add processor-specific flags (these are eventually added later):
    126     default_cflags="$default_cflags -g -O3"
     99    # Add debug symbols by default
     100    required_cflags="$required_cflags -g"
    127101fi
    128102
    129103
    130104case "$UNAME" in
    131105    SunOS)
    132106        if [ "$SAGE64" = yes ]; then
    133             echo "Building a 64-bit version of MPIR." 
     107            echo "Building a 64-bit version of MPIR."
    134108            ABI=64
    135109        else
    136             echo "Building a 32-bit version of MPIR." 
     110            echo "Building a 32-bit version of MPIR."
    137111            ABI=32
    138112        fi;;
    139113    Darwin)
     
    174148        # systems:
    175149        required_ldflags="$required_ldflags -Wl,-z,noexecstack"
    176150
    177         if [ "$SAGE_FAT_BINARY" = "yes" ]; then
    178             # For now we do the same thing -- namely "--enable-fat" --
    179             # on both 64-bit and 32-bit, though this is likely to change.
    180             case "`uname -m`" in
    181             i[3456]86)
    182                 echo "** Building with \"fat binary\" support for 32-bit CPUs **"
    183                 SAGE_CONF_OPTS="$SAGE_CONF_OPTS --enable-fat"
    184                 ;;
    185             x86_64|amd64)
    186                 echo "** Building with \"fat binary\" support for 64-bit CPUs **"
    187                 SAGE_CONF_OPTS="$SAGE_CONF_OPTS --enable-fat"
    188                 ;;
    189             *) # e.g. ia64 (Itanium) or PPC (ppc, ppc64)
    190                 echo >&2 "Warning: A \"fat binary\" build is currently not" \
    191                     "supported on this CPU architecture."
    192                 # XXX exit 1 ?
    193             esac
    194         fi
    195 
    196151        # MPIR fails to build on 32-bit operating systems running on
    197152        # 64-bit CPUs if CFLAGS happen to contain '-m32' and ABI is
    198153        # *not* set, so we set it here if necessary:
     
    204159            echo "int main(){return 0;}" > foo.c
    205160            # Try building and running a 64-bit executable:
    206161            # (Building usually succeeds even on 32-bit systems, unless e.g. a 32-bit
    207             # CPU is explicitly selected by CFLAGS, while running does not.)
     162            # CPU is explicitly selected by CFLAGS, while running does not.)
    208163            if $CC $CFLAGS $CFLAG64 -o foo foo.c 2>/dev/null && ./foo 2>/dev/null; then
    209164                # We can run 64-bit executables.
    210165                # Setting ABI=64 shouldn't be necessary, but shouldn't hurt either.
     
    254209# Now configure MPIR, eventually modifying CFLAGS [further]:
    255210###############################################################################
    256211
    257 SAGE_CONF_OPTS="--enable-gmpcompat --enable-shared $SAGE_CONF_OPTS"
     212MPIR_CONFIGURE="--enable-gmpcompat --enable-shared $MPIR_CONFIGURE"
    258213
    259 # If we're bootstrapping GCC from the GCC spkg, don't build the C++ interface
    260 # and static libraries in the first place (cf. #12782):
     214# If we're bootstrapping GCC from the GCC spkg, don't build the C++
     215# interface (cf. #12782), static libraries and disable fat binary.
     216# After GCC is built, we will build MPIR again.
    261217if [ "$SAGE_BUILD_TOOLCHAIN" = yes ]; then
    262218    echo "Building a reduced version of MPIR to bootstrap GCC."
    263219    echo "MPIR will later get rebuilt (with the C++ interface and static libraries"
    264220    echo "enabled) using the new compiler."
    265     SAGE_CONF_OPTS="--disable-cxx --disable-static $SAGE_CONF_OPTS"
     221    MPIR_CONFIGURE="--disable-cxx --disable-static $MPIR_CONFIGURE"
     222    SAGE_FAT_BINARY=no
    266223else
    267224    # Also build the static library to be used by e.g. ECM:
    268225    echo "Building MPIR with the C++ interface and (also) static libraries."
    269     SAGE_CONF_OPTS="--enable-cxx --enable-static $SAGE_CONF_OPTS"
     226    MPIR_CONFIGURE="--enable-cxx --enable-static $MPIR_CONFIGURE"
    270227fi
    271228# (Further options to 'configure' are added below.)
    272229
     230# If SAGE_FAT_BINARY is enabled, then add --enable-fat to configure
     231# options on Linux x86 systems.  On other systems, fat binaries are not
     232# supported.  Then we specify a build architecture which doesn't
     233# have a CPU name in it.  This means which use the vanilla config.guess
     234# (renamed to configfsf.guess in MPIR) file instead of MPIR's version.
     235if [ "$SAGE_FAT_BINARY" = "yes" ]; then
     236    case "$UNAME-`uname -m`" in
     237        Linux-i[3456]86)
     238            echo "** Building with \"fat binary\" support for 32-bit CPUs **"
     239            MPIR_CONFIGURE="--enable-fat $MPIR_CONFIGURE"
     240            ;;
     241        Linux-x86_64|Linux-amd64)
     242            echo "** Building with \"fat binary\" support for 64-bit CPUs **"
     243            MPIR_CONFIGURE="--enable-fat $MPIR_CONFIGURE"
     244            ;;
     245        *) # Anything else
     246            echo "** Building a generic binary (not assuming any specific CPU) **"
     247            MPIR_CONFIGURE="--build=`./configfsf.guess` $MPIR_CONFIGURE"
     248            ;;
     249    esac
     250fi
     251
    273252
    274253# Pre-configure MPIR to get the settings it would use if CFLAGS were empty:
    275254echo "Checking what CFLAGS MPIR would use if they were empty..."
    276 (unset CFLAGS CPPFLAGS CXXFLAGS && ./configure $SAGE_CONF_OPTS $MPIR_EXTRA_OPTS) &>configure-empty.log
     255(unset CFLAGS CPPFLAGS CXXFLAGS && ./configure $MPIR_CONFIGURE) &>configure-empty.log
    277256if [ $? -ne 0 ]; then
    278257    # Output the log of the failed configure run
    279258    cat configure-empty.log
     
    294273echo "Settings chosen by MPIR when configuring with CFLAGS unset:"
    295274echo "  CC:      $mpir_cc"
    296275echo "  CFLAGS:  $mpir_cflags"
    297 echo "Settings required to properly build MPIR, taking into account SAGE_DEBUG etc.:"
     276echo "Settings added by Sage to build MPIR, taking into account SAGE_DEBUG etc.:"
    298277echo "  CFLAGS:  $required_cflags"  # Might be empty.
    299278echo "  LDFLAGS: $required_ldflags" # Might be empty.
    300279echo "  ABI:     $ABI" # Might be empty, or the one specified by the user.
     
    305284echo "  ABI:     $user_abi"
    306285echo "  (CPP, CPPFLAGS, CXX and CXXFLAGS are listed below; these don't get modified.)"
    307286
    308 if [ -z "$user_cflags" ]; then
    309     # No CFLAGS specified by user => Use MPIR's flags, plus those
    310     # required by Sage for the package to build properly:
    311     echo "Using MPIR's settings (plus mandatory ones)."
    312     CFLAGS="$mpir_cflags $required_cflags"
    313 else
    314     # CFLAGS were specified by the user, so don't override them (unless
    315     # necessary) and only add some useful ones to improve code generation:
    316     echo "Using user-specified settings (overriding defaults), with some additions."
    317     CFLAGS="$default_cflags $user_cflags $required_cflags"
    318 
    319     # Now add processor-specific flags if appropriate:
    320     if [ -z "`get_processor_specific_cflags $CFLAGS`" ]; then
    321         # User didn't specify specific architecture, so try to add such flag(s):
    322         # Add MPIR's. Honors '--enable-fat'.
    323         echo "Adding processor-specific options from MPIR."
    324         CFLAGS="`get_processor_specific_cflags $mpir_cflags` $CFLAGS"
    325     else
    326         # User did specify some processor-specific CFLAGS.
    327         # We *might* prepend all of MPIR's CFLAGS here in addition,
    328         # but doing so could raise a conflict.
    329         :;
    330     fi
    331 fi
    332 
     287# Finally: use MPIR's flags, plus those required by Sage for the
     288# package to build properly, plus those specified by the user.
     289CFLAGS="$mpir_cflags $required_cflags $user_cflags"
    333290LDFLAGS="$required_ldflags $user_ldflags"
    334291
    335292echo "Finally using the following settings:"
     
    350307# We also add '--libdir="$SAGE_LOCAL/lib"' below, since newer autotools may
    351308# otherwise put the libraries into .../lib64 on 64-bit systems (cf. #12131).
    352309
    353 if [ -z "$MPIR_EXTRA_OPTS" ]; then
    354     echo "Configuring MPIR with the following options:"
    355     echo "    --prefix=\"$SAGE_LOCAL\" --libdir=\"$SAGE_LOCAL/lib\" $SAGE_CONF_OPTS"
    356     echo "You can set MPIR_EXTRA_OPTS to pass additional parameters."
    357 else
    358     echo "Using additional 'configure' options as specified through" \
    359         "MPIR_EXTRA_OPTS:"
    360     echo "    $MPIR_EXTRA_OPTS"
    361     echo "Configuring MPIR with the following options:"
    362     echo "    --prefix=\"$SAGE_LOCAL\" --libdir=\"$SAGE_LOCAL/lib\" $SAGE_CONF_OPTS $MPIR_EXTRA_OPTS"
    363 fi
     310echo "Configuring MPIR with the following options:"
     311echo "    --prefix=\"$SAGE_LOCAL\" --libdir=\"$SAGE_LOCAL/lib\" $MPIR_CONFIGURE"
     312echo "You can set MPIR_CONFIGURE to pass additional parameters."
    364313
    365314# Clear the cache of the previous configure run
    366315find . -name config.cache -exec rm -f {} \;
    367316
    368 ./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" $SAGE_CONF_OPTS $MPIR_EXTRA_OPTS
     317./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" $MPIR_CONFIGURE
    369318if [ $? -ne 0 ]; then
    370319    echo >&2 "Error configuring MPIR. (See above for the options passed to it.)"
    371320    exit 1