GCC with patches for Dreamcast
Revision | 307707f02e7df822ffccb03bc17bf7a62cfbd0b7 (tree) |
---|---|
Time | 2021-09-30 15:59:47 |
Author | Jakub Jelinek <jakub@redh...> |
Commiter | alaskanemily |
intl: Unbreak intl build with bison 3 when no regeneration is needed [PR92008]
As Iain reported, my change broke the case when one has bison >= 3,
but make decides there is no reason to regenerate plural.c, unfortunately
that seems to be a scenario I haven't tested. The problem is that
the pregenerated plural.c has been generated with bison 1.35, but when
config.h says HAVE_BISON3, the code assumes it is the bison3 variant.
What used to work fine is when one has bison >= 3 and plural.c has been
regenerated (e.g. do touch intl/plural.y and it will work), or when
one doesn't have any bison (then nothing is regenerated, but HAVE_BISON3
isn't defined either), or when one has bison < 3 and doesn't need to
regenerate, or when one has bison < 3 and it is regenerated.
The following patch fixes this, by killing the HAVE_BISON3 macro from
config.h, and instead remembering the fact whether plural.c has been created
with bison < 3 or bison >= 3 in a separate new plural-config.h header.
The way this works:
- user doesn't have bison
- user has bison >= 3, but intl/{plural-config.h,plural.c} aren't older than intl/plural.y
- user has bison < 3, but intl/{plural-config.h,plural.c} aren't older than intl/plural.y
pregenerated !USE_BISON3 plural.c and plural-config.h from source
dir is used, nothing in the objdir
- user has bison >= 3 and intl/plural.y is newer
Makefile generates plural.c and USE_BISON3 plural-config.h in the
objdir, which is then used in preference to srcdir copies
- user has bison < 3 and intl/plural.y is newer
Makefile generates plural.c and !USE_BISON3 plural-config.h in the
objdir, which is then used in preference to srcdir copies
I have tested all these cases and make all-yes worked in all the cases.
If one uses the unsupported ./configure where srcdir == objdir, I guess
(though haven't tested) that it should still work, just it would be nice
if such people didn't try to check in the plural{.c,-config.h} they have
regenerated.
What doesn't work, but didn't work before either (just tested gcc-9 branch
too) is when one doesn't have bison and plural.y is newer than plural.c.
Don't do that ;)
2020-04-16 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/92008
intl/
* configure.ac: Remove HAVE_BISON3 AC_DEFINE.
* Makefile.in (HEADERS): Add plural-config.h.
(.y.c): Also create plural-config.h.
(dcigettext.o loadmsgcat.o plural.o plural-exp.o): Also depend
on plural-config.h.
(plural-config.h): Depend on plural.c.
* plural-exp.h: Include plural-config.h. Use USE_BISON3 instead
of HAVE_BISON3.
* plural.y: Use USE_BISON3 instead of HAVE_BISON3.
* configure: Regenerated.
* plural.c: Regenerated.
* config.h.in: Regenerated.
* plural-config.h: Generated.
contrib/
* gcc_update: Add intl/plural.y dependency for intl/plural-config.h.
@@ -72,6 +72,7 @@ fixincludes/configure: fixincludes/configure.ac fixincludes/aclocal.m4 | ||
72 | 72 | fixincludes/config.h.in: fixincludes/configure.ac fixincludes/aclocal.m4 |
73 | 73 | # intl library |
74 | 74 | intl/plural.c: intl/plural.y |
75 | +intl/plural-config.h: intl/plural.y | |
75 | 76 | intl/configure: intl/configure.ac intl/aclocal.m4 |
76 | 77 | intl/config.h.in: intl/configure.ac intl/aclocal.m4 |
77 | 78 | # Now, proceed to gcc automatically generated files |
@@ -4,6 +4,21 @@ | ||
4 | 4 | 2020-04-16 Jakub Jelinek <jakub@redhat.com> |
5 | 5 | |
6 | 6 | PR bootstrap/92008 |
7 | + * configure.ac: Remove HAVE_BISON3 AC_DEFINE. | |
8 | + * Makefile.in (HEADERS): Add plural-config.h. | |
9 | + (.y.c): Also create plural-config.h. | |
10 | + (dcigettext.o loadmsgcat.o plural.o plural-exp.o): Also depend | |
11 | + on plural-config.h. | |
12 | + (plural-config.h): Depend on plural.c. | |
13 | + * plural-exp.h: Include plural-config.h. Use USE_BISON3 instead | |
14 | + of HAVE_BISON3. | |
15 | + * plural.y: Use USE_BISON3 instead of HAVE_BISON3. | |
16 | + * configure: Regenerated. | |
17 | + * plural.c: Regenerated. | |
18 | + * config.h.in: Regenerated. | |
19 | + * plural-config.h: Generated. | |
20 | + | |
21 | + PR bootstrap/92008 | |
7 | 22 | * configure.ac: Add check for bison >= 3, AC_DEFINE HAVE_BISON3 |
8 | 23 | and AC_SUBST BISON3_YES and BISON3_NO. |
9 | 24 | * Makefile.in (.y.c): Prefix $(YACC) invocation with @BISON3_NO@, |
@@ -57,6 +57,7 @@ HEADERS = \ | ||
57 | 57 | gettextP.h \ |
58 | 58 | hash-string.h \ |
59 | 59 | loadinfo.h \ |
60 | + plural-config.h \ | |
60 | 61 | plural-exp.h \ |
61 | 62 | eval-plural.h \ |
62 | 63 | localcharset.h \ |
@@ -133,10 +134,12 @@ libintl.h: $(srcdir)/libgnuintl.h | ||
133 | 134 | $(COMPILE) $< |
134 | 135 | |
135 | 136 | .y.c: |
137 | +@BISON3_YES@ echo '#define USE_BISON3' > $(patsubst %.c,%-config.h,$@) | |
136 | 138 | @BISON3_YES@ sed 's,%pure_parser,,;s,^/\* BISON3 \(.*\) \*/$$,\1,' $< > $@.y |
137 | 139 | @BISON3_YES@ $(YACC) $(YFLAGS) --output $@.c $@.y |
138 | 140 | @BISON3_YES@ sed 's/\.c\.y"/.y"/' $@.c > $@ |
139 | 141 | @BISON3_YES@ rm -f $@.c $@.y $@.h |
142 | +@BISON3_NO@ echo '/* #define USE_BISON3 */' > $(patsubst %.c,%-config.h,$@) | |
140 | 143 | @BISON3_NO@ $(YACC) $(YFLAGS) --output $@ $< |
141 | 144 | rm -f $*.h |
142 | 145 |
@@ -165,7 +168,7 @@ dngettext.o finddomain.o gettext.o intl-compat.o loadmsgcat.o \ | ||
165 | 168 | localealias.o ngettext.o textdomain.o: gettextP.h gmo.h loadinfo.h |
166 | 169 | dcigettext.o loadmsgcat.o: hash-string.h |
167 | 170 | explodename.o l10nflist.o: loadinfo.h |
168 | -dcigettext.o loadmsgcat.o plural.o plural-exp.o: plural-exp.h | |
171 | +dcigettext.o loadmsgcat.o plural.o plural-exp.o: plural-exp.h plural-config.h | |
169 | 172 | dcigettext.o: eval-plural.h |
170 | 173 | localcharset.o: localcharset.h |
171 | 174 | localealias.o localcharset.o relocatable.o: relocatable.h |
@@ -242,6 +245,8 @@ $(srcdir)/aclocal.m4: @MAINT@ $(aclocal_deps) | ||
242 | 245 | config.h: stamp-h1 |
243 | 246 | test -f config.h || (rm -f stamp-h1 && $(MAKE) stamp-h1) |
244 | 247 | |
248 | +plural-config.h: plural.c | |
249 | + | |
245 | 250 | stamp-h1: $(srcdir)/config.h.in config.status |
246 | 251 | -rm -f stamp-h1 |
247 | 252 | $(SHELL) ./config.status config.h |
@@ -28,9 +28,6 @@ | ||
28 | 28 | /* Define to 1 if you have the <argz.h> header file. */ |
29 | 29 | #undef HAVE_ARGZ_H |
30 | 30 | |
31 | -/* Define if bison 3 or later is used. */ | |
32 | -#undef HAVE_BISON3 | |
33 | - | |
34 | 31 | /* Define if the GNU dcgettext() function is already present or preinstalled. |
35 | 32 | */ |
36 | 33 | #undef HAVE_DCGETTEXT |
@@ -6643,9 +6643,6 @@ $as_echo_n "checking bison 3 or later... " >&6; } | ||
6643 | 6643 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5 |
6644 | 6644 | $as_echo "$ac_prog_version" >&6; } |
6645 | 6645 | if test $ac_bison3 = yes; then |
6646 | - | |
6647 | -$as_echo "#define HAVE_BISON3 1" >>confdefs.h | |
6648 | - | |
6649 | 6646 | BISON3_YES= |
6650 | 6647 | BISON3_NO='#' |
6651 | 6648 | fi |
@@ -68,7 +68,6 @@ changequote([,])dnl | ||
68 | 68 | esac |
69 | 69 | AC_MSG_RESULT([$ac_prog_version]) |
70 | 70 | if test $ac_bison3 = yes; then |
71 | - AC_DEFINE(HAVE_BISON3, 1, [Define if bison 3 or later is used.]) | |
72 | 71 | BISON3_YES= |
73 | 72 | BISON3_NO='#' |
74 | 73 | fi |
@@ -0,0 +1 @@ | ||
1 | +/* #define USE_BISON3 */ |
@@ -20,6 +20,8 @@ | ||
20 | 20 | #ifndef _PLURAL_EXP_H |
21 | 21 | #define _PLURAL_EXP_H |
22 | 22 | |
23 | +#include <plural-config.h> | |
24 | + | |
23 | 25 | #ifndef PARAMS |
24 | 26 | # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES |
25 | 27 | # define PARAMS(args) args |
@@ -111,7 +113,7 @@ struct parse_args | ||
111 | 113 | |
112 | 114 | extern void FREE_EXPRESSION PARAMS ((struct expression *exp)) |
113 | 115 | internal_function; |
114 | -#ifdef HAVE_BISON3 | |
116 | +#ifdef USE_BISON3 | |
115 | 117 | extern int PLURAL_PARSE PARAMS ((struct parse_args *arg)); |
116 | 118 | #else |
117 | 119 | extern int PLURAL_PARSE PARAMS ((void *arg)); |
@@ -59,7 +59,7 @@ | ||
59 | 59 | # define __gettextparse PLURAL_PARSE |
60 | 60 | #endif |
61 | 61 | |
62 | -#ifndef HAVE_BISON3 | |
62 | +#ifndef USE_BISON3 | |
63 | 63 | #define YYLEX_PARAM &((struct parse_args *) arg)->cp |
64 | 64 | #define YYPARSE_PARAM arg |
65 | 65 | #endif |
@@ -89,7 +89,7 @@ static inline struct expression *new_exp_3 PARAMS ((enum operator op, | ||
89 | 89 | struct expression *bexp, |
90 | 90 | struct expression *tbranch, |
91 | 91 | struct expression *fbranch)); |
92 | -#ifdef HAVE_BISON3 | |
92 | +#ifdef USE_BISON3 | |
93 | 93 | static int yylex PARAMS ((YYSTYPE *lval, struct parse_args *arg)); |
94 | 94 | static void yyerror PARAMS ((struct parse_args *arg, const char *str)); |
95 | 95 | #else |
@@ -1372,7 +1372,7 @@ FREE_EXPRESSION (exp) | ||
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | |
1375 | -#ifdef HAVE_BISON3 | |
1375 | +#ifdef USE_BISON3 | |
1376 | 1376 | static int |
1377 | 1377 | yylex (lval, arg) |
1378 | 1378 | YYSTYPE *lval; |
@@ -1526,7 +1526,7 @@ yylex (lval, pexp) | ||
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | |
1529 | -#ifdef HAVE_BISON3 | |
1529 | +#ifdef USE_BISON3 | |
1530 | 1530 | static void |
1531 | 1531 | yyerror (arg, str) |
1532 | 1532 | struct parse_args *arg; |
@@ -40,7 +40,7 @@ | ||
40 | 40 | # define __gettextparse PLURAL_PARSE |
41 | 41 | #endif |
42 | 42 | |
43 | -#ifndef HAVE_BISON3 | |
43 | +#ifndef USE_BISON3 | |
44 | 44 | #define YYLEX_PARAM &((struct parse_args *) arg)->cp |
45 | 45 | #define YYPARSE_PARAM arg |
46 | 46 | #endif |
@@ -71,7 +71,7 @@ static inline struct expression *new_exp_3 PARAMS ((enum operator op, | ||
71 | 71 | struct expression *bexp, |
72 | 72 | struct expression *tbranch, |
73 | 73 | struct expression *fbranch)); |
74 | -#ifdef HAVE_BISON3 | |
74 | +#ifdef USE_BISON3 | |
75 | 75 | static int yylex PARAMS ((YYSTYPE *lval, struct parse_args *arg)); |
76 | 76 | static void yyerror PARAMS ((struct parse_args *arg, const char *str)); |
77 | 77 | #else |
@@ -266,7 +266,7 @@ FREE_EXPRESSION (exp) | ||
266 | 266 | } |
267 | 267 | |
268 | 268 | |
269 | -#ifdef HAVE_BISON3 | |
269 | +#ifdef USE_BISON3 | |
270 | 270 | static int |
271 | 271 | yylex (lval, arg) |
272 | 272 | YYSTYPE *lval; |
@@ -420,7 +420,7 @@ yylex (lval, pexp) | ||
420 | 420 | } |
421 | 421 | |
422 | 422 | |
423 | -#ifdef HAVE_BISON3 | |
423 | +#ifdef USE_BISON3 | |
424 | 424 | static void |
425 | 425 | yyerror (arg, str) |
426 | 426 | struct parse_args *arg; |