Re: building gmp-6.1 for s390 (31-bit) w/asm disabled failing with undefined sdiv_qrnnd

2016-12-09 Thread Mike Frysinger
On 09 Dec 2016 22:29, Torbjörn Granlund wrote:
>   > When other packages rely on reverse engineering of GMP's internals, then
>   > things such as this are bound to happen.
>   
>   i don't think it's that simple
>   
>   and udiv_qrnnd in mpfr-longlong.h looks like:
>   /* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
>  __udiv_w_sdiv (defined in libgcc or elsewhere).  */
>   #if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
>   #define udiv_qrnnd(q, r, nh, nl, d) \
> do {  
> \
>   UWtype __r; 
> \
>   (q) = __MPN(udiv_w_sdiv) (&__r, nh, nl, d); 
> \
>   (r) = __r;  
> \
> } while (0)
>   #endif
>   
> Right.  The longlong.h file is shared among several GNU programs, but I
> long ago stopped trying to keep GMP's version easily usable outside of
> GMP.
> 
> In particular, GMP's longlong.h requires various external functions, and
> the condition under which these are needed are part of the internals.
> 
> This is a MPFR problem.  It is unfixable in GMP.

OK, i've moved this to MPFR's tracker:

https://gforge.inria.fr/tracker/index.php?func=detail&aid=21053&group_id=136&atid=619
-mike


signature.asc
Description: Digital signature
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: building gmp-6.1 for s390 (31-bit) w/asm disabled failing with undefined sdiv_qrnnd

2016-12-09 Thread Mike Frysinger
On 09 Dec 2016 20:26, Marc Glisse wrote:
> On Fri, 9 Dec 2016, Mike Frysinger wrote:
> > now the __gmpn_udiv_w_sdiv symbol is exported based on the asm
> > configure flag.  mpfr will link against it if it's available,
> 
> Does mpfr always do that, or only with --with-gmp-build or equivalent?

a simple `./configure` is sufficient to reproduce
-mike


signature.asc
Description: Digital signature
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: building gmp-6.1 for s390 (31-bit) w/asm disabled failing with undefined sdiv_qrnnd

2016-12-09 Thread Mike Frysinger
On 09 Dec 2016 20:20, Torbjörn Granlund wrote:
> Mike Frysinger  writes:
> 
>   now the __gmpn_udiv_w_sdiv symbol is exported based on the asm
>   configure flag.  mpfr will link against it if it's available,
>   and if you rebuild gmp w/asm disabled, then mpfr is left in a
>   broken state until it gets rebuilt.  this can be a problem when
>   gcc itself relies on gmp/mpfr now :).
>   
>   here's gmp-6.1.0 built w/--enable-asm:
>   $ readelf -sW /usr/lib/libgmp.so | grep udiv_w_sdiv
>  439: 00025538   366 FUNCGLOBAL DEFAULT   10 __gmpn_udiv_w_sdiv
>   here it's built w/--disable-asm:
>   $ readelf -sW /usr/lib/libgmp.so | grep udiv_w_sdiv
>   
> 
> I don't see a solution to this within GMP.
> 
> When other packages rely on reverse engineering of GMP's internals, then
> things such as this are bound to happen.

i don't think it's that simple

here's the mpfr build output:
$ s390-ibm-linux-gnu-gcc -std=gnu99 -DTIME_WITH_SYS_TIME=1 -DHAVE_INTTYPES_H=1 
-DHAVE_STDINT_H=1 -DHAVE_LOCALE_H=1 -DHAVE_WCHAR_H=1 -DHAVE_STDARG=1 
-DHAVE_SYS_TIME_H=1 -DHAVE_STRUCT_LCONV_DECIMAL_POINT=1 
-DHAVE_STRUCT_LCONV_THOUSANDS_SEP=1 -DHAVE_ALLOCA_H=1 -DHAVE_STDINT_H=1 
-DHAVE_VA_COPY=1 -DHAVE_SETLOCALE=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_LONG_LONG=1 
-DHAVE_INTMAX_T=1 -DMPFR_HAVE_INTMAX_MAX=1 -DMPFR_HAVE_FESETROUND=1 
-DHAVE_DENORMS=1 -DHAVE_SIGNEDZ=1 -DHAVE_ROUND=1 -DHAVE_TRUNC=1 -DHAVE_FLOOR=1 
-DHAVE_CEIL=1 -DHAVE_NEARBYINT=1 -DHAVE_LDOUBLE_IEEE_QUAD_BIG=1 
-DMPFR_USE_THREAD_SAFE=1 -DHAVE_CLOCK_GETTIME=1 -DLT_OBJDIR=\".libs/\" 
-DHAVE_ATTRIBUTE_MODE=1 -DHAVE___GMPN_ROOTREM=1 -DHAVE___GMPN_SBPI1_DIVAPPR_Q=1 
-I. -Wall -Wmissing-prototypes -Wpointer-arith -O2 -pipe -march=z10 -c 
mulders.c -o mulders.o
mulders.c: In function ‘mpfr_divhigh_n_basecase’:
mulders.c:221:7: warning: implicit declaration of function ‘__gmpn_udiv_w_sdiv’ 
[-Wimplicit-function-declaration]
   invert_limb (dinv, d1);
   ^

