Re: not really a bug but somewhat odd : checking compiler /usr/local/bin/gcc8 ... no, mpn_lshift_com

2019-07-28 Thread Dennis Clarke
On 7/28/19 8:09 AM, Vincent Lefevre wrote:
> On 2019-07-28 07:40:38 -0400, Dennis Clarke wrote:
>> On 7/28/19 7:32 AM, Vincent Lefevre wrote:
>>> On 2019-07-28 12:44:55 +0200, Vincent Lefevre wrote:
 On 2019-07-28 06:12:06 -0400, Dennis Clarke wrote:
> configure:6813: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest
> Abort trap (core dumped)

 I don't know in your case, but I fear that this program is buggy.
>>> [...]
>>>
>>> You can try the attached patch in case this would be the issue.
>>> This could also solve invisible failures (as occurring inside
>>> configure) in other cases.
>>>
>>
>> Thank you for that but I suspect the problem lay entirely elsewhere in
>> an unexpected place :
> 
> I don't see how you can deduce that.
> 

It's called being bloody wrong.

Dennis

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


Re: not really a bug but somewhat odd : checking compiler /usr/local/bin/gcc8 ... no, mpn_lshift_com

2019-07-28 Thread Dennis Clarke
On 7/28/19 7:32 AM, Vincent Lefevre wrote:
> On 2019-07-28 12:44:55 +0200, Vincent Lefevre wrote:
>> On 2019-07-28 06:12:06 -0400, Dennis Clarke wrote:
>>> configure:6813: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest
>>> Abort trap (core dumped)
>>
>> I don't know in your case, but I fear that this program is buggy.
> [...]
> 
> You can try the attached patch in case this would be the issue.
> This could also solve invisible failures (as occurring inside
> configure) in other cases.
> 

Thank you for that but I suspect the problem lay entirely elsewhere in
an unexpected place :

hydra$ cat foo.c

/* The following is mis-compiled by Intel ia-64 icc version 1.8 under
"icc -O3",  After several calls, the function writes partial garbage to
the result vector.  Perhaps relates to the chk.a.nc insn.  This code
needs
to be run to show the problem, but that's fine, the offending cc is a
native-only compiler so we don't have to worry about cross
compiling.  */

#if ! defined (__cplusplus)
#include 

void lshift_com (rp, up, n, cnt)
  unsigned long *rp;
  unsigned long *up;
  long n;
  unsigned cnt;
{
  unsigned long high_limb, low_limb;
  unsigned tnc;
  long i;
  up += n;
  rp += n;
  tnc = 8 * sizeof (unsigned long) - cnt;
  low_limb = *--up;
  high_limb = low_limb << cnt;
  for (i = n - 1; i != 0; i--)
{
  low_limb = *--up;
  *--rp = ~(high_limb | (low_limb >> tnc));
  high_limb = low_limb << cnt;
}
  *--rp = ~high_limb;
}

int main () {
  unsigned long *r, *r2;
  unsigned long a[88 + 1];
  long i;
  for (i = 0; i < 88 + 1; i++)
a[i] = ~0L;
  r = malloc (1 * sizeof (unsigned long));
  r2 = r;
  for (i = 0; i < 528; i += 23)
{
  lshift_com (r2, a,
  i / (8 * sizeof (unsigned long)) + 1,
  i % (8 * sizeof (unsigned long)));
  r2 += 88 + 1;
}
  if (r[2048] != 0 || r[2049] != 0 || r[2050] != 0 || r[2051] != 0 ||
  r[2052] != 0 || r[2053] != 0 || r[2054] != 0)
abort ();
  free (r);
  return 0;
}

#else

int main () {
  return 0;
}

#endif

hydra$


That compiles and runs fine on FreeBSD x86_64 with gcc 8.3.0 however on
 the ppc64 boxen :

hydra$ ls foo
foo
hydra$ gdb ./foo
GNU gdb (GDB) 8.3 [GDB v8.3 for FreeBSD]
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later

This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-portbld-freebsd13.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./foo...
warning: File
"/opt/bw/build/gmp-6.1.2_FreeBSD_13.0-CURRENT_r350103_ppc64.001/.gdbinit" 
auto-loading
has been declined by your `auto-load safe-path' set to
"$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path
/opt/bw/build/gmp-6.1.2_FreeBSD_13.0-CURRENT_r350103_ppc64.001/.gdbinit
line to your configuration file "/home/dclarke/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/home/dclarke/.gdbinit".
--Type  for more, q to quit, c to continue without paging--c
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the
shell:
info "(gdb)Auto-loading safe path"
(gdb) run
Starting program:
/opt/bw/build/gmp-6.1.2_FreeBSD_13.0-CURRENT_r350103_ppc64.001/foo

Program received signal SIGABRT, Aborted.
0x00081026b898 in .__sys_thr_kill () from /lib/libc.so.7
(gdb) bt
#0  0x00081026b898 in .__sys_thr_kill () from /lib/libc.so.7
#1  0x00081026af3c in .__raise () from /lib/libc.so.7
#2  0x0008101cf41c in abort () from /lib/libc.so.7
#3  0x1cb4 in main () at foo.c:51
(gdb) quit
A debugging session is active.

Inferior 1 [process 3361] will be killed.

Quit anyway? (y or n) y
hydra$

Well looks to be in libc.so.7 here.   :-(

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


Re: not really a bug but somewhat odd : checking compiler /usr/local/bin/gcc8 ... no, mpn_lshift_com

2019-07-28 Thread Vincent Lefevre
On 2019-07-28 12:44:55 +0200, Vincent Lefevre wrote:
> On 2019-07-28 06:12:06 -0400, Dennis Clarke wrote:
> > configure:6813: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest
> > Abort trap (core dumped)
> 
> I don't know in your case, but I fear that this program is buggy.
[...]

You can try the attached patch in case this would be the issue.
This could also solve invisible failures (as occurring inside
configure) in other cases.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
diff -r 36b5993aefae acinclude.m4
--- a/acinclude.m4  Sat Jul 13 22:25:31 2019 +0200
+++ b/acinclude.m4  Sun Jul 28 13:26:13 2019 +0200
@@ -660,11 +660,7 @@
 
 #if ! defined (__cplusplus)
 unsigned long
-lshift_com (rp, up, n, cnt)
-  unsigned long *rp;
-  unsigned long *up;
-  long n;
-  unsigned cnt;
+lshift_com (unsigned long *rp, unsigned long *up, long n, unsigned cnt)
 {
   unsigned long retval, high_limb, low_limb;
   unsigned tnc;
@@ -711,11 +707,7 @@
 #if ! defined (__cplusplus)
 #include 
 void
-lshift_com (rp, up, n, cnt)
-  unsigned long *rp;
-  unsigned long *up;
-  long n;
-  unsigned cnt;
+lshift_com (unsigned long *rp, unsigned long *up, long n, unsigned cnt)
 {
   unsigned long high_limb, low_limb;
   unsigned tnc;
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: not really a bug but somewhat odd : checking compiler /usr/local/bin/gcc8 ... no, mpn_lshift_com

2019-07-28 Thread Dennis Clarke
On 7/28/19 6:21 AM, paul zimmermann wrote:
>Hi Dennis,
> 
>> Dear gmp/mpfr folks :
> 
> this apparently has nothing to do with mpfr.

No but I know where you all tend to read mailists. :-)

> 
> From the error message in configure ("no, mpn_lshift_com optimization 2,
> program does not run") you can conclude that your compiler is broken.
> Please report to the compiler vendor.

Seems hard to accept given that the FreeBSD provided gcc 8.3.0 compiler
did actually compile and install libgmp from "ports" on this machine.

However when I try this manually I get the config error that I just have
not seen before.




-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: not really a bug but somewhat odd : checking compiler /usr/local/bin/gcc8 ... no, mpn_lshift_com

2019-07-28 Thread Vincent Lefevre
On 2019-07-28 06:12:06 -0400, Dennis Clarke wrote:
> configure:6813: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest
> Abort trap (core dumped)

I don't know in your case, but I fear that this program is buggy.

[...]
> void
> lshift_com (rp, up, n, cnt)
>   unsigned long *rp;
>   unsigned long *up;
>   long n;
>   unsigned cnt;

It uses the old pre-ANSI K function definition, and AFAIK, in
this case, there is no notion of prototype, i.e. it is expected
that the caller passes compatible types as the compiler will not
be able to do type conversion. Note that the 4th parameter, cnt,
is of type unsigned int.

> {
>   unsigned long high_limb, low_limb;
>   unsigned tnc;
>   long i;
>   up += n;
>   rp += n;
>   tnc = 8 * sizeof (unsigned long) - cnt;
>   low_limb = *--up;
>   high_limb = low_limb << cnt;
>   for (i = n - 1; i != 0; i--)
> {
>   low_limb = *--up;
>   *--rp = ~(high_limb | (low_limb >> tnc));
>   high_limb = low_limb << cnt;
> }
>   *--rp = ~high_limb;
> }
> int
> main ()
> {
>   unsigned long *r, *r2;
>   unsigned long a[88 + 1];
>   long i;
>   for (i = 0; i < 88 + 1; i++)
> a[i] = ~0L;
>   r = malloc (1 * sizeof (unsigned long));
>   r2 = r;
>   for (i = 0; i < 528; i += 23)
> {
>   lshift_com (r2, a,
>   i / (8 * sizeof (unsigned long)) + 1,
>   i % (8 * sizeof (unsigned long)));

Here the 4th argument is of type >= long since i is of type long.
With calling via registers, this may not be an issue (here, the
value would be correct), but if the data are passed on the stack,
this will probably not work.

>   r2 += 88 + 1;
> }
>   if (r[2048] != 0 || r[2049] != 0 || r[2050] != 0 || r[2051] != 0 ||
>   r[2052] != 0 || r[2053] != 0 || r[2054] != 0)
> abort ();
>   free (r);
>   return 0;
> }
[...]

If you want an example about K function definition issues,
consider

foo (a)
{
}

main ()
{
  foo (1, 2);
  return 0;
}

With GCC, this builds without any error.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: not really a bug but somewhat odd : checking compiler /usr/local/bin/gcc8 ... no, mpn_lshift_com

2019-07-28 Thread paul zimmermann
   Hi Dennis,

> Dear gmp/mpfr folks :

this apparently has nothing to do with mpfr.

>From the error message in configure ("no, mpn_lshift_com optimization 2,
program does not run") you can conclude that your compiler is broken.
Please report to the compiler vendor.

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