ostreedev / ostree

Operating system and container binary deployment and upgrades
https://ostreedev.github.io/ostree/
Other
1.26k stars 291 forks source link

Build fails with bison 3.8 #2439

Open phmccarty opened 3 years ago

phmccarty commented 3 years ago

These are the errors I am seeing:

src/ostree/parse-datetime.c:481:6: error: conflicting types for ‘yyerror’; have ‘void(parser_control *, const char *)’
  481 | void yyerror (parser_control *pc, const char *msg);
      |      ^~~~~~~
src/ostree/parse-datetime.y:231:12: note: previous declaration of ‘yyerror’ with type ‘int(const parser_control *, const char *)’
  231 | static int yyerror (parser_control const *, char const *);
      |            ^~~~~~~
src/ostree/parse-datetime.y:1212:1: error: conflicting types for ‘yyerror’; have ‘int(const parser_control *, const char *)’
 1212 | yyerror (parser_control const *pc,
      | ^~~~~~~
src/ostree/parse-datetime.c:481:6: note: previous declaration of ‘yyerror’ with type ‘void(parser_control *, const char *)’
  481 | void yyerror (parser_control *pc, const char *msg);
      |      ^~~~~~~
src/ostree/parse-datetime.y:1212:1: warning: ‘yyerror’ defined but not used [-Wunused-function]
 1212 | yyerror (parser_control const *pc,
      | ^~~~~~~

From the bison 3.8 release notes:

  To comply with the latest POSIX standard, in Yacc compatibility mode
  (options `-y`/`--yacc`) Bison now generates prototypes for yyerror and
  yylex.  In some situations, this is breaking compatibility: if the user
  has already declared these functions but with some differences (e.g., to
  declare them as static, or to use specific attributes), the generated
  parser will fail to compile.  To disable these prototypes, #define yyerror
  (to `yyerror`), and likewise for yylex.
dbnicholson commented 3 years ago

Thanks, bison. I think we should take this opportunity to switch away from yacc mode and go with pure bison like flatpak did to kill some warnings. I doubt anyone is using anything except bison.

phmccarty commented 3 years ago

Seems to be fixed with bison 3.8.1. I guess the compatibility break was not intended:

* Noteworthy changes in release 3.8.1 (2021-09-11) [stable]

  The generation of prototypes for yylex and yyerror in Yacc mode is
  breaking existing grammar files.  To avoid breaking too many grammars, the
  prototypes are now generated when `-y/--yacc` is used *and* the
  `POSIXLY_CORRECT` environment variable is defined.

  Avoid using `-y`/`--yacc` simply to comply with Yacc's file name
  conventions, rather, use `-o y.tab.c`.  Autoconf's AC_PROG_YACC macro uses
  `-y`.  Avoid it if possible, for instance by using gnulib's gl_PROG_BISON.