This one is tricky.  The bison skeleton code uses malloc(3) and
free(3), and tries to make sure a prototype for those functions is in
scope.  It attempts to detect if <stdlib.h> has been included, and if
not, provides its own prototypes.  The detection code checks if
_STDLIB_H has been defined.  However, the BSD stdlib.h uses _STDLIB_H_
(note the trailing underscore).  So the check fails and a typically
redundant prototype will be provided.  Usually this only produces a
compiler warning.  However...

The multimedia/libaacs port has a

  #pragma GCC visibility push(hidden)

in its parser code.  Since the malloc and free prototypes appear after
that pragma, it means they get marked as hidden symbols.  This makes
the compiler generate R_X86_64_PC32 relocations that binutils 2.17
doesn't like.

Here is a simple fix that simply replaces _STDLIB_H with _STDLIB_H_ in
the skeleton code.  Newer bison versions take a slightly different
approach and check whether EXIT_SUCCESS has been defined.

ok?


Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/bison/Makefile,v
retrieving revision 1.50
diff -u -p -r1.50 Makefile
--- Makefile    9 Nov 2013 23:19:02 -0000       1.50
+++ Makefile    16 May 2015 15:19:43 -0000
@@ -3,7 +3,7 @@
 COMMENT=       GNU parser generator
 
 DISTNAME=      bison-2.3
-REVISION=      1
+REVISION=      2
 CATEGORIES=    devel
 MASTER_SITES=  ${MASTER_SITE_GNU:=bison/}
 
Index: patches/patch-data_yacc_c
===================================================================
RCS file: patches/patch-data_yacc_c
diff -N patches/patch-data_yacc_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-data_yacc_c   16 May 2015 15:19:43 -0000
@@ -0,0 +1,46 @@
+$OpenBSD$
+--- data/yacc.c.orig   Sat May 27 02:28:17 2006
++++ data/yacc.c        Sat May 16 16:57:28 2015
+@@ -307,10 +307,10 @@ typedef short int yytype_int16;
+ #    define alloca _alloca
+ #   else
+ #    define YYSTACK_ALLOC alloca
+-#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && ]b4_c_modern[
++#    if ! defined _ALLOCA_H && ! defined _STDLIB_H_ && ]b4_c_modern[
+ #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+-#     ifndef _STDLIB_H
+-#      define _STDLIB_H 1
++#     ifndef _STDLIB_H_
++#      define _STDLIB_H_ 1
+ #     endif
+ #    endif
+ #   endif
+@@ -333,23 +333,23 @@ typedef short int yytype_int16;
+ #  ifndef YYSTACK_ALLOC_MAXIMUM
+ #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+ #  endif
+-#  if (defined __cplusplus && ! defined _STDLIB_H \
++#  if (defined __cplusplus && ! defined _STDLIB_H_ \
+        && ! ((defined YYMALLOC || defined malloc) \
+            && (defined YYFREE || defined free)))
+ #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+-#   ifndef _STDLIB_H
+-#    define _STDLIB_H 1
++#   ifndef _STDLIB_H_
++#    define _STDLIB_H_ 1
+ #   endif
+ #  endif
+ #  ifndef YYMALLOC
+ #   define YYMALLOC malloc
+-#   if ! defined malloc && ! defined _STDLIB_H && ]b4_c_modern[
++#   if ! defined malloc && ! defined _STDLIB_H_ && ]b4_c_modern[
+ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+ #   endif
+ #  endif
+ #  ifndef YYFREE
+ #   define YYFREE free
+-#   if ! defined free && ! defined _STDLIB_H && ]b4_c_modern[
++#   if ! defined free && ! defined _STDLIB_H_ && ]b4_c_modern[
+ void free (void *); /* INFRINGES ON USER NAME SPACE */
+ #   endif
+ #  endif

Reply via email to