• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GCC with patches for Dreamcast


Commit MetaInfo

Revision1236906ecbbfd3c335b50ff6b6d30b3afaedf6d3 (tree)
Time2021-09-30 15:58:37
AuthorJakub Jelinek <jakub@redh...>
Commiteralaskanemily

Log Message

intl: Allow building both with old bison and bison >= 3 [PR92008]

bison 3 apparently made a backwards incompatible change, dropped
YYLEX_PARAM/YYPARSE_PARAM support and instead needs %param or %lex-param
and %parse-param. Furthermore, there is no easy way to conditionalize
on bison version in the *.y files.
While e.g. glibc bumped bison requirement and just has the bison 3
compatible version, Richi said there are still systems with older bison
where we want to build gcc.

So, this patch instead determines during configure bison version, and
depending on that when building plural.c (if building it at all) tweaks
what is passed over to bison if needed.

Tested with both bison 3 and bison 1.35, in each case with reconfiguring
intl and building with make all-yes (as in my setup intl isn't normally
used).

2020-04-16 Jakub Jelinek <jakub@redhat.com>

PR bootstrap/92008
* configure.ac: Add check for bison >= 3, AC_DEFINE HAVE_BISON3
and AC_SUBST BISON3_YES and BISON3_NO.
* Makefile.in (.y.c): Prefix $(YACC) invocation with @BISON3_NO@,
add @BISON3_YES@ prefixed rule to adjust the *.y source using sed
and adjust output afterwards.
* plural-exp.h (PLURAL_PARSE): If HAVE_BISON3 is defined, use
struct parse_args * type for arg instead of void *.
* plural.y: Add magic /* BISON3 ... */ comments with bison >= 3
directives.
(YYLEX_PARAM, YYPARSE_PARAM): Don't define if HAVE_BISON3 is defined.
(yylex, yyerror): Adjust prototypes and definitions if HAVE_BISON3
is defined.
* plural.c: Regenerated.
* config.h.in: Regenerated.
* configure: Regenerated.

Change Summary

Incremental Difference

