Re: Compiling for ARMv8-A Using GCC 7.2.0 - Assertion error in gen-fac

2019-12-07 Thread Marco Bodrato
Ciao,

Il Ven, 6 Dicembre 2019 3:55 pm, Torbjörn Granlund ha scritto:
> ni...@lysator.liu.se (Niels Möller) writes:
>
>   > From my understanding this might be a difference in how GCC 7.2.0
>   > handles unsigned longs vs GCC 4.8.5.
>
>   Can you file a gcc bug? These constants are defined as

> The first thing to try might be gcc 7.4, which was the final gcc 7
> release.

There is also a 7.5 version, released Nov 14, 2019:
https://gcc.gnu.org/gcc-7/

Ĝis,
m

-- 
http://bodrato.it/papers/

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


RE: Compiling for ARMv8-A Using GCC 7.2.0 - Assertion error in gen-fac

2019-12-06 Thread Damm, Stephen
I also see no reasonable way for it to end up as 1.  If I printf("%lu") those 
same two variables the results are even more strange:

== GCC 4.8.5 ==
GMP_HLIMB_BIT=4294967296=1  

  
GMP_LLIMB_MASK=4294967295=

== GCC 7.2.0 ==
GMP_HLIMB_BIT=4294967296=1  

  
GMP_LLIMB_MASK=4294967297=10001

So it appears like the "-1" being applies to GMP_HLIMB_BIT is a +1 in GCC 
7.2.0.  I've not encountered behaviour like this before.  Very strange.

I am currently investigating if this is an issue with how GCC handles longs 
between 4.8.5 and 7.2.0 in ARM64 hosts builds. 

This concludes me to believe a bug in GCC ARM64 or a bug in GMP or I am somehow 
building GCC wrong but right enough that it can compile most other libraries.

I do notice in GCC 4.8.5 -mabi is not specified when compiling GMP.  When GCC 
7.2.0 goes to build GMP it is being explicit about the -mabi=lp64.  

If anything comes to mind let me know.  I'll post back here if I find out the 
cause.


Thanks,
Stephen Damm


-Original Message-
From: Niels Möller [mailto:ni...@lysator.liu.se] 
Sent: December 6, 2019 03:51
To: Damm, Stephen 
Cc: gmp-bugs@gmplib.org
Subject: Re: Compiling for ARMv8-A Using GCC 7.2.0 - Assertion error in gen-fac

"Damm, Stephen"  writes:

> I was able to narrow down the cause.  In GC 7.2.0 the GMP_LLIMB_MASK is wrong:
>
> =GCC 4.8.5=
> GMP_LIMB_BITS=64
> GMP_LLIMB_MASK=4294967295=0x
>
> =GCC 7.2.0=
> GMP_LIMB_BITS=64
> GMP_LLIMB_MASK=1=0x0001
>
> From my understanding this might be a difference in how GCC 7.2.0 handles 
> unsigned longs vs GCC 4.8.5.  It also could be I am missing some vital 
> compiler flag for GMP.

Can you file a gcc bug? These constants are defined as

#define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)/* 64, you say */

#define GMP_HLIMB_BIT ((mp_limb_t) 1 << (GMP_LIMB_BITS / 2)) #define 
GMP_LLIMB_MASK (GMP_HLIMB_BIT - 1)

I see no reasonable way that can end up defining GMP_LLIMB_MASK as 1.

Regards,
/Niels

--
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: Compiling for ARMv8-A Using GCC 7.2.0 - Assertion error in gen-fac

2019-12-06 Thread Torbjörn Granlund
ni...@lysator.liu.se (Niels Möller) writes:

  > I was able to narrow down the cause.  In GC 7.2.0 the GMP_LLIMB_MASK is 
wrong:
  >
  > =GCC 4.8.5=
  > GMP_LIMB_BITS=64
  > GMP_LLIMB_MASK=4294967295=0x
  >
  > =GCC 7.2.0=
  > GMP_LIMB_BITS=64
  > GMP_LLIMB_MASK=1=0x0001
  >
  > From my understanding this might be a difference in how GCC 7.2.0
  > handles unsigned longs vs GCC 4.8.5.  It also could be I am missing
  > some vital compiler flag for GMP.

  Can you file a gcc bug? These constants are defined as

  #define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)/* 64, you say */

  #define GMP_HLIMB_BIT ((mp_limb_t) 1 << (GMP_LIMB_BITS / 2))
  #define GMP_LLIMB_MASK (GMP_HLIMB_BIT - 1)

  I see no reasonable way that can end up defining GMP_LLIMB_MASK as 1.

The first thing to try might be gcc 7.4, which was the final gcc 7
release.

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: Compiling for ARMv8-A Using GCC 7.2.0 - Assertion error in gen-fac

2019-12-06 Thread Niels Möller
"Damm, Stephen"  writes:

> I was able to narrow down the cause.  In GC 7.2.0 the GMP_LLIMB_MASK is wrong:
>
> =GCC 4.8.5=
> GMP_LIMB_BITS=64
> GMP_LLIMB_MASK=4294967295=0x
>
> =GCC 7.2.0=
> GMP_LIMB_BITS=64
> GMP_LLIMB_MASK=1=0x0001
>
> From my understanding this might be a difference in how GCC 7.2.0 handles 
> unsigned longs vs GCC 4.8.5.  It also could be I am missing some vital 
> compiler flag for GMP.

Can you file a gcc bug? These constants are defined as

#define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)/* 64, you say */

#define GMP_HLIMB_BIT ((mp_limb_t) 1 << (GMP_LIMB_BITS / 2))
#define GMP_LLIMB_MASK (GMP_HLIMB_BIT - 1)

I see no reasonable way that can end up defining GMP_LLIMB_MASK as 1.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Compiling for ARMv8-A Using GCC 7.2.0 - Assertion error in gen-fac

2019-12-05 Thread Damm, Stephen
GMP-Bugs,

I am trying to build GMP 6.1.2 for ARMv8-A Thunderx2t99 (AARCH64) CPU on 
RHEL7.4.

I can build BINUTILS 2.29.1, GMP 6.1.2, and CC 7.2.0 using the system GCC 
4.8.5.  No errors, GMP passes its `make check` tests.  The gen-fac program 
works.

Next I use my GCC 7.2.0 to build everything again.  GMP fails with an assertion 
error before it gets very far into its build process.

During the GMP build process it builds a few programs, "gen-fac" being one of 
them.   This is the exact command the Makefile executes:
"custom_toolchain/bin/gcc -v `test -f 'gen-fac.c' || echo './'`gen-fac.c -o 
gen-fac"

It then tries to execute: "./gen-fac 64 0" which hits an assertion error if 
built using my GCC 7.2.0:
gen-fac: mini-gmp/mini-gmp.c:1207: mpn_limb_size_in_base_2: Assertion `u > 0' 
failed.
/bin/sh: line 1:  9766 Aborted (core dumped) ./gen-fac 64 0 > 
fac_table.h

It is dying due to an assertion in mpn_limb_size_in_base_2.  In this case `u` 
is exactly 0.

I was able to narrow down the cause.  In GC 7.2.0 the GMP_LLIMB_MASK is wrong:

=GCC 4.8.5=
GMP_LIMB_BITS=64
GMP_LLIMB_MASK=4294967295=0x

=GCC 7.2.0=
GMP_LIMB_BITS=64
GMP_LLIMB_MASK=1=0x0001

>From my understanding this might be a difference in how GCC 7.2.0 handles 
>unsigned longs vs GCC 4.8.5.  It also could be I am missing some vital 
>compiler flag for GMP.

Any ideas?


Thanks,
Stephen Damm
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs