#11574: update M4RI to newest upstream release --------------------------------+------------------------------------------- Reporter: malb | Owner: Type: enhancement | Status: needs_work Priority: critical | Milestone: sage-4.7.2 Component: packages | Resolution: Keywords: sd32 | Work_issues: Upstream: N/A | Reviewer: Simon King Author: Martin Albrecht | Merged: Dependencies: #11261 | --------------------------------+-------------------------------------------
Comment(by leif): Replying to [comment:42 malb]: > I can confirm that passing {{{-msse2}}} fixes the issue. I guess I'll have to find a way to save the flags (to disc?) such that third parties (!PolyBoRi, Sage) can re-use them? Any suggestions on how to do that? Take a look at GMP's / MPIR's `gmp.h` and the various libs (like e.g. MPFR) that use it: {{{ #!sh $ egrep -B1 "__GMP_(CC|CFLAGS)" /usr/include/gmp.h /* Define CC and CFLAGS which were used to build this version of GMP */ #define __GMP_CC "gcc -std=gnu99" #define __GMP_CFLAGS "-march=native -g -O3" }}} I for example use (slightly OT): {{{ #!sh # We eventually use / add these settings (or parts of them) to "our" CFLAGS, # e.g. "-march=..." or "-mcpu=..." and "-mtune=..." to let gcc generate better, # processor-specific code, since ECM doesn't use them if we set our own: gmp_cc_pat='/^[ ]*#[ ]*define[ ]\+__GMP_CC[ ]\+/s/.*"\([^"]*\)"/\1/p' gmp_cflags_pat='/^[ ]*#[ ]*define[ ]\+__GMP_CFLAGS[ ]\+/s/.*"\([^"]*\)"/\1/p' gmp_cc=`sed -n -e "$gmp_cc_pat" "$SAGE_LOCAL"/include/gmp.h` gmp_cflags=`sed -n -e "$gmp_cflags_pat" "$SAGE_LOCAL"/include/gmp.h` system_gmp_h="" for incdir in /usr/include /usr/local/include; do if [ -f $incdir/gmp.h ]; then system_gmp_h=$incdir/gmp.h fi done if [ -n "$system_gmp_h" ]; then system_gmp_cc=`sed -n -e "$gmp_cc_pat" $system_gmp_h` system_gmp_cflags=`sed -n -e "$gmp_cflags_pat" $system_gmp_h` fi ... else # 'native' not supported, see if GMP / MPIR provides us some CPU type: for opt in $gmp_cflags; do case $opt in -march=*|-mcpu=*|-mtune*) echo "Found CPU parameter in gmp.h: $opt" cpu_params="$cpu_params $opt" ;; # perhaps add other options, too (e.g. for different compilers) *) other_gmp_cflags="$other_gmp_cflags $opt" esac done fi # Only add them if CFLAGS do not already contain similar: if [ -n "$cpu_params" ] && ! (echo "$CFLAGS" | egrep -- '-march=|-mcpu=|-mtune=' >/dev/null); then echo "Using additional host-specific CFLAGS: $cpu_params" CFLAGS="$cpu_params $CFLAGS" fi if [ -n "$other_gmp_cflags" ]; then echo "Not using other CFLAGS provided by gmp.h: $other_gmp_cflags" fi ... }}} Putting at least the ''necessary'' flags into `libm4ri.pc` is of course another, non-exclusive option, and even on systems that lack `pkg-config`, you could use the `.pc` file by adding a few lines of shell, Python or whatever code. You can also test whether adding `-msse2` (if using SSE2 is desired) is necessary at all, or supported (for simplicity, here `gcc`-specific): {{{ #!sh # Test whether '-msse2' is supported at all: if $CC -msse2 -c -x c /dev/null -o /dev/null &>/dev/null; then # Ok, supported. Do we need it? # [Should perhaps check whether __SSE2__ is really non-zero.] if ($CC -E -dM -x c /dev/null | grep -w __SSE2__) &>/dev/null; then # Fine, we don't need to pass any options to enable SSE2. required_cflag="" else required_cflag="-msse2" fi # Check whether the flag conflicts with others, perhaps specified by the user: if $CC $CFLAGS $required_cflag -c -x c /dev/null -o /dev/null &>/dev/null; then # Ok, compatible and sufficient. else # Conflicting flags, issue error message or try something else... fi else # Not supported, perhaps disable use of SSE2. fi }}} (The same tests can easily be performed from Python as well, e.g. in [Sage's] `setup.py` or `module_list.py`. You could also steal macros from autotools.) -- Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11574#comment:49> Sage <http://www.sagemath.org> Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, and MATLAB -- You received this message because you are subscribed to the Google Groups "sage-trac" group. To post to this group, send email to sage-trac@googlegroups.com. To unsubscribe from this group, send email to sage-trac+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-trac?hl=en.