NetBSD Problem Report #51788

From hf@spg.tu-darmstadt.de  Fri Jan  6 15:04:02 2017
Return-Path: <hf@spg.tu-darmstadt.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 614357A16E
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  6 Jan 2017 15:04:02 +0000 (UTC)
Message-Id: <201701061502.v06F2rsQ008609@Gstoder.nt.e-technik.tu-darmstadt.de>
Date: Fri, 6 Jan 2017 16:02:53 +0100 (CET)
From: Hauke Fath <hf@spg.tu-darmstadt.de>
Reply-To: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: Hauke Fath <hf@spg.tu-darmstadt.de>
Subject: devel/gmp build fails in configure phase
X-Send-Pr-Version: 3.95

>Number:         51788
>Category:       pkg
>Synopsis:       devel/gmp build fails in configure phase
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 06 15:05:00 +0000 2017
>Closed-Date:    Thu Jun 15 04:18:49 +0000 2017
>Last-Modified:  Thu Jun 15 04:20:00 +0000 2017
>Originator:     Hauke Fath
>Release:        NetBSD 7.99.50
>Organization:
Technische Universitaet Darmstadt
>Environment:


System: NetBSD Gstoder 7.99.50 NetBSD 7.99.50 (MONOLITHIC) #0: Fri Dec 16 15:07:39 CET 2016 hf@Hochstuhl:/var/obj/netbsd-builds/developer/i386/sys/arch/i386/compile/MONOLITHIC i386
Architecture: i386
Machine: i386
>Description:

	The devel/gmp build fails early with

[...]
===> Configuring for gmp-6.1.2
cd /var/obj/pkgsrc/devel/gmp/work/gmp-6.1.2 && type autoconf && autoconf
autoconf is /var/obj/pkgsrc/devel/gmp/work/.tools/bin/autoconf
=> Modifying GNU configure scripts to avoid --recheck
=> Replacing config-guess with pkgsrc versions
=> Replacing config-sub with pkgsrc versions
=> Replacing install-sh with pkgsrc version
=> Checking for portability problems in extracted files
checking build system type... i486--netbsdelf
checking host system type... i486--netbsdelf
checking for a BSD-compatible install... /usr/bin/install -c -o hf -g spgmit
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... /usr/bin/awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking ABI=32
checking compiler gcc -O2 ... no, mpn_lshift_com optimization 2, program does not run
configure: error: could not find a working compiler, see config.log for details
*** Error code 1


	The config.log has

[...]
Test compile: mpn_lshift_com optimization 2
configure:6805: gcc -O2  conftest.c >&5
configure:6808: $? = 0
configure:6813: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest
[1]   Abort trap (core dumped) ./a.out
eval: ./b.out: not found
eval: ./a.exe: not found
eval: ./a_out.exe: not found
eval: ./conftest: not found
configure:6816: $? = 127
failed program was:
/* 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 <stdlib.h>
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 (10000 * 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

configure:6962: result: no, mpn_lshift_com optimization 2, program does not run
configure:7200: error: could not find a working compiler, see config.log for details
[...]



>How-To-Repeat:

	Build devel/gmp on NetBSD-current/i386, find you cannot.


>Fix:

	No idea.



>Release-Note:

>Audit-Trail:
From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/51788: devel/gmp build fails in configure phase
Date: Sat, 7 Jan 2017 02:06:51 +0000

 On Fri, Jan 06, 2017 at 03:05:00PM +0000, Hauke Fath wrote:
  > 	The devel/gmp build fails early with
  > [...]

 I guess the first question is: does it work with -O1?

 -- 
 David A. Holland
 dholland@netbsd.org

From: Masanobu SAITOH <msaitoh@execsw.org>
To: gnats-bugs@NetBSD.org
Cc: msaitoh@execsw.org,
 "hf@spg.tu-darmstadt.de >> Hauke Fath" <hf@spg.tu-darmstadt.de>
Subject: Re: pkg/51788 devel/gmp build fails in configure phase
Date: Wed, 14 Jun 2017 15:41:31 +0900

 Hi.

 > checking compiler gcc -O2 ... no, mpn_lshift_com optimization 2, program does not run
 > configure: error: could not find a working compiler, see config.log for details
 > *** Error code 1

 I can reproduce this problem with "/etc/malloc.conf -> J"
 Without the malloc.conf, I can compile it.

   The following change fixes with my i386 machine
 (malloc() -> calloc())

 OK to commit?

 Index: distinfo
 ===================================================================
 RCS file: /cvsroot/pkgsrc/devel/gmp/distinfo,v
 retrieving revision 1.52
 diff -u -p -r1.52 distinfo
 --- distinfo	19 Dec 2016 08:50:45 -0000	1.52
 +++ distinfo	14 Jun 2017 04:15:11 -0000
 @@ -5,5 +5,5 @@ RMD160 (gmp-6.1.2.tar.bz2) = 03b905b4d7f
   SHA512 (gmp-6.1.2.tar.bz2) = 268db88447174617f5746d9a6ba2b105940cc1a5e73155eb23b6eedf55f8e7724eda05d161b2de19aca9e794956d226ba9ed6f23124c7c82f7e1872e32b003cf
   Size (gmp-6.1.2.tar.bz2) = 2386766 bytes
   SHA1 (patch-aa) = dec275cbd5886a70f7cf0def1dedf01e7e4a49e9
 -SHA1 (patch-ab) = 829812822a72a4926ea4cf6e8ffafdcd13a0f76c
   SHA1 (patch-ac) = 6f7de0a285bec2c2645479d3090dc0276580f3d8
 +SHA1 (patch-acinclude.m4) = 7c8522c0c16f576c2f20794f0f2cac5df0066737
 Index: patches/patch-ab
 ===================================================================
 RCS file: patches/patch-ab
 diff -N patches/patch-ab
 --- patches/patch-ab	31 Jan 2013 20:30:26 -0000	1.8
 +++ /dev/null	1 Jan 1970 00:00:00 -0000
 @@ -1,23 +0,0 @@
 -$NetBSD: patch-ab,v 1.8 2013/01/31 20:30:26 adam Exp $
 -
 -Fixed detection of __attribute__((__mode__(XX))) for sunpro.
 -
 ---- acinclude.m4.orig	2007-09-01 12:09:03.000000000 +0200
 -+++ acinclude.m4	2007-11-25 09:26:07.000000000 +0100
 -@@ -3068,7 +3068,15 @@ dnl  Introduced in gcc 2.2, but perhaps
 - AC_DEFUN([GMP_C_ATTRIBUTE_MODE],
 - [AC_CACHE_CHECK([whether gcc __attribute__ ((mode (XX))) works],
 -                 gmp_cv_c_attribute_mode,
 --[AC_TRY_COMPILE([typedef int SItype __attribute__ ((mode (SI)));], ,
 -+[AC_TRY_COMPILE([
 -+  typedef int SItype __attribute__ ((mode (SI)));
 -+  typedef int QItype __attribute__ ((mode (QI)));
 -+], [
 -+  switch (1) {
 -+  case sizeof(SItype):
 -+  case sizeof(QItype): ;
 -+  }
 -+],
 -   gmp_cv_c_attribute_mode=yes, gmp_cv_c_attribute_mode=no)
 - ])
 - if test $gmp_cv_c_attribute_mode = yes; then
 Index: patches/patch-acinclude.m4
 ===================================================================
 RCS file: patches/patch-acinclude.m4
 diff -N patches/patch-acinclude.m4
 --- /dev/null	1 Jan 1970 00:00:00 -0000
 +++ patches/patch-acinclude.m4	14 Jun 2017 04:15:11 -0000
 @@ -0,0 +1,28 @@
 +--- acinclude.m4.orig	2016-12-17 00:45:27.000000000 +0900
 ++++ acinclude.m4	2017-06-14 13:05:04.000000000 +0900
 +@@ -741,7 +741,7 @@ main ()
 +   long i;
 +   for (i = 0; i < 88 + 1; i++)
 +     a[i] = ~0L;
 +-  r = malloc (10000 * sizeof (unsigned long));
 ++  r = calloc (10000, sizeof (unsigned long));
 +   r2 = r;
 +   for (i = 0; i < 528; i += 23)
 +     {
 +@@ -3228,7 +3228,15 @@ dnl  Introduced in gcc 2.2, but perhaps
 + AC_DEFUN([GMP_C_ATTRIBUTE_MODE],
 + [AC_CACHE_CHECK([whether gcc __attribute__ ((mode (XX))) works],
 +                 gmp_cv_c_attribute_mode,
 +-[AC_TRY_COMPILE([typedef int SItype __attribute__ ((mode (SI)));], ,
 ++[AC_TRY_COMPILE([
 ++  typedef int SItype __attribute__ ((mode (SI)));
 ++  typedef int QItype __attribute__ ((mode (QI)));
 ++], [
 ++  switch (1) {
 ++  case sizeof(SItype):
 ++  case sizeof(QItype): ;
 ++  }
 ++],
 +   gmp_cv_c_attribute_mode=yes, gmp_cv_c_attribute_mode=no)
 + ])
 + if test $gmp_cv_c_attribute_mode = yes; then


 -- 
 -----------------------------------------------
                  SAITOH Masanobu (msaitoh@execsw.org
                                   msaitoh@netbsd.org)

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/51788: devel/gmp build fails in configure phase
Date: Wed, 14 Jun 2017 10:02:26 +0000

 looks good to me :-)
 good find!

From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/51788 devel/gmp build fails in configure phase
Date: Wed, 14 Jun 2017 22:44:00 +0000

 On Wed, Jun 14, 2017 at 06:45:01AM +0000, Masanobu SAITOH wrote:
  >    The following change fixes with my i386 machine
  >  (malloc() -> calloc())
  >  
  >  OK to commit?

 Please propagate the existing patch comment instead of dropping it...
 (also add one for your bit)

 also this seems to be an upstream bug so trying to file it upstream
 might be worthwhile.

 Seems fine otherwise.

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: open->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Thu, 15 Jun 2017 04:18:49 +0000
State-Changed-Why:
Fixed.
Thanks.


From: Masanobu SAITOH <msaitoh@execsw.org>
To: gnats-bugs@NetBSD.org
Cc: msaitoh@execsw.org,
 "hf@spg.tu-darmstadt.de >> Hauke Fath" <hf@spg.tu-darmstadt.de>,
 dholland-pbugs@netbsd.org
Subject: Re: pkg/51788 devel/gmp build fails in configure phase
Date: Thu, 15 Jun 2017 13:17:56 +0900

   dh said:
 >   >  OK to commit?
 >  
 >  Please propagate the existing patch comment instead of dropping it...
 >  (also add one for your bit)

   Oh. I've forgotten it. Thanks.

 >  also this seems to be an upstream bug so trying to file it upstream
 >  might be worthwhile.

   That diff was a part of the following commit and new
 version have not released yet.

 	https://gmplib.org/repo/gmp/rev/2ce5c60f5372

 Yes, it's not related to AMD zen :)

 -- 
 -----------------------------------------------
                  SAITOH Masanobu (msaitoh@execsw.org
                                   msaitoh@netbsd.org)

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.