Subject: Re: pkg/33403: Can't build perl module written by C++
To: None <jlam@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org,>
From: Johnny C. Lam <jlam@pkgsrc.org>
List: pkgsrc-bugs
Date: 05/05/2006 17:30:02
The following reply was made to PR pkg/33403; it has been noted by GNATS.

From: "Johnny C. Lam" <jlam@pkgsrc.org>
To: obata@lins.jp
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/33403: Can't build perl module written by C++
Date: Fri, 5 May 2006 17:27:34 +0000

 --Qxx1br4bt0+wmkIi
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Fri, May 05, 2006 at 11:25:02AM +0000, OBATA Akio wrote:
 >  
 >  If fllowing patch was applied, build OK.
 >  
 >  --- XSUB.h.orig 2006-04-13 10:28:48.000000000 +0900
 >  +++ XSUB.h      2006-05-05 20:11:43.000000000 +0900
 >  @@ -92,7 +92,7 @@
 >   #  define XS(name) __declspec(dllexport) void name(pTHX_ CV* cv)
 >   #else
 >   #  ifdef HASATTRIBUTE_UNUSED
 >  -#    define XS(name) void name(pTHX_ CV* cv __attribute__unused__)
 >  +#    define XS(name) void name(pTHX_ CV* cv PERL_UNUSED_DECL)
 >   #  else
 >   #    define XS(name) void name(pTHX_ CV* cv)
 >   #  endif
 
 Thanks for the information.  I've attached two patches one to perl.h
 and the second to XSUB.h which I will send back to the Perl authors
 if you can verify that they fix the problem you are describing with
 C++ Perl modules.
 
 	Thanks,
 
 	-- Johnny Lam <jlam@pkgsrc.org>
 
 --Qxx1br4bt0+wmkIi
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=patch-aq
 
 $NetBSD$
 
 --- XSUB.h.orig	2006-01-02 09:45:29.000000000 -0500
 +++ XSUB.h
 @@ -85,17 +85,16 @@ handled automatically by C<xsubpp>.
  #ifndef PERL_UNUSED_VAR
  #  define PERL_UNUSED_VAR(x) ((void)x)
  #endif
 +#ifndef PERL_UNUSED_DECL
 +#  define PERL_UNUSED_DECL
 +#endif
  
  #define ST(off) PL_stack_base[ax + (off)]
  
  #if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
  #  define XS(name) __declspec(dllexport) void name(pTHX_ CV* cv)
  #else
 -#  ifdef HASATTRIBUTE_UNUSED
 -#    define XS(name) void name(pTHX_ CV* cv __attribute__unused__)
 -#  else
 -#    define XS(name) void name(pTHX_ CV* cv)
 -#  endif
 +#  define XS(name) void name(pTHX_ CV* cv PERL_UNUSED_DECL)
  #endif
  
  #define dAX const I32 ax = MARK - PL_stack_base + 1
 
 --Qxx1br4bt0+wmkIi
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=patch-ar
 
 $NetBSD$
 
 --- perl.h.orig	2006-01-13 13:17:12.000000000 -0500
 +++ perl.h
 @@ -150,6 +150,15 @@ struct perl_thread;
  #  define CALLPROTECT CALL_FPTR(PL_protect)
  #endif
  
 +/* GCC versions prior to 3.4 have a bug handling the "unused" attribute
 + * in declarations when compiling C++ code.
 + */
 +#if defined(__GNUC__) && defined(__cplusplus)
 +#  if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
 +#    define PERL_UNUSED_DECL
 +#  endif
 +#endif
 +
  #if defined(SYMBIAN) && defined(__GNUC__)
  #  ifdef __cplusplus
  #    define PERL_UNUSED_DECL
 @@ -2375,7 +2384,11 @@ typedef struct clone_params CLONE_PARAMS
  #    define HASATTRIBUTE_PURE
  #  endif
  #  if __GNUC__ >= 3 /* gcc 3.0 -> */ /* XXX Verify this version */
 -#    define HASATTRIBUTE_UNUSED
 +#    if (__GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3) /* 3.4 -> */
 +#      define HASATTRIBUTE_UNUSED
 +#    elif !defined(__cplusplus)
 +#      define HASATTRIBUTE_UNUSED
 +#    endif
  #  endif
  #  if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3 /* 3.4 -> */
  #    define HASATTRIBUTE_WARN_UNUSED_RESULT
 
 --Qxx1br4bt0+wmkIi--