let's look at the preprocessed output for that symbol:
static mp_limb_t
mpfr_divhigh_n_basecase (mpfr_limb_ptr qp, mpfr_limb_ptr np,
 mpfr_limb_srcptr dp, mp_size_t n)
{
...
  if (n == 1)
{
  do { mp_limb_t dummy; ((void) 0); do { UWtype __r; (dinv) = 
__gmpn_udiv_w_sdiv (&__r, ~(d1), ~(mp_limb_t)0, d1); (dummy) = __r; } while 
(0); } while (0);

mulders.c looks like:
static mp_limb_t
mpfr_divhigh_n_basecase (mpfr_limb_ptr qp, mpfr_limb_ptr np,
 mpfr_limb_srcptr dp, mp_size_t n)
{
...
  if (n == 1)
{
  invert_limb (dinv, d1);

invert_limb in mpfr-gmp.h looks like:
#undef invert_limb
#define invert_limb(invxl,xl) \
  do {\
mp_limb_t dummy;  \
MPFR_ASSERTD ((xl) != 0); \
udiv_qrnnd (invxl, dummy, ~(xl), ~(mp_limb_t)0, xl);  \
  } while (0)

and udiv_qrnnd in mpfr-longlong.h looks like:
/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
   __udiv_w_sdiv (defined in libgcc or elsewhere).  */
#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
#define udiv_qrnnd(q, r, nh, nl, d) \
  do {  \
UWtype __r; \
(q) = __MPN(udiv_w_sdiv) (&__r, nh, nl, d); \
(r) = __r;  \
  } while (0)
#endif

finally, __MPN comes from gmp's installed gmp.h header:
#ifndef __MPN
#define __MPN(x) __gmpn_##x
#endif

otherwise mpfr's mpfr-longlong.h's copy would have kicked in:
/* This is used to make sure no undesirable sharing between different libraries
   that use this file takes place.  */
#ifndef __MPN
#define __MPN(x) __##x
#endif

so attempting to share code has caused a collision to rise up.
-mike


signature.asc
Description: Digital signature
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: building gmp-6.1 for s390 (31-bit) w/asm disabled failing with undefined sdiv_qrnnd

2016-12-09 Thread Mike Frysinger
On 26 Nov 2016 17:06, Mike Frysinger wrote:
> On 27 Nov 2016 01:06, Torbjörn Granlund wrote:
> > Mike Frysinger  writes:
> > 
> >   building gmp-6.1.0 & gmp-6.1.1 like so:
> >   ./configure \
> > --build=s390-ibm-linux-gnu --host=s390-ibm-linux-gnu \
> > --enable-shared --disable-assembly --enable-cxx --disable-static
> >   
> >   triggers this warning:
> >   udiv_w_sdiv.c: In function ‘__gmpn_udiv_w_sdiv’:
> >   udiv_w_sdiv.c:58:4: warning: implicit declaration of function 
> > ‘sdiv_qrnnd’ [-Wimplicit-function-declaration]
> >   sdiv_qrnnd (q, r, a1, a0, d);
> >   
> >   and the final lib has an undefined ref to the sdiv_qrnnd symbol.
> > 
> > Please try this https://gmplib.org/repo/gmp/rev/1890de258348 and comment
> > back.
> 
> it seemed to fix my builds.  thanks!

turns out, this causes problems too :(

now the __gmpn_udiv_w_sdiv symbol is exported based on the asm
configure flag.  mpfr will link against it if it's available,
and if you rebuild gmp w/asm disabled, then mpfr is left in a
broken state until it gets rebuilt.  this can be a problem when
gcc itself relies on gmp/mpfr now :).

here's gmp-6.1.0 built w/--enable-asm:
$ readelf -sW /usr/lib/libgmp.so | grep udiv_w_sdiv
   439: 00025538   366 FUNCGLOBAL DEFAULT   10 __gmpn_udiv_w_sdiv
here it's built w/--disable-asm:
$ readelf -sW /usr/lib/libgmp.so | grep udiv_w_sdiv

-mike


signature.asc
Description: Digital signature
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: building gmp-6.1 for s390 (31-bit) w/asm disabled failing with undefined sdiv_qrnnd

2016-11-26 Thread Mike Frysinger
On 27 Nov 2016 01:06, Torbjörn Granlund wrote:
> Mike Frysinger  writes:
> 
>   building gmp-6.1.0 & gmp-6.1.1 like so:
>   ./configure \
>   --build=s390-ibm-linux-gnu --host=s390-ibm-linux-gnu \
>   --enable-shared --disable-assembly --enable-cxx --disable-static
>   
>   triggers this warning:
>   udiv_w_sdiv.c: In function ‘__gmpn_udiv_w_sdiv’:
>   udiv_w_sdiv.c:58:4: warning: implicit declaration of function ‘sdiv_qrnnd’ 
> [-Wimplicit-function-declaration]
>   sdiv_qrnnd (q, r, a1, a0, d);
>   
>   and the final lib has an undefined ref to the sdiv_qrnnd symbol.
> 
> Please try this https://gmplib.org/repo/gmp/rev/1890de258348 and comment
> back.

it seemed to fix my builds.  thanks!
-mike


signature.asc
Description: Digital signature
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


[PATCH] tune: fix spurious clock_gettime reference

2016-11-26 Thread Mike Frysinger
When running the tune program, the generated gmp-mparam.h header might
include an invalid line leading to build failures like so:
In file included from .../gmp-impl.h:145:0,
 from mp_bases.c:4:
../gmp-mparam.h:1:1: error: unknown type name 'clock_gettime'
 clock_gettime is 1.000ns accurate

This is because the tune source has one printf that is not protected
by the verbose flag leading it to be written to the output.

Credit to Conrad Kostecki for analysis.

URL: https://bugs.gentoo.org/568320
---
 tune/time.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tune/time.c b/tune/time.c
index e0d262096396..d1efb0a6d35d 100644
--- a/tune/time.c
+++ b/tune/time.c
@@ -773,8 +773,9 @@ cgt_works_p (void)
 }
 
   cgt_unittime = unit.tv_sec + unit.tv_nsec * 1e-9;
-  printf ("clock_gettime is %s accurate\n",
- unittime_string (cgt_unittime));
+  if (speed_option_verbose)
+printf ("clock_gettime is %s accurate\n",
+   unittime_string (cgt_unittime));
 
   if (cgt_unittime < 10e-9)
 {
-- 
2.11.0.rc2

___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


building gmp-6.1 for s390 (31-bit) w/asm disabled failing with undefined sdiv_qrnnd

2016-11-25 Thread Mike Frysinger
building gmp-6.1.0 & gmp-6.1.1 like so:
./configure \
--build=s390-ibm-linux-gnu --host=s390-ibm-linux-gnu \
--enable-shared --disable-assembly --enable-cxx --disable-static

triggers this warning:
udiv_w_sdiv.c: In function ‘__gmpn_udiv_w_sdiv’:
udiv_w_sdiv.c:58:4: warning: implicit declaration of function ‘sdiv_qrnnd’ 
[-Wimplicit-function-declaration]
sdiv_qrnnd (q, r, a1, a0, d);

and the final lib has an undefined ref to the sdiv_qrnnd symbol.

Torbjorn: you should have access to this system to reproduce -- lgentoo3.
-mike


signature.asc
Description: Digital signature
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs