NetBSD Problem Report #38364

From martin@duskware.de  Fri Apr  4 17:02:38 2008
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 8B26E63B293
	for <gnats-bugs@gnats.netbsd.org>; Fri,  4 Apr 2008 17:02:38 +0000 (UTC)
Message-Id: <20080404163933.3B23E63B293@narn.NetBSD.org>
Date: Fri,  4 Apr 2008 16:39:33 +0000 (UTC)
From: srcshelton@gmail.com
Reply-To: srcshelton@gmail.com
To: netbsd-bugs-owner@NetBSD.org
Subject: Patches to allow gmp to build on IRIX
X-Send-Pr-Version: www-1.0

>Number:         38364
>Category:       pkg
>Synopsis:       Patches to allow gmp to build on IRIX
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    irix-pkg-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 04 17:05:01 +0000 2008
>Last-Modified:  Sat Apr 05 04:15:49 +0000 2008
>Originator:     Stuart Shelton
>Release:        pkgsrc latest from CVS
>Organization:
>Environment:
IRIX64 octane 6.5 07202013 IP30; IRIX 6.5.30; MIPSpro Compilers Version 7.4.4m
>Description:

The following patches allow gmp to build and test successfully on IRIX:

--- configure.in        2007-12-17 11:49:07.703764040 +0000
+++ configure.in        2007-12-17 11:53:25.932823000 +0000
@@ -1542,6 +1542,7 @@
 # $abilist is restricted to just that choice.
 #
 if test -n "$ABI"; then
+  if test "$ABI" = "32"; then ABI=n32; fi
   found=no
   for abi in $abilist; do
     if test $abi = "$ABI"; then found=yes; break; fi

--- gmp-impl.h  2007-08-30 19:31:40.000000000 +0100
+++ gmp-impl.h        2007-12-17 18:42:57.675916520 +0000
@@ -189,6 +189,9 @@

 /* gmp_uint_least32_t is an unsigned integer type with at least 32 bits. */
 #if HAVE_UINT_LEAST32_T
+#ifdef __sgi
+typedef unsigned int            uint_least32_t;
+#endif
 typedef uint_least32_t      gmp_uint_least32_t;
 #else
 #if SIZEOF_UNSIGNED_SHORT >= 4

--- gmp.h       2007-12-17 18:57:17.066264600 +0000
+++ gmp.h     2007-12-17 18:42:57.674573960 +0000
@@ -348,6 +348,9 @@
    application uses for gmp_vprintf etc will almost certainly require the
    whole <stdarg.h> or <varargs.h> anyway.  */

+#ifdef __sgi
+typedef char *va_list;
+#endif
 #ifdef va_start
 #define _GMP_H_HAVE_VA_LIST 1
 #endif
