> From: j...@wxcvbn.org (=?utf-8?Q?J=C3=A9r=C3=A9mie_Courr=C3=A8ges-Anglas?=) > Date: Mon, 18 May 2015 13:26:08 +0200 > > Mark Kettenis <mark.kette...@xs4all.nl> writes: > > > 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. > > Maybe I'm nitpicking here, but that would mean that parsers generated by > the OpenBSD bison package may now misbehave on systems where _STDLIB_H > is provided. I know that our bison package is old, people should > probably not use it, but maybe there's another way to deal with this? > > I think that this #ifdef _STDLIB_H maze would be enough with the > following tweak. I see no reason for C++ to be a special case here. > The resulting libaacs parser *still depends on stdlib.h being included > earlier in the .y*, but at least the _STDLIB_H guards are working and > prevent the local decls. > > Thoughts?
My guess is that it was done this way for a reason. If you really think that redistributing OpenBSD generated parsers to non-BSD systems is something that needs to be addressed, I'd rather take the EXIT_SUCCESS approach. > 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 18 May 2015 11:02:39 -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 18 May 2015 11:02:39 -0000 > @@ -0,0 +1,12 @@ > +$OpenBSD$ > +--- data/yacc.c.orig Mon May 18 12:04:31 2015 > ++++ data/yacc.c Mon May 18 13:01:54 2015 > +@@ -333,7 +333,7 @@ typedef short int yytype_int16; > + # ifndef YYSTACK_ALLOC_MAXIMUM > + # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM > + # endif > +-# if (defined __cplusplus && ! defined _STDLIB_H \ > ++# if (! defined _STDLIB_H \ > + && ! ((defined YYMALLOC || defined malloc) \ > + && (defined YYFREE || defined free))) > + # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */