NetBSD Problem Report #51424

From www@NetBSD.org  Thu Aug 18 06:25:36 2016
Return-Path: <www@NetBSD.org>
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 02E107A218
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 18 Aug 2016 06:25:36 +0000 (UTC)
Message-Id: <20160818062535.035CD7A286@mollari.NetBSD.org>
Date: Thu, 18 Aug 2016 06:25:35 +0000 (UTC)
From: will@worrbase.com
Reply-To: will@worrbase.com
To: gnats-bugs@NetBSD.org
Subject: pkgtools/libnbcompat string.h header does not properly guard strdup definition
X-Send-Pr-Version: www-1.0

>Number:         51424
>Category:       pkg
>Synopsis:       pkgtools/libnbcompat string.h header does not properly guard strdup definition
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    joerg
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 18 06:30:00 +0000 2016
>Last-Modified:  Tue Sep 13 04:10:00 +0000 2016
>Originator:     William Orr
>Release:        current
>Organization:
>Environment:
Linux locke.worr.haus 4.6.5-200.fc23.x86_64 #1 SMP Thu Jul 28 01:10:25 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
>Description:
When trying to build stuff that relies on libnbcompat on Linux,
compilation fails in the case that strdup is defined as a macro. There
seems to be a mistake in the feature guard for the function prototype in
libnbcompat
>How-To-Repeat:
1. Install libnbcompat on a modern Fedora
2. Try and build pkgin
>Fix:
Index: pkgtools/libnbcompat/files/nbcompat/string.h
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/libnbcompat/files/nbcompat/string.h,v
retrieving revision 1.3
diff -u -b -w -p -r1.3 string.h
--- pkgtools/libnbcompat/files/nbcompat/string.h	8 Jun 2015 00:44:46 -0000	1.3
+++ pkgtools/libnbcompat/files/nbcompat/string.h	18 Aug 2016 05:37:36 -0000
@@ -40,7 +40,7 @@
  * Declare functions and macros that may be missing in <string.h>.
  */

-#if !HAVE_DECL_STRDUP
+#if !HAVE_STRDUP
 char	*strdup(const char *);
 #endif


>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->joerg
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Thu, 18 Aug 2016 17:53:51 +0000
Responsible-Changed-Why:
Over to maintainer.


From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/51424: pkgtools/libnbcompat string.h header does not
 properly guard strdup definition
Date: Fri, 19 Aug 2016 18:21:15 +0200

 On Thu, Aug 18, 2016 at 06:30:00AM +0000, will@worrbase.com wrote:
 > >Description:
 > When trying to build stuff that relies on libnbcompat on Linux,
 > compilation fails in the case that strdup is defined as a macro. There
 > seems to be a mistake in the feature guard for the function prototype in
 > libnbcompat

 The patch is not correct. The more interesting question would be why the
 configure check fails.

 Joerg

From: William Orr <will@worrbase.com>
To: gnats-bugs@NetBSD.org, joerg@NetBSD.org, gnats-admin@netbsd.org,
 pkgsrc-bugs@netbsd.org
Cc: 
Subject: Re: pkg/51424: pkgtools/libnbcompat string.h header does not properly
 guard strdup definition
Date: Fri, 19 Aug 2016 15:22:17 -0700

 On 8/19/16 9:25 AM, Joerg Sonnenberger wrote:
 > The following reply was made to PR pkg/51424; it has been noted by GNATS.
 > 
 > From: Joerg Sonnenberger <joerg@bec.de>
 > To: gnats-bugs@NetBSD.org
 > Cc: 
 > Subject: Re: pkg/51424: pkgtools/libnbcompat string.h header does not
 >  properly guard strdup definition
 > Date: Fri, 19 Aug 2016 18:21:15 +0200
 > 
 >  On Thu, Aug 18, 2016 at 06:30:00AM +0000, will@worrbase.com wrote:
 >  > >Description:
 >  > When trying to build stuff that relies on libnbcompat on Linux,
 >  > compilation fails in the case that strdup is defined as a macro. There
 >  > seems to be a mistake in the feature guard for the function prototype in
 >  > libnbcompat
 >  
 >  The patch is not correct. The more interesting question would be why the
 >  configure check fails.
 >  
 >  Joerg
 >  
 > 

 Hey,

 It's not that the configure test fails, it's that the configure test
 doesn't define HAVE_DECL_STRDUP - it defines HAVE_STRDUP. Normally, this
 would just shadow the declaration of strdup, but because strdup is a
 macro on this system, the preprocessor mangles the definition in
 nbcompat/string.h. When the header compilation check runs on
 nbcompat/string.h, this results in a compilation failure.

 Thanks

From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: joerg@NetBSD.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org,
	will@worrbase.com
Subject: Re: pkg/51424: pkgtools/libnbcompat string.h header does not
 properly guard strdup definition
Date: Sat, 20 Aug 2016 13:29:21 +0200

 On Sat, Aug 20, 2016 at 12:10:00AM +0000, William Orr wrote:
 >  It's not that the configure test fails, it's that the configure test
 >  doesn't define HAVE_DECL_STRDUP - it defines HAVE_STRDUP. Normally, this
 >  would just shadow the declaration of strdup, but because strdup is a
 >  macro on this system, the preprocessor mangles the definition in
 >  nbcompat/string.h. When the header compilation check runs on
 >  nbcompat/string.h, this results in a compilation failure.

 This is not true. When the detection works correctly, it does define
 HAVE_DECL_STRDUP. This is *not* a test for a function, but for an actual
 usable prototype and function.

 Joerg

From: William Orr <will@worrbase.com>
To: gnats-bugs@NetBSD.org, joerg@NetBSD.org, gnats-admin@netbsd.org,
 pkgsrc-bugs@netbsd.org
Cc: 
Subject: Re: pkg/51424: pkgtools/libnbcompat string.h header does not properly
 guard strdup definition
Date: Sun, 21 Aug 2016 20:31:51 -0700

 On 8/20/16 4:30 AM, Joerg Sonnenberger wrote:
 > The following reply was made to PR pkg/51424; it has been noted by GNATS.
 > 
 > From: Joerg Sonnenberger <joerg@bec.de>
 > To: gnats-bugs@NetBSD.org
 > Cc: joerg@NetBSD.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org,
 > 	will@worrbase.com
 > Subject: Re: pkg/51424: pkgtools/libnbcompat string.h header does not
 >  properly guard strdup definition
 > Date: Sat, 20 Aug 2016 13:29:21 +0200
 > 
 >  On Sat, Aug 20, 2016 at 12:10:00AM +0000, William Orr wrote:
 >  >  It's not that the configure test fails, it's that the configure test
 >  >  doesn't define HAVE_DECL_STRDUP - it defines HAVE_STRDUP. Normally, this
 >  >  would just shadow the declaration of strdup, but because strdup is a
 >  >  macro on this system, the preprocessor mangles the definition in
 >  >  nbcompat/string.h. When the header compilation check runs on
 >  >  nbcompat/string.h, this results in a compilation failure.
 >  
 >  This is not true. When the detection works correctly, it does define
 >  HAVE_DECL_STRDUP. This is *not* a test for a function, but for an actual
 >  usable prototype and function.
 >  
 >  Joerg
 >  
 > 

 Not sure what I'm missing. autoconf (when building pkgin) *does* set
 HAVE_STRDUP, but *does not* set HAVE_DECL_STRDUP. None of the other
 functions are guarded by a prefix. ./configure *does* throw errors when
 the function is guarded by the HAVE_DECL_STRDUP macro, since strdup on
 Fedora is a macro itself.

 Why is strdup the only function that is guarded by a macro prefixed with
 HAVE_DECL_ instead of HAVE_ ? Not super clear as to why on that front
 either.

From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: joerg@NetBSD.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org,
	will@worrbase.com
Subject: Re: pkg/51424: pkgtools/libnbcompat string.h header does not
 properly guard strdup definition
Date: Mon, 22 Aug 2016 10:41:16 +0200

 On Mon, Aug 22, 2016 at 03:35:01AM +0000, William Orr wrote:
 >  Not sure what I'm missing. autoconf (when building pkgin) *does* set
 >  HAVE_STRDUP, but *does not* set HAVE_DECL_STRDUP. None of the other
 >  functions are guarded by a prefix. ./configure *does* throw errors when
 >  the function is guarded by the HAVE_DECL_STRDUP macro, since strdup on
 >  Fedora is a macro itself.
 >  
 >  Why is strdup the only function that is guarded by a macro prefixed with
 >  HAVE_DECL_ instead of HAVE_ ? Not super clear as to why on that front
 >  either.

 Are we talking about libnbcompat or pkgin? They use different ways to
 check for strdup and different macros for the feature test.

 Joerg

From: William Orr <will@worrbase.com>
To: gnats-bugs@NetBSD.org, joerg@NetBSD.org, gnats-admin@netbsd.org,
 pkgsrc-bugs@netbsd.org
Cc: 
Subject: Re: pkg/51424: pkgtools/libnbcompat string.h header does not properly
 guard strdup definition
Date: Mon, 12 Sep 2016 21:06:40 -0700

 On 08/22/2016 01:45 AM, Joerg Sonnenberger wrote:
 > The following reply was made to PR pkg/51424; it has been noted by GNATS.
 > 
 > From: Joerg Sonnenberger <joerg@bec.de>
 > To: gnats-bugs@NetBSD.org
 > Cc: joerg@NetBSD.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org,
 > 	will@worrbase.com
 > Subject: Re: pkg/51424: pkgtools/libnbcompat string.h header does not
 >  properly guard strdup definition
 > Date: Mon, 22 Aug 2016 10:41:16 +0200
 > 
 >  On Mon, Aug 22, 2016 at 03:35:01AM +0000, William Orr wrote:
 >  >  Not sure what I'm missing. autoconf (when building pkgin) *does* set
 >  >  HAVE_STRDUP, but *does not* set HAVE_DECL_STRDUP. None of the other
 >  >  functions are guarded by a prefix. ./configure *does* throw errors when
 >  >  the function is guarded by the HAVE_DECL_STRDUP macro, since strdup on
 >  >  Fedora is a macro itself.
 >  >  
 >  >  Why is strdup the only function that is guarded by a macro prefixed with
 >  >  HAVE_DECL_ instead of HAVE_ ? Not super clear as to why on that front
 >  >  either.
 >  
 >  Are we talking about libnbcompat or pkgin? They use different ways to
 >  check for strdup and different macros for the feature test.
 >  
 >  Joerg
 >  
 > 

 Ah yes, this is my bad. I'll send a patch to fix pkgin.

 Thanks!

>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.