@@ -516,9 +519,11 @@

 #if defined (__cplusplus)
 extern "C" {
+#ifndef __sgi
 #ifdef _GMP_H_HAVE_FILE
 using std::FILE;
 #endif
+#endif
 #endif

 #define mp_set_memory_functions __gmp_set_memory_functions

>How-To-Repeat:

uint_least32_t is defined in <stdint.h> (which is C(99) only) but not any C++ headers.  However, 'configure' runs it's tests against $CC rather than $CXX (presumably assuming that they are front-ends to identical compilers) and so the build thinks that HAVE_UINT_LEAST32_T is defined.  <stdint.h> does defined uint_least32_t as above.

I have no idea at all why va_list has to be defined: If you don't define it, the build fails saying that va_list is an unknown identifier... but if you do define it (as above) you get a warning that you're redefining an existing value!

Weird...

(This is almost always the case for C++ builds - va_list issues such as this seem to occur whenever it is used)
>Fix:

>Release-Note:

>Audit-Trail:
From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/38364: Patches to allow gmp to build on IRIX
Date: Fri, 4 Apr 2008 19:25:23 +0200

 On Fri, Apr 04, 2008 at 05:05:01PM +0000, srcshelton@gmail.com wrote:
 >  /* gmp_uint_least32_t is an unsigned integer type with at least 32 bits. */
 >  #if HAVE_UINT_LEAST32_T
 > +#ifdef __sgi
 > +typedef unsigned int            uint_least32_t;
 > +#endif
 >  typedef uint_least32_t      gmp_uint_least32_t;
 >  #else
 >  #if SIZEOF_UNSIGNED_SHORT >= 4

 This looks just wrong. Why does the else part not work? Or is the type
 used somewhere else unconditionally?

 > +#ifdef __sgi
 > +typedef char *va_list;
 > +#endif
 >  #ifdef va_start
 >  #define _GMP_H_HAVE_VA_LIST 1
 >  #endif

 This looks wrong as well.

 > @@ -516,9 +519,11 @@
 >  
 >  #if defined (__cplusplus)
 >  extern "C" {
 > +#ifndef __sgi
 >  #ifdef _GMP_H_HAVE_FILE
 >  using std::FILE;
 >  #endif
 > +#endif
 >  #endif

 Sounds like a miss detection, whatever sets _GMP_H_HAVE_FILE should be
 fixed instead, I bet.

 > uint_least32_t is defined in <stdint.h> (which is C(99) only) but not
 > any C++ headers.

 Your system compiler disallows including stdint.h (or inttypes.h for
 that matter) for C++?

 > I have no idea at all why va_list has to be defined: If you don't
 > define it, the build fails saying that va_list is an unknown
 > identifier... but if you do define it (as above) you get a warning that
 > you're redefining an existing value!

 Can you check stdarg.h for conditional includes on C99 or C++?

 Joerg

From: Stuart Shelton <srcshelton@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: pkg-manager@netbsd.org,
 gnats-admin@netbsd.org,
 pkgsrc-bugs@netbsd.org
Subject: Re: pkg/38364: Patches to allow gmp to build on IRIX
Date: Sat, 5 Apr 2008 01:51:58 +0100

 > On Fri, Apr 04, 2008 at 05:05:01PM +0000, srcshelton@gmail.com wrote:
 >> /* gmp_uint_least32_t is an unsigned integer type with at least 32  
 >> bits. */
 >> #if HAVE_UINT_LEAST32_T
 >> +#ifdef __sgi
 >> +typedef unsigned int            uint_least32_t;
 >> +#endif
 >> typedef uint_least32_t      gmp_uint_least32_t;
 >> #else
 >> #if SIZEOF_UNSIGNED_SHORT >= 4
 >
 > This looks just wrong. Why does the else part not work? Or is the type
 > used somewhere else unconditionally?

 'configure' checks what prototypes and symbols are defined using the  
 $CC compiler.  It then uses these results to compile code with $CXX -  
 which on IRIX is not correct.

 (Or, more specifically, if $CC is set to "c99" or "cc -c99" it's not  
 correct.  I'm not sure what happens if "c89" or "cc" without '-c99' in  
 CFLAGS are used...)

 What is happening is that configure is checking whether uint_least32_t  
 is defined for C99 code, which it is.  Then when the above code is  
 built with CC and the symbol isn't available, the build breaks.

 (The other alternative would be setting the variable to force  
 configure to assume that HAVE_UINT_LEAST32_T=no)

 Without patch, the output is:

 cc-1020 CC: ERROR File = ../gmp-impl.h, Line = 192
    The identifier "uint_least32_t" is undefined.

    typedef uint_least32_t      gmp_uint_least32_t;
            ^

 cc-1107 CC: WARNING File = ../gmp-impl.h, Line = 2880
    A signed bit field has a length of 1 bit.

          gmp_uint_least32_t sig:1;
                             ^


 >> +#ifdef __sgi
 >> +typedef char *va_list;
 >> +#endif
 >> #ifdef va_start
 >> #define _GMP_H_HAVE_VA_LIST 1
 >> #endif
 >
 > This looks wrong as well.

 I can't explain this one, and it's not limited to GMP.  This change  
 does solve the problem, however.  See below.


 >> @@ -516,9 +519,11 @@
 >>
 >> #if defined (__cplusplus)
 >> extern "C" {
 >> +#ifndef __sgi
 >> #ifdef _GMP_H_HAVE_FILE
 >> using std::FILE;
 >> #endif
 >> +#endif
 >> #endif
 >
 > Sounds like a miss detection, whatever sets _GMP_H_HAVE_FILE should be
 > fixed instead, I bet.

 If it helps, the error without the patch is:

 cc-1132 CC: ERROR File = ../gmp.h, Line = 520
    The namespace "std" has no member "FILE".

    using std::FILE;
               ^


 >> uint_least32_t is defined in <stdint.h> (which is C(99) only) but not
 >> any C++ headers.
 >
 > Your system compiler disallows including stdint.h (or inttypes.h for
 > that matter) for C++?

 The following headers #error out if not building C99 code (which C++  
 doesn't conform to):

 complex.h
 fenv.h
 stdbool.h
 stdint.h
 tgmath.h

 inttypes.h is valid, but doesn't define uint_least32_t.


 >> I have no idea at all why va_list has to be defined: If you don't
 >> define it, the build fails saying that va_list is an unknown
 >> identifier... but if you do define it (as above) you get a warning  
 >> that
 >> you're redefining an existing value!
 >
 > Can you check stdarg.h for conditional includes on C99 or C++?

 <stdarg.h> does nothing but #include <internal/stdarg_core.h>.   This  
 in turn #includes <sgidefs.h> and <internal/sgimacros.h>, before:

 #define _INT 0
 #define _FP  1
 #define _STRUCT 2

 /* Define the va_list type: */
 __SGI_LIBC_BEGIN_NAMESPACE_STD
 #ifndef _VA_LIST_
 #define _VA_LIST_
 typedef char *va_list;
 #endif /* !_VA_LIST_ */

 __SGI_LIBC_END_NAMESPACE_STD

 ... the two previous included headers do define some symbols based on  
 C99 or C++, but they're all self-contained.  I guess that means the  
 problem is related to the NAMESPACE_STD lines - but I don't fully  
 understand what these do.

 sgimacros.h says:


 /*   __SGI_LIBC_BEGIN_NAMESPACE_STD
   *       Begin namespace std. Does nothing unless this is C++ and we're
   *       putting the C library into std.
   */
 #if defined(__cplusplus) && defined(_LIBC_IN_NAMESPACE_STD_)
 #  define  __SGI_LIBC_BEGIN_NAMESPACE_STD namespace std {
 #  define  __SGI_LIBC_END_NAMESPACE_STD }
 #else /* defined(__cplusplus) && defined(_LIBC_IN_NAMESPACE_STD_) */
 #  define  __SGI_LIBC_BEGIN_NAMESPACE_STD
 #  define  __SGI_LIBC_END_NAMESPACE_STD
 #endif /* defined(__cplusplus) && defined(_LIBC_IN_NAMESPACE_STD_) */

 What I don't understand, as I mentioned, is that either va_list seems  
 undefined if not explicitly declared, but if it is declared then a  
 warning about redefinition is output.  Is this a namespace issue?

Responsible-Changed-From-To: pkg-manager->irix-pkg-people
Responsible-Changed-By: obache@NetBSD.org
Responsible-Changed-When: Sat, 05 Apr 2008 04:15:49 +0000
Responsible-Changed-Why:
Problem on IRIX.


>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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.