building gmp-6.1 for s390 (31-bit) w/asm disabled failing with undefined sdiv_qrnnd
Mike Frysinger
vapier at gentoo.org
Fri Dec 9 20:12:19 UTC 2016
On 09 Dec 2016 20:20, Torbjörn Granlund wrote:
> Mike Frysinger <vapier at gentoo.org> 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 FUNC GLOBAL DEFAULT 10 __gmpn_udiv_w_sdiv
> here it's built w/--disable-asm:
> $ readelf -sW /usr/lib/libgmp.so | grep udiv_w_sdiv
> <nothing>
>
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://gmplib.org/pipermail/gmp-bugs/attachments/20161209/9c527c11/attachment.bin>
More information about the gmp-bugs
mailing list