Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#13290 closed enhancement (fixed)

Upgrade MPC to version 1.0

Reported by: jdemeyer Owned by: tbd
Priority: minor Milestone: sage-5.3
Component: packages: standard Keywords:
Cc: jpflori, zimmerma Merged in: sage-5.3.beta2
Authors: Jeroen Demeyer Reviewers: Leif Leonhardy, Volker Braun
Report Upstream: Fixed upstream, in a later stable release. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

Currently, Sage uses a development version of MPC (stable 0.9 had build issues on certain platforms).

We should upgrade to the just-released MPC-1.0: http://www.multiprecision.org/index.php?prog=mpc. While we're at it, import MPComplexField by default and add MPC to the reference manual.

spkg: http://boxen.math.washington.edu/home/jdemeyer/spkg/mpc-1.0.p0.spkg

apply 13290_mpc_1_0.patch to the Sage library.

mpc-1.0 (Jeroen Demeyer, 27 July 2012)

  • Trac #13290: upgrade to stable version 1.0.
  • Remove no_fortify_source.patch (which is upstream now).
  • Remove legacy "unset RM" command.

Attachments (4)

mpc-1.0.spkg-gcc-4.7.0-config.log (42.5 KB) - added by leif 9 years ago.
config.log from MPC 1.0 spkg showing use of gcc instead of gmp.h's CC
configure.ac.patch (689 bytes) - added by leif 9 years ago.
"Upstream" patch to configure.ac to fix CC not being taken from gmp.h.
13290_mpc_1_0.patch (38.7 KB) - added by jdemeyer 9 years ago.
Patch for the Sage library
mpc-1.0.p0.diff (62.8 KB) - added by jdemeyer 9 years ago.
Patch for the mpc spkg, for review only

Download all attachments as: .zip

Change History (38)

comment:1 Changed 9 years ago by leif

FWIW, MPFR 3.1.1 has also recently been released. (Don't know whether there's already a ticket to upgrade to that version.)

comment:2 Changed 9 years ago by jdemeyer

  • Description modified (diff)

comment:3 Changed 9 years ago by jdemeyer

  • Status changed from new to needs_review

comment:4 Changed 9 years ago by jdemeyer

  • Description modified (diff)

comment:5 Changed 9 years ago by leif

s/Gnu Mpc/GNU MPC/ in SPKG.txt ;-) (The original has small caps.)

For consistency, I wouldn't remove the error check and message in spkg-check.

I also wouldn't comment out the patch loop; in case there are no patches, simply no patch should get applied, without raising an error message (either because patches/ doesn't exist, or because there's no patch in patches/ such that ../patches/*.patch "expands" to itself). Otherwise we uselessly keep creating and deleting directories, and commenting code out or reversing that each time patches again appear or all previous patches vanish. Prepending

ls ../patches/*.patch &>/dev/null &&

to the for loop should be sufficient.

comment:6 Changed 9 years ago by jpflori

  • Cc jpflori added

comment:7 Changed 9 years ago by jdemeyer

leif, I made some minor corrections you suggested. I changed the patch loop to:

# Apply patches.  See SPKG.txt for information about what each patch
# does.
for patch in ../patches/*.patch; do
    [ -r "$patch" ] || continue
    patch -p1 <"$patch"
    if [ $? -ne 0 ]; then
        echo >&2 "Error applying '$patch'"
        exit 1
    fi
done

comment:8 Changed 9 years ago by jdemeyer

  • Reviewers set to Leif Leonhardy

comment:9 follow-up: Changed 9 years ago by jdemeyer

I also changed the developer documentation to change the "patch loop" as I did for MPC.

comment:10 Changed 9 years ago by leif

Oh, just reviewed the previous patch to the Sage library, which looked good except that you removed the formulas for the conjugate and the square of a complex number ;-), and some instances of self not typeset monospaced.

comment:11 in reply to: ↑ 9 ; follow-up: Changed 9 years ago by leif

Replying to jdemeyer:

I also changed the developer documentation to change the "patch loop" as I did for MPC.

Is that the only change you made to the Sage library patch? (It should better be a separate patch.)

I'd rather use [ -f "$patch" ] instead of [ -r "$patch" ].

While you're at it, $SAGE_ROOT should be quoted in the Developer Guide's template.

comment:12 in reply to: ↑ 11 ; follow-up: Changed 9 years ago by jdemeyer

Replying to leif:

I'd rather use [ -f "$patch" ] instead of [ -r "$patch" ].

Actually I like -r, because like this one can intentionally disable a patch by chmoding it 000.

comment:13 in reply to: ↑ 12 ; follow-up: Changed 9 years ago by leif

Replying to jdemeyer:

Replying to leif:

I'd rather use [ -f "$patch" ] instead of [ -r "$patch" ].

Actually I like -r, because like this one can intentionally disable a patch by chmoding it 000.

I was thinking of the same, but it's also a potential pitfall I think, and not very appropriate from an educational perspective... (unless you add a comment on that; people might think -r tests for a regular file, and [ -r <some directory> ] is usually true as well).


...
checking for CC and CFLAGS in gmp.h... yes CC=gcc-4.7.0 -std=gnu99 CFLAGS=-O2 -m64 -march=btver1 -mtune=btver1  -g -march=native -O3 -fno-strict-aliasing -DHONORS_CFLAGS
checking for CC=gcc-4.7.0 -std=gnu99 and CFLAGS=-O2 -m64 -march=btver1 -mtune=btver1  -g -march=native -O3 -fno-strict-aliasing -DHONORS_CFLAGS... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... ld
checking if the linker (ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/local/bin/nm -B
checking the name lister (/usr/local/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/local/bin/nm -B output from gcc object... failed
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... cpp-4.7.0
checking for ANSI C header files... no
checking for sys/types.h... no
checking for sys/stat.h... no
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... no
checking for dlfcn.h... no
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... no
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... no
checking if gcc supports -c -o file.o... (cached) no
checking if we can lock with hard links... yes
checking whether the gcc linker (ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... 
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gmp.h... no
configure: error: gmp.h cannot be found or is unusable.
Error configuring MPC.

real	0m7.518s
user	0m0.780s
sys	0m0.700s
************************************************************************
Error installing package mpc-1.0
************************************************************************

Ooops!?

($SAGE_LOCAL/include/gmp.h is of course present and sane as well, as you can also see since MPC found __GMP_CC and __GMP_CFLAGS.)

comment:14 in reply to: ↑ 13 Changed 9 years ago by leif

Replying to leif:

************************************************************************
Error installing package mpc-1.0
************************************************************************

Ooops!?

($SAGE_LOCAL/include/gmp.h is of course present and sane as well, as you can also see since MPC found __GMP_CC and __GMP_CFLAGS.)

... and my environment and my Sage installation are sane; just successfully reinstalled the previous MPC spkg.

comment:15 follow-up: Changed 9 years ago by leif

Despite looking for GMP's CC, upstream's configure apparently uses gcc in almost all tests (which is GCC 4.4.3, and which e.g. doesn't understand -march=btver1 from GMP's/MPIR's CFLAGS)!

comment:16 in reply to: ↑ 15 ; follow-up: Changed 9 years ago by jdemeyer

Replying to leif:

Despite looking for GMP's CC, upstream's configure apparently uses gcc in almost all tests (which is GCC 4.4.3, and which e.g. doesn't understand -march=btver1 from GMP's/MPIR's CFLAGS)!

Really? Could you attach the config.log from mpc-1.0?

comment:17 Changed 9 years ago by leif

Not clear to me what's causing this; the change to configure.ac looks harmless, but they're also using newer autotools.

  • src/configure.ac

    old new  
    1 # Copyright (C) 2008, 2009, 2010, 2011 INRIA
     1# Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA
    22#
    33# This file is part of GNU MPC.
    44#
     
    2020# Process this file with autoconf to produce a configure script.
    2121
    2222AC_PREREQ(2.61)
    23 AC_INIT(mpc, 1.0.0dev, mpc-discuss@lists.gforge.inria.fr)
     23AC_INIT(mpc, 1.0, mpc-discuss@lists.gforge.inria.fr)
    2424AC_CONFIG_SRCDIR([src/mpc-impl.h])
    2525AC_CONFIG_HEADER([config.h])
    2626
    2727AM_INIT_AUTOMAKE([1.9 -Wall -Werror])
    2828AM_MAINTAINER_MODE
    2929
     30USER_CC=$CC
     31USER_CFLAGS=$CFLAGS
     32
     33# automake 1.12 seems to require this, but automake 1.11 doesn't recognize it
     34m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
     35
    3036AC_CANONICAL_HOST
    3137AC_CONFIG_MACRO_DIR([m4])
    3238
     39
    3340# Extra arguments to configure
    3441AC_ARG_WITH([mpfr_include],
    3542            [AC_HELP_STRING([--with-mpfr-include=DIR],
     
    96103# at http://lists.gforge.inria.fr/pipermail/mpc-discuss/2012-January/001056.html
    97104AC_PROG_EGREP
    98105AC_PROG_SED
    99 if test -z "$CC" && test -z "$CFLAGS"; then
     106if test -z "$USER_CC" && test -z "$USER_CFLAGS"; then
    100107   MPC_GMP_CC_CFLAGS
    101108fi
    102109
     
    105112AC_LANG(C)
    106113
    107114# Set up LibTool
    108 AC_PROG_LIBTOOL
     115LT_INIT
    109116

Changed 9 years ago by leif

config.log from MPC 1.0 spkg showing use of gcc instead of gmp.h's CC

comment:18 in reply to: ↑ 16 Changed 9 years ago by leif

Replying to jdemeyer:

Could you attach the config.log from mpc-1.0?

Did so. Quite long; the relevant parts seem

configure:2930: checking for gcc
configure:2946: found /usr/bin/gcc
configure:2957: result: gcc
configure:3186: checking for C compiler version
configure:3195: gcc --version >&5
gcc (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3206: $? = 0

...

configure:4394: checking for CC and CFLAGS in gmp.h
configure:4420: result: yes CC=gcc-4.7.0 -std=gnu99 CFLAGS=-O2 -m64 -march=btver1 -mtune=btver1  -g -march=native -O3 -fno-strict-aliasing -DHONORS_CFLAGS
configure:4426: checking for CC=gcc-4.7.0 -std=gnu99 and CFLAGS=-O2 -m64 -march=btver1 -mtune=btver1  -g -march=native -O3 -fno-strict-aliasing -DHONORS_CFLAGS
configure:4430: result: yes
configure:4493: checking for gcc
configure:4520: result: gcc
configure:4749: checking for C compiler version
configure:4758: gcc --version >&5
gcc (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:4769: $? = 0

Somehow the settings from gmp.h don't get "propagated".

comment:19 Changed 9 years ago by leif

Interestingly, similar happens if I unset CC, CPP, CFLAGS and CPPFLAGS: While configure definitely uses the CFLAGS from gmp.h, it doesn't use the CC setting.

Apparently because of inappropriate caching:

...
checking for CC and CFLAGS in gmp.h... yes CC=gcc-4.7.0 -std=gnu99 CFLAGS=-O2 -m64 -march=btver1 -mtune=btver1  -g -march=native -O3 -fno-strict-aliasing -DHONORS_CFLAGS
checking for CC=gcc-4.7.0 -std=gnu99 and CFLAGS=-O2 -m64 -march=btver1 -mtune=btver1  -g -march=native -O3 -fno-strict-aliasing -DHONORS_CFLAGS... yes
checking for gcc... (cached) gcc
...

comment:20 Changed 9 years ago by jdemeyer

  • Status changed from needs_review to needs_work

I can confirm the regression regarding $CC.

comment:21 follow-up: Changed 9 years ago by leif

Obviously the CC from gmp.h gets overwritten with $ac_cv_prog_CC (determined earlier), but I don't know the proper way to avoid that. (One could of course "manually" unset it in the MPC_GMP_CC_CFLAG macro from mpc.m4, or set it to the new value if appropriate, but that appears very hackish to me. There must be some other way to update or invalidate cached variables I think, but so far I haven't found one.)

The cause of the regression seems to simply be the use of newer autotools (generating a configure script that now checks for the compiler before MPC_GMP_CC_CFLAG is called).

comment:22 in reply to: ↑ 21 Changed 9 years ago by leif

Replying to leif:

The cause of the regression seems to simply be the use of newer autotools (generating a configure script that now checks for the compiler before MPC_GMP_CC_CFLAG is called).

Not really, or at least not directly. The culprit is AM_PROG_AR, which pulls in a lot of crap, or more precisely triggers the compiler tests too early.

If I move

# automake 1.12 seems to require this, but automake 1.11 doesn't recognize it
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

past the call to MPC_GMP_CC_CFLAGS, the spkg installs and passes its test suite.

comment:23 follow-up: Changed 9 years ago by leif

  • Cc zimmerma added

P.S.:

Since I don't have Automake 1.12 installed, perhaps someone else should autoreconf the spkg; patching configure IMHO doesn't make much sense.

Anybody going to report this upstream? Paul...? :P

Changed 9 years ago by leif

"Upstream" patch to configure.ac to fix CC not being taken from gmp.h.

comment:24 Changed 9 years ago by leif

I've attached a patch to src/configure.ac.

comment:25 in reply to: ↑ 23 ; follow-up: Changed 9 years ago by leif

Replying to leif:

Since I don't have Automake 1.12 installed, perhaps someone else should autoreconf the spkg; patching configure IMHO doesn't make much sense.

Anybody going to report this upstream?

Ok, reported upstream (patch included).

comment:26 in reply to: ↑ 25 Changed 9 years ago by leif

Replying to leif:

Ok, reported upstream (patch included).

Comment By: Andreas Enge (enge)
Date: 2012-07-27 21:39

Message:
I confirm the problem and admit I tested only the propagation of the CFLAGS, which seems to work. This part of the configuration is really tricky.

Thanks for working this out. I applied the patch to the trunk and the 1.0 branch. A bug fix release 1.0.1 is planned for the end of August.

That's quick... :-)

comment:27 Changed 9 years ago by jdemeyer

  • Report Upstream changed from N/A to Fixed upstream, but not in a stable release.

comment:28 Changed 9 years ago by jdemeyer

  • Description modified (diff)

Changed 9 years ago by jdemeyer

Patch for the Sage library

Changed 9 years ago by jdemeyer

Patch for the mpc spkg, for review only

comment:29 Changed 9 years ago by jdemeyer

  • Status changed from needs_work to needs_review

comment:30 Changed 9 years ago by jdemeyer

Tested on the buildbots, no problems.

comment:31 Changed 9 years ago by vbraun

  • Status changed from needs_review to positive_review

Looks good to me.

comment:32 Changed 9 years ago by jdemeyer

  • Merged in set to sage-5.3.beta2
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:33 Changed 9 years ago by jdemeyer

  • Reviewers changed from Leif Leonhardy to Leif Leonhardy, Volker Braun

comment:34 Changed 9 years ago by jdemeyer

  • Report Upstream changed from Fixed upstream, but not in a stable release. to Fixed upstream, in a later stable release.

MPC-1.0.1 just got released.

Note: See TracTickets for help on using tickets.