--- a/intl/ChangeLog
+++ b/intl/ChangeLog
@@ -1,4 +1,27 @@
1+<<<<<<< HEAD
12 2021-05-14 Release Manager
3+=======
4+2020-04-16 Jakub Jelinek <jakub@redhat.com>
5+
6+ PR bootstrap/92008
7+ * configure.ac: Add check for bison >= 3, AC_DEFINE HAVE_BISON3
8+ and AC_SUBST BISON3_YES and BISON3_NO.
9+ * Makefile.in (.y.c): Prefix $(YACC) invocation with @BISON3_NO@,
10+ add @BISON3_YES@ prefixed rule to adjust the *.y source using sed
11+ and adjust output afterwards.
12+ * plural-exp.h (PLURAL_PARSE): If HAVE_BISON3 is defined, use
13+ struct parse_args * type for arg instead of void *.
14+ * plural.y: Add magic /* BISON3 ... */ comments with bison >= 3
15+ directives.
16+ (YYLEX_PARAM, YYPARSE_PARAM): Don't define if HAVE_BISON3 is defined.
17+ (yylex, yyerror): Adjust prototypes and definitions if HAVE_BISON3
18+ is defined.
19+ * plural.c: Regenerated.
20+ * config.h.in: Regenerated.
21+ * configure: Regenerated.
22+
23+2020-02-01 Andrew Burgess <andrew.burgess@embecosm.com>
24+>>>>>>> 2ca17e0a89f (intl: Allow building both with old bison and bison >= 3 [PR92008])
225
326 * GCC 8.5.0 released.
427
--- a/intl/Makefile.in
+++ b/intl/Makefile.in
@@ -133,7 +133,11 @@ libintl.h: $(srcdir)/libgnuintl.h
133133 $(COMPILE) $<
134134
135135 .y.c:
136- $(YACC) $(YFLAGS) --output $@ $<
136+@BISON3_YES@ sed 's,%pure_parser,,;s,^/\* BISON3 \(.*\) \*/$$,\1,' $< > $@.y
137+@BISON3_YES@ $(YACC) $(YFLAGS) --output $@.c $@.y
138+@BISON3_YES@ sed 's/\.c\.y"/.y"/' $@.c > $@
139+@BISON3_YES@ rm -f $@.c $@.y $@.h
140+@BISON3_NO@ $(YACC) $(YFLAGS) --output $@ $<
137141 rm -f $*.h
138142
139143 INCLUDES = -I. -I$(srcdir)
--- a/intl/config.h.in
+++ b/intl/config.h.in
@@ -28,6 +28,9 @@
2828 /* Define to 1 if you have the <argz.h> header file. */
2929 #undef HAVE_ARGZ_H
3030
31+/* Define if bison 3 or later is used. */
32+#undef HAVE_BISON3
33+
3134 /* Define if the GNU dcgettext() function is already present or preinstalled.
3235 */
3336 #undef HAVE_DCGETTEXT
--- a/intl/configure
+++ b/intl/configure
@@ -591,6 +591,8 @@ ac_includes_default="\
591591 ac_subst_vars='LTLIBOBJS
592592 LIBOBJS
593593 PICFLAG
594+BISON3_NO
595+BISON3_YES
594596 INCINTL
595597 LIBINTL_DEP
596598 MAINT
@@ -6620,13 +6622,35 @@ case $USE_INCLUDED_LIBINTL in
66206622 ;;
66216623 esac
66226624
6623-# Check whether --enable-host-shared was given.
66246625 if test "${enable_host_shared+set}" = set; then :
66256626 enableval=$enable_host_shared; PICFLAG=-fPIC
66266627 else
66276628 PICFLAG=
66286629 fi
66296630
6631+BISON3_YES='#'
6632+BISON3_NO=
6633+if test "$INTLBISON" != :; then
6634+ ac_bison3=no
6635+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking bison 3 or later" >&5
6636+$as_echo_n "checking bison 3 or later... " >&6; }
6637+ ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
6638+ case $ac_prog_version in
6639+ [3-9].*)
6640+ ac_prog_version="$ac_prog_version, bison3"; ac_bison3=yes;;
6641+ *) ac_prog_version="$ac_prog_version, old";;
6642+ esac
6643+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5
6644+$as_echo "$ac_prog_version" >&6; }
6645+ if test $ac_bison3 = yes; then
6646+
6647+$as_echo "#define HAVE_BISON3 1" >>confdefs.h
6648+
6649+ BISON3_YES=
6650+ BISON3_NO='#'
6651+ fi
6652+fi
6653+
66306654
66316655
66326656 ac_config_files="$ac_config_files Makefile config.intl"
--- a/intl/configure.ac
+++ b/intl/configure.ac
@@ -53,5 +53,28 @@ AC_ARG_ENABLE(host-shared,
5353 [PICFLAG=-fPIC], [PICFLAG=])
5454 AC_SUBST(PICFLAG)
5555
56+BISON3_YES='#'
57+BISON3_NO=
58+if test "$INTLBISON" != :; then
59+ ac_bison3=no
60+ AC_MSG_CHECKING([bison 3 or later])
61+changequote(<<,>>)dnl
62+ ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
63+ case $ac_prog_version in
64+ [3-9].*)
65+changequote([,])dnl
66+ ac_prog_version="$ac_prog_version, bison3"; ac_bison3=yes;;
67+ *) ac_prog_version="$ac_prog_version, old";;
68+ esac
69+ AC_MSG_RESULT([$ac_prog_version])
70+ if test $ac_bison3 = yes; then
71+ AC_DEFINE(HAVE_BISON3, 1, [Define if bison 3 or later is used.])
72+ BISON3_YES=
73+ BISON3_NO='#'
74+ fi
75+fi
76+AC_SUBST(BISON3_YES)
77+AC_SUBST(BISON3_NO)
78+
5679 AC_CONFIG_FILES(Makefile config.intl)
5780 AC_OUTPUT
--- a/intl/plural-exp.h
+++ b/intl/plural-exp.h
@@ -1,5 +1,5 @@
11 /* Expression parsing and evaluation for plural form selection.
2- Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
2+ Copyright (C) 2000-2020 Free Software Foundation, Inc.
33 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
44
55 This program is free software; you can redistribute it and/or modify it
@@ -111,7 +111,11 @@ struct parse_args
111111
112112 extern void FREE_EXPRESSION PARAMS ((struct expression *exp))
113113 internal_function;
114+#ifdef HAVE_BISON3
115+extern int PLURAL_PARSE PARAMS ((struct parse_args *arg));
116+#else
114117 extern int PLURAL_PARSE PARAMS ((void *arg));
118+#endif
115119 extern struct expression GERMANIC_PLURAL attribute_hidden;
116120 extern void EXTRACT_PLURAL_EXPRESSION PARAMS ((const char *nullentry,
117121 struct expression **pluralp,
--- a/intl/plural.c
+++ b/intl/plural.c
@@ -19,7 +19,7 @@
1919 #line 1 "plural.y"
2020
2121 /* Expression parsing for plural form selection.
22- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
22+ Copyright (C) 2000-2020 Free Software Foundation, Inc.
2323 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
2424
2525 This program is free software; you can redistribute it and/or modify it
@@ -59,10 +59,12 @@
5959 # define __gettextparse PLURAL_PARSE
6060 #endif
6161
62+#ifndef HAVE_BISON3
6263 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
6364 #define YYPARSE_PARAM arg
65+#endif
6466
65-#line 49 "plural.y"
67+#line 54 "plural.y"
6668 #ifndef YYSTYPE
6769 typedef union {
6870 unsigned long int num;
@@ -72,7 +74,7 @@ typedef union {
7274 # define YYSTYPE yystype
7375 # define YYSTYPE_IS_TRIVIAL 1
7476 #endif
75-#line 55 "plural.y"
77+#line 60 "plural.y"
7678
7779 /* Prototypes for local functions. */
7880 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
@@ -87,8 +89,13 @@ static inline struct expression *new_exp_3 PARAMS ((enum operator op,
8789 struct expression *bexp,
8890 struct expression *tbranch,
8991 struct expression *fbranch));
92+#ifdef HAVE_BISON3
93+static int yylex PARAMS ((YYSTYPE *lval, struct parse_args *arg));
94+static void yyerror PARAMS ((struct parse_args *arg, const char *str));
95+#else
9096 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
9197 static void yyerror PARAMS ((const char *str));
98+#endif
9299
93100 /* Allocation of expressions. */
94101
@@ -236,8 +243,8 @@ static const short yyrhs[] =
236243 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
237244 static const short yyrline[] =
238245 {
239- 0, 174, 182, 186, 190, 194, 198, 202, 206, 210,
240- 214, 218, 223
246+ 0, 184, 192, 196, 200, 204, 208, 212, 216, 220,
247+ 224, 228, 233
241248 };
242249 #endif
243250
@@ -339,8 +346,8 @@ static const short yycheck[] =
339346
340347 You should have received a copy of the GNU General Public License
341348 along with this program; if not, write to the Free Software
342- Foundation, Inc., 51 Franklin Street - Fifth Floor,
343- Boston, MA 02110-1301, USA. */
349+ Foundation, Inc., 59 Temple Place - Suite 330,
350+ Boston, MA 02111-1307, USA. */
344351
345352 /* As a special exception, when this file is copied by Bison into a
346353 Bison output file, you may use that output file without restriction.
@@ -1027,7 +1034,7 @@ yyreduce:
10271034 switch (yyn) {
10281035
10291036 case 1:
1030-#line 175 "plural.y"
1037+#line 185 "plural.y"
10311038 {
10321039 if (yyvsp[0].exp == NULL)
10331040 YYABORT;
@@ -1035,68 +1042,68 @@ case 1:
10351042 }
10361043 break;
10371044 case 2:
1038-#line 183 "plural.y"
1045+#line 193 "plural.y"
10391046 {
10401047 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
10411048 }
10421049 break;
10431050 case 3:
1044-#line 187 "plural.y"
1051+#line 197 "plural.y"
10451052 {
10461053 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
10471054 }
10481055 break;
10491056 case 4:
1050-#line 191 "plural.y"
1057+#line 201 "plural.y"
10511058 {
10521059 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
10531060 }
10541061 break;
10551062 case 5:
1056-#line 195 "plural.y"
1063+#line 205 "plural.y"
10571064 {
10581065 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
10591066 }
10601067 break;
10611068 case 6:
1062-#line 199 "plural.y"
1069+#line 209 "plural.y"
10631070 {
10641071 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
10651072 }
10661073 break;
10671074 case 7:
1068-#line 203 "plural.y"
1075+#line 213 "plural.y"
10691076 {
10701077 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
10711078 }
10721079 break;
10731080 case 8:
1074-#line 207 "plural.y"
1081+#line 217 "plural.y"
10751082 {
10761083 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
10771084 }
10781085 break;
10791086 case 9:
1080-#line 211 "plural.y"
1087+#line 221 "plural.y"
10811088 {
10821089 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
10831090 }
10841091 break;
10851092 case 10:
1086-#line 215 "plural.y"
1093+#line 225 "plural.y"
10871094 {
10881095 yyval.exp = new_exp_0 (var);
10891096 }
10901097 break;
10911098 case 11:
1092-#line 219 "plural.y"
1099+#line 229 "plural.y"
10931100 {
10941101 if ((yyval.exp = new_exp_0 (num)) != NULL)
10951102 yyval.exp->val.num = yyvsp[0].num;
10961103 }
10971104 break;
10981105 case 12:
1099-#line 224 "plural.y"
1106+#line 234 "plural.y"
11001107 {
11011108 yyval.exp = yyvsp[-1].exp;
11021109 }
@@ -1334,7 +1341,7 @@ yyreturn:
13341341 #endif
13351342 return yyresult;
13361343 }
1337-#line 229 "plural.y"
1344+#line 239 "plural.y"
13381345
13391346
13401347 void
@@ -1365,11 +1372,20 @@ FREE_EXPRESSION (exp)
13651372 }
13661373
13671374
1375+#ifdef HAVE_BISON3
1376+static int
1377+yylex (lval, arg)
1378+ YYSTYPE *lval;
1379+ struct parse_args *arg;
1380+{
1381+ const char **pexp = &arg->cp;
1382+#else
13681383 static int
13691384 yylex (lval, pexp)
13701385 YYSTYPE *lval;
13711386 const char **pexp;
13721387 {
1388+#endif
13731389 const char *exp = *pexp;
13741390 int result;
13751391
@@ -1510,8 +1526,14 @@ yylex (lval, pexp)
15101526 }
15111527
15121528
1529+#ifdef HAVE_BISON3
1530+static void
1531+yyerror (arg, str)
1532+ struct parse_args *arg;
1533+#else
15131534 static void
15141535 yyerror (str)
1536+#endif
15151537 const char *str;
15161538 {
15171539 /* Do nothing. We don't print error messages here. */
--- a/intl/plural.y
+++ b/intl/plural.y
@@ -1,6 +1,6 @@
11 %{
22 /* Expression parsing for plural form selection.
3- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
3+ Copyright (C) 2000-2020 Free Software Foundation, Inc.
44 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
55
66 This program is free software; you can redistribute it and/or modify it
@@ -40,10 +40,15 @@
4040 # define __gettextparse PLURAL_PARSE
4141 #endif
4242
43+#ifndef HAVE_BISON3
4344 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
4445 #define YYPARSE_PARAM arg
46+#endif
4547 %}
4648 %pure_parser
49+/* BISON3 %parse-param {struct parse_args *arg} */
50+/* BISON3 %lex-param {struct parse_args *arg} */
51+/* BISON3 %define api.pure full */
4752 %expect 7
4853
4954 %union {
@@ -66,8 +71,13 @@ static inline struct expression *new_exp_3 PARAMS ((enum operator op,
6671 struct expression *bexp,
6772 struct expression *tbranch,
6873 struct expression *fbranch));
74+#ifdef HAVE_BISON3
75+static int yylex PARAMS ((YYSTYPE *lval, struct parse_args *arg));
76+static void yyerror PARAMS ((struct parse_args *arg, const char *str));
77+#else
6978 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
7079 static void yyerror PARAMS ((const char *str));
80+#endif
7181
7282 /* Allocation of expressions. */
7383
@@ -256,11 +266,20 @@ FREE_EXPRESSION (exp)
256266 }
257267
258268
269+#ifdef HAVE_BISON3
270+static int
271+yylex (lval, arg)
272+ YYSTYPE *lval;
273+ struct parse_args *arg;
274+{
275+ const char **pexp = &arg->cp;
276+#else
259277 static int
260278 yylex (lval, pexp)
261279 YYSTYPE *lval;
262280 const char **pexp;
263281 {
282+#endif
264283 const char *exp = *pexp;
265284 int result;
266285
@@ -401,8 +420,14 @@ yylex (lval, pexp)
401420 }
402421
403422
423+#ifdef HAVE_BISON3
424+static void
425+yyerror (arg, str)
426+ struct parse_args *arg;
427+#else
404428 static void
405429 yyerror (str)
430+#endif
406431 const char *str;
407432 {
408433 /* Do nothing. We don't print error messages here. */