Kbuild: factor parser rules
Subsystems (3)
v2 cover Kbuild: factor parser rules
Hi,
[ Original RFC and motivation can be found at:
http://marc.info/?l=linux-kbuild&m=130456101131801&w=2 ]
I tried to re-think the order in this serie to address Michal comments.
Main changes since v1 are:
- include scripts/dtc/' parser in the scope of the patchset
- do not rename any parser source
- make lexer file name consistent, ie. name it %.lex.c, not lex.%.c
- rebase on top of v2.6.39
A few notes:
- the parser should not include the lexer; however, this has the advantage to avoid having to deals with the parser's header.
- the tuple ( "migrate parser to implicit rules", regen parser) should really be one commit, to enforce bisect'ability
Comments welcome!
- Arnaud
Arnaud Lacombe (13):
kbuild: add implicit rules for parser generation
genksyms: include the lexer from the parser
genksyms: pass hash and lookup functions name and target language
though the input file
genksyms: migrate parser to implicit rules
genksym: regen parser
kconfig: constify `kconf_id_lookup'
kconfig: back-out parser prefix, from zconf' to yy'
kconfig: kill no longer needed reference to YYDEBUG
kconfig: migrate parser to implicit rules
kconfig: regen parser
dtc: include the lexer from the parser
dtc: migrate parser to implicit rules
dtc: regen parser
scripts/Makefile.lib | 33 ++-
scripts/dtc/Makefile | 29 +--
scripts/dtc/dtc-lexer.l | 1 -
scripts/dtc/dtc-lexer.lex.c_shipped | 60 +---
scripts/dtc/dtc-parser.tab.c_shipped | 118 +----
scripts/dtc/dtc-parser.tab.h_shipped | 91 ----
scripts/dtc/dtc-parser.y | 2 +
scripts/genksyms/.gitignore | 6 +-
scripts/genksyms/Makefile | 48 +--
scripts/genksyms/keywords.gperf | 3 +
...{keywords.c_shipped => keywords.hash.c_shipped} | 96 ++--
scripts/genksyms/lex.l | 5 +-
.../genksyms/{lex.c_shipped => lex.lex.c_shipped} | 360 +--------------
scripts/genksyms/parse.h_shipped | 97 ----
.../{parse.c_shipped => parse.tab.c_shipped} | 200 +-------
scripts/genksyms/parse.y | 2 +
scripts/kconfig/.gitignore | 2 +-
scripts/kconfig/Makefile | 31 +--
scripts/kconfig/lkc.h | 4 +-
scripts/kconfig/zconf.gperf | 2 +-
scripts/kconfig/zconf.hash.c_shipped | 273 +++++++-----
scripts/kconfig/zconf.l | 20 +-
.../{lex.zconf.c_shipped => zconf.lex.c_shipped} | 493 +++++++++-----------
scripts/kconfig/zconf.tab.c_shipped | 102 ++---
scripts/kconfig/zconf.y | 44 +-
25 files changed, 614 insertions(+), 1508 deletions(-)
delete mode 100644 scripts/dtc/dtc-parser.tab.h_shipped
rename scripts/genksyms/{keywords.c_shipped => keywords.hash.c_shipped} (94%)
rename scripts/genksyms/{lex.c_shipped => lex.lex.c_shipped} (89%)
delete mode 100644 scripts/genksyms/parse.h_shipped
rename scripts/genksyms/{parse.c_shipped => parse.tab.c_shipped} (92%)
rename scripts/kconfig/{lex.zconf.c_shipped => zconf.lex.c_shipped} (81%)Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 1/13 kbuild: add implicit rules for parser generation
--- scripts/Makefile.lib | 33 ++++++++++++++++++++++++++++++++- 1 files changed, 32 insertions(+), 1 deletions(-)
scripts/Makefile.lib +32 -1
@@ -160,15 +160,46 @@ ld_flags = $(LDFLAGS) $(ldflags-y) modname-multi = $(sort $(foreach m,$(multi-used),\ $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) +ifdef REGENERATE_PARSERS +# GPERF +# --------------------------------------------------------------------------- +quiet_cmd_gperf = GPERF $@ + cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $< +$(src)/%.hash.c_shipped: $(src)/%.gperf + $(call cmd,gperf) + +# LEX +# --------------------------------------------------------------------------- +quiet_cmd_flex = LEX $@ + cmd_flex = flex -o$@ -L $< +$(src)/%.lex.c_shipped: $(src)/%.l + $(call cmd,flex) + +# YACC +# --------------------------------------------------------------------------- +quiet_cmd_bison = YACC $@ + cmd_bison = bison -o$@ -t -l $< +$(src)/%.tab.c_shipped: $(src)/%.y + $(call cmd,bison) +endif + # Shipped files # =========================================================================== quiet_cmd_shipped = SHIPPED $@ cmd_shipped = cat $< > $@ -$(obj)/%:: $(src)/%_shipped +$(obj)/%.tab.c: $(src)/%.tab.c_shipped + $(call cmd,shipped) + +$(obj)/%.lex.c: $(src)/%.lex.c_shipped $(call cmd,shipped) +$(obj)/%.hash.c: $(src)/%.hash.c_shipped + $(call cmd,shipped) + +$(obj)/%:: $(src)/%_shipped + # Commands useful for building a boot image # =========================================================================== #
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 2/13 genksyms: include the lexer from the parser
In reply to Arnaud Lacombe--- scripts/genksyms/lex.l | 3 --- scripts/genksyms/parse.y | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)
scripts/genksyms/lex.l +0 -3
@@ -28,9 +28,6 @@ #include <string.h> #include <ctype.h> -#include "genksyms.h" -#include "parse.h" - /* We've got a two-level lexer here. We let flex do basic tokenization and then we categorize those basic tokens in the second stage. */ #define YY_DECL static int yylex1(void)
scripts/genksyms/parse.y +2 -0
@@ -497,3 +497,5 @@ yyerror(const char *e) { error_with_pos("%s", e); } + +#include "lex.lex.c"
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 3/13 genksyms: pass hash and lookup functions name and target language though the input file
In reply to Arnaud LacombeRenaming hash and lookup functions on the command line would reduces its genericity. Use the .gperf file to pass this information. Do the same for the target language.
--- scripts/genksyms/keywords.gperf | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
scripts/genksyms/keywords.gperf +3 -0
@@ -1,3 +1,6 @@ +%language=ANSI-C +%define hash-function-name is_reserved_hash +%define lookup-function-name is_reserved_word %{ struct resword; static const struct resword *is_reserved_word(register const char *str, register unsigned int len);
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 4/13 genksyms: migrate parser to implicit rules
In reply to Arnaud Lacombe--- scripts/genksyms/.gitignore | 6 ++-- scripts/genksyms/Makefile | 48 ++---------------------------------------- scripts/genksyms/lex.l | 2 +- 3 files changed, 7 insertions(+), 49 deletions(-)
scripts/genksyms/.gitignore +3 -3
@@ -1,4 +1,4 @@ -keywords.c -lex.c -parse.[ch] +*.hash.c +*.lex.c +*.tab.c genksyms
scripts/genksyms/Makefile +3 -45
55 lines not on this page · raw message
scripts/genksyms/lex.l +1 -1
@@ -91,7 +91,7 @@ MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>) /* Bring in the keyword recognizer. */ -#include "keywords.c" +#include "keywords.hash.c" /* Macros to append to our phrase collection list. */
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 5/13 genksym: regen parser
In reply to Arnaud Lacombe---
...{keywords.c_shipped => keywords.hash.c_shipped} | 96 +++---
.../genksyms/{lex.c_shipped => lex.lex.c_shipped} | 360 +-------------------
scripts/genksyms/parse.h_shipped | 97 ------
.../{parse.c_shipped => parse.tab.c_shipped} | 200 +----------
4 files changed, 72 insertions(+), 681 deletions(-)
rename scripts/genksyms/{keywords.c_shipped => keywords.hash.c_shipped} (94%)
rename scripts/genksyms/{lex.c_shipped => lex.lex.c_shipped} (89%)
delete mode 100644 scripts/genksyms/parse.h_shipped
rename scripts/genksyms/{parse.c_shipped => parse.tab.c_shipped} (92%)scripts/genksyms/keywords.hash.c_shipped renamed from scripts/genksyms/keywords.c_shipped +48 -48
@@ -1,5 +1,5 @@ /* ANSI-C code produced by gperf version 3.0.4 */ -/* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf */ +/* Command-line: gperf -t --output-file scripts/genksyms/keywords.hash.c_shipped -a -C -E -g -k '1,3,$' -p -t scripts/genksyms/keywords.gperf */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -28,11 +28,11 @@ #error "gperf generated tables don't work with this execution character set. Please report a bug to <[email protected]>." #endif -#line 1 "scripts/genksyms/keywords.gperf" +#line 4 "scripts/genksyms/keywords.gperf" struct resword; static const struct resword *is_reserved_word(register const char *str, register unsigned int len); -#line 5 "scripts/genksyms/keywords.gperf" +#line 8 "scripts/genksyms/keywords.gperf" struct resword { const char *name; int token; }; /* maximum key range = 64, duplicates = 0 */
@@ -99,108 +99,108 @@ is_reserved_word (register const char *str, register unsigned int len) static const struct resword wordlist[] = { {""}, {""}, {""}, -#line 30 "scripts/genksyms/keywords.gperf" +#line 33 "scripts/genksyms/keywords.gperf" {"asm", ASM_KEYW}, {""}, -#line 12 "scripts/genksyms/keywords.gperf" +#line 15 "scripts/genksyms/keywords.gperf" {"__asm", ASM_KEYW}, {""}, -#line 13 "scripts/genksyms/keywords.gperf" +#line 16 "scripts/genksyms/keywords.gperf" {"__asm__", ASM_KEYW}, {""}, {""}, -#line 56 "scripts/genksyms/keywords.gperf" +#line 59 "scripts/genksyms/keywords.gperf" {"__typeof__", TYPEOF_KEYW}, {""}, -#line 16 "scripts/genksyms/keywords.gperf" +#line 19 "scripts/genksyms/keywords.gperf" {"__const", CONST_KEYW}, -#line 15 "scripts/genksyms/keywords.gperf" +#line 18 "scripts/genksyms/keywords.gperf" {"__attribute__", ATTRIBUTE_KEYW}, -#line 17 "scripts/genksyms/keywords.gperf" +#line 20 "scripts/genksyms/keywords.gperf" {"__const__", CONST_KEYW}, -#line 22 "scripts/genksyms/keywords.gperf" +#line 25 "scripts/genksyms/keywords.gperf" {"__signed__", SIGNED_KEYW}, -#line 48 "scripts/genksyms/keywords.gperf" +#line 51 "scripts/genksyms/keywords.gperf" {"static", STATIC_KEYW}, {""}, -#line 43 "scripts/genksyms/keywords.gperf" +#line 46 "scripts/genksyms/keywords.gperf" {"int", INT_KEYW}, -#line 36 "scripts/genksyms/keywords.gperf" +#line 39 "scripts/genksyms/keywords.gperf" {"char", CHAR_KEYW}, -#line 37 "scripts/genksyms/keywords.gperf" +#line 40 "scripts/genksyms/keywords.gperf" {"const", CONST_KEYW}, -#line 49 "scripts/genksyms/keywords.gperf" +#line 52 "scripts/genksyms/keywords.gperf" {"struct", STRUCT_KEYW}, -#line 28 "scripts/genksyms/keywords.gperf" +#line 31 "scripts/genksyms/keywords.gperf" {"__restrict__", RESTRICT_KEYW}, -#line 29 "scripts/genksyms/keywords.gperf" +#line 32 "scripts/genksyms/keywords.gperf" {"restrict", RESTRICT_KEYW}, -#line 9 "scripts/genksyms/keywords.gperf" +#line 12 "scripts/genksyms/keywords.gperf" {"EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW}, -#line 20 "scripts/genksyms/keywords.gperf" +#line 23 "scripts/genksyms/keywords.gperf" {"__inline__", INLINE_KEYW}, {""}, -#line 24 "scripts/genksyms/keywords.gperf" +#line 27 "scripts/genksyms/keywords.gperf" {"__volatile__", VOLATILE_KEYW}, -#line 7 "scripts/genksyms/keywords.gperf" +#line 10 "scripts/genksyms/keywords.gperf" {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW}, -#line 27 "scripts/genksyms/keywords.gperf" +#line 30 "scripts/genksyms/keywords.gperf" {"_restrict", RESTRICT_KEYW}, {""}, -#line 14 "scripts/genksyms/keywords.gperf" +#line 17 "scripts/genksyms/keywords.gperf" {"__attribute", ATTRIBUTE_KEYW}, -#line 8 "scripts/genksyms/keywords.gperf" +#line 11 "scripts/genksyms/keywords.gperf" {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, -#line 18 "scripts/genksyms/keywords.gperf" +#line 21 "scripts/genksyms/keywords.gperf" {"__extension__", EXTENSION_KEYW}, -#line 39 "scripts/genksyms/keywords.gperf" +#line 42 "scripts/genksyms/keywords.gperf" {"enum", ENUM_KEYW}, -#line 10 "scripts/genksyms/keywords.gperf" +#line 13 "scripts/genksyms/keywords.gperf" {"EXPORT_UNUSED_SYMBOL", EXPORT_SYMBOL_KEYW}, -#line 40 "scripts/genksyms/keywords.gperf" +#line 43 "scripts/genksyms/keywords.gperf" {"extern", EXTERN_KEYW}, {""}, -#line 21 "scripts/genksyms/keywords.gperf" +#line 24 "scripts/genksyms/keywords.gperf" {"__signed", SIGNED_KEYW}, -#line 11 "scripts/genksyms/keywords.gperf" +#line 14 "scripts/genksyms/keywords.gperf" {"EXPORT_UNUSED_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, -#line 51 "scripts/genksyms/keywords.gperf" +#line 54 "scripts/genksyms/keywords.gperf" {"union", UNION_KEYW}, -#line 55 "scripts/genksyms/keywords.gperf" +#line 58 "scripts/genksyms/keywords.gperf" {"typeof", TYPEOF_KEYW}, -#line 50 "scripts/genksyms/keywords.gperf" +#line 53 "scripts/genksyms/keywords.gperf" {"typedef", TYPEDEF_KEYW}, -#line 19 "scripts/genksyms/keywords.gperf" +#line 22 "scripts/genksyms/keywords.gperf" {"__inline", INLINE_KEYW}, -#line 35 "scripts/genksyms/keywords.gperf" +#line 38 "scripts/genksyms/keywords.gperf" {"auto", AUTO_KEYW}, -#line 23 "scripts/genksyms/keywords.gperf" +#line 26 "scripts/genksyms/keywords.gperf" {"__volatile", VOLATILE_KEYW}, {""}, {""}, -#line 52 "scripts/genksyms/keywords.gperf" +#line 55 "scripts/genksyms/keywords.gperf" {"unsigned", UNSIGNED_KEYW}, {""}, -#line 46 "scripts/genksyms/keywords.gperf" +#line 49 "scripts/genksyms/keywords.gperf" {"short", SHORT_KEYW}, -#line 42 "scripts/genksyms/keywords.gperf" +#line 45 "scripts/genksyms/keywords.gperf" {"inline", INLINE_KEYW}, {""}, -#line 54 "scripts/genksyms/keywords.gperf" +#line 57 "scripts/genksyms/keywords.gperf" {"volatile", VOLATILE_KEYW}, -#line 44 "scripts/genksyms/keywords.gperf" +#line 47 "scripts/genksyms/keywords.gperf" {"long", LONG_KEYW}, -#line 26 "scripts/genksyms/keywords.gperf" +#line 29 "scripts/genksyms/keywords.gperf" {"_Bool", BOOL_KEYW}, {""}, {""}, -#line 45 "scripts/genksyms/keywords.gperf" +#line 48 "scripts/genksyms/keywords.gperf" {"register", REGISTER_KEYW}, -#line 53 "scripts/genksyms/keywords.gperf" +#line 56 "scripts/genksyms/keywords.gperf" {"void", VOID_KEYW}, -#line 41 "scripts/genksyms/keywords.gperf" +#line 44 "scripts/genksyms/keywords.gperf" {"float", FLOAT_KEYW}, -#line 38 "scripts/genksyms/keywords.gperf" +#line 41 "scripts/genksyms/keywords.gperf" {"double", DOUBLE_KEYW}, {""}, {""}, {""}, {""}, -#line 47 "scripts/genksyms/keywords.gperf" +#line 50 "scripts/genksyms/keywords.gperf" {"signed", SIGNED_KEYW} };
scripts/genksyms/lex.lex.c_shipped renamed from scripts/genksyms/lex.c_shipped +6 -354
986 lines not on this page · raw message
scripts/genksyms/parse.h_shipped deleted +0 -97
97 lines not on this page · raw message
scripts/genksyms/parse.tab.c_shipped renamed from scripts/genksyms/parse.c_shipped +18 -182
689 lines not on this page · raw message
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 6/13 kconfig: constify `kconf_id_lookup'
In reply to Arnaud Lacombe--- scripts/kconfig/Makefile | 2 +- scripts/kconfig/zconf.gperf | 2 +- scripts/kconfig/zconf.l | 4 ++-- scripts/kconfig/zconf.y | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-)
scripts/kconfig/Makefile +1 -1
@@ -348,7 +348,7 @@ lex.%.c: %.l cp $@ $@_shipped %.hash.c: %.gperf - gperf < $< > $@ + gperf -C < $< > $@ cp $@ $@_shipped endif
scripts/kconfig/zconf.gperf +1 -1
@@ -9,7 +9,7 @@ struct kconf_id; -static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); +static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); %% mainmenu, T_MAINMENU, TF_COMMAND
scripts/kconfig/zconf.l +2 -2
@@ -96,7 +96,7 @@ n [A-Za-z0-9_] <COMMAND>{ {n}+ { - struct kconf_id *id = kconf_id_lookup(yytext, yyleng); + const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); BEGIN(PARAM); current_pos.file = current_file; current_pos.lineno = current_file->lineno;
@@ -132,7 +132,7 @@ n [A-Za-z0-9_] \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; --- /* ignore */ ({n}|[-/.])+ { - struct kconf_id *id = kconf_id_lookup(yytext, yyleng); + const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); if (id && id->flags & TF_PARAM) { zconflval.id = id; return id->token;
scripts/kconfig/zconf.y +4 -4
@@ -25,7 +25,7 @@ extern int zconflex(void); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); static void zconferror(const char *err); -static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken); +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); struct symbol *symbol_hash[SYMBOL_HASHSIZE];
@@ -45,7 +45,7 @@ static struct menu *current_menu, *current_entry; struct symbol *symbol; struct expr *expr; struct menu *menu; - struct kconf_id *id; + const struct kconf_id *id; } %token <id>T_MAINMENU
@@ -229,7 +229,7 @@ symbol_option_list: /* empty */ | symbol_option_list T_WORD symbol_option_arg { - struct kconf_id *id = kconf_id_lookup($2, strlen($2)); + const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); if (id && id->flags & TF_OPTION) menu_add_option(id->token, $3); else
@@ -545,7 +545,7 @@ static const char *zconf_tokenname(int token) return "<token>"; } -static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken) +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken) { if (id->token != endtoken) { zconf_error("unexpected '%s' within %s block",
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 7/13 kconfig: back-out parser prefix, from `zconf' to `yy'
In reply to Arnaud Lacombe--- scripts/kconfig/lkc.h | 2 +- scripts/kconfig/zconf.l | 16 ++++++++-------- scripts/kconfig/zconf.y | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 20 deletions(-)
scripts/kconfig/lkc.h +1 -1
@@ -69,7 +69,7 @@ struct kconf_id { };#ifdef YYDEBUG -extern int zconfdebug; +extern int yyebug;#endif int zconfparse (void );
scripts/kconfig/zconf.l +8 -8
@@ -101,11 +101,11 @@ n [A-Za-z0-9_] current_pos.file = current_file; current_pos.lineno = current_file->lineno; if (id && id->flags & TF_COMMAND) { - zconflval.id = id; + yylval.id = id; return id->token; } alloc_string(yytext, yyleng); - zconflval.string = text; + yylval.string = text; return T_WORD; } .
@@ -134,11 +134,11 @@ n [A-Za-z0-9_] ({n}|[-/.])+ { const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); if (id && id->flags & TF_PARAM) { - zconflval.id = id; + yylval.id = id; return id->token; } alloc_string(yytext, yyleng); - zconflval.string = text; + yylval.string = text; return T_WORD; } #.* /* comment */
@@ -152,7 +152,7 @@ n [A-Za-z0-9_] <STRING>{ [^'"\\\n]+/\n { append_string(yytext, yyleng); - zconflval.string = text; + yylval.string = text; return T_WORD_QUOTE; } [^'"\\\n]+ {
@@ -160,7 +160,7 @@ n [A-Za-z0-9_] } \\.?/\n { append_string(yytext + 1, yyleng - 1); - zconflval.string = text; + yylval.string = text; return T_WORD_QUOTE; } \\.? {
@@ -169,7 +169,7 @@ n [A-Za-z0-9_] \'|\" { if (str == yytext[0]) { BEGIN(PARAM); - zconflval.string = text; + yylval.string = text; return T_WORD_QUOTE; } else append_string(yytext, 1);
@@ -252,7 +252,7 @@ void zconf_starthelp(void) static void zconf_endhelp(void) { - zconflval.string = text; + yylval.string = text; BEGIN(INITIAL); }
scripts/kconfig/zconf.y +11 -11
@@ -21,10 +21,10 @@ int cdebug = PRINTD; -extern int zconflex(void); +extern int yylex(void); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); -static void zconferror(const char *err); +static void yyerror(const char *err); static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); struct symbol *symbol_hash[SYMBOL_HASHSIZE];
@@ -505,10 +505,10 @@ void conf_parse(const char *name) #if YYDEBUG if (getenv("ZCONF_DEBUG")) - zconfdebug = 1; + yydebug = 1; #endif - zconfparse(); - if (zconfnerrs) + yyparse(); + if (yynerrs) exit(1); if (!modules_sym->prop) { struct property *prop;
@@ -523,9 +523,9 @@ void conf_parse(const char *name) menu_finalize(&rootmenu); for_all_symbols(i, sym) { if (sym_check_deps(sym)) - zconfnerrs++; + yynerrs++; } - if (zconfnerrs) + if (yynerrs) exit(1); sym_set_change_count(1); }
@@ -550,7 +550,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok if (id->token != endtoken) { zconf_error("unexpected '%s' within %s block", kconf_id_strings + id->name, zconf_tokenname(starttoken)); - zconfnerrs++; + yynerrs++; return false; } if (current_menu->file != current_file) {
@@ -559,7 +559,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok fprintf(stderr, "%s:%d: location of the '%s'\n", current_menu->file->name, current_menu->lineno, zconf_tokenname(starttoken)); - zconfnerrs++; + yynerrs++; return false; } return true;
@@ -580,7 +580,7 @@ static void zconf_error(const char *err, ...) { va_list ap; - zconfnerrs++; + yynerrs++; fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); va_start(ap, err); vfprintf(stderr, err, ap);
@@ -588,7 +588,7 @@ static void zconf_error(const char *err, ...) fprintf(stderr, "\n"); } -static void zconferror(const char *err) +static void yyerror(const char *err) { #if YYDEBUG fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
Signature · 1 line
1.7.3.4.574.g608b.dirty
Re: [RFCv2 07/13] kconfig: back-out parser prefix, from `zconf' to `yy'
Arnaud, All,
Quoted 11 lines · On Monday 23 May 2011 101033 Arnaud Lacombe wrote:
--- scripts/kconfig/lkc.h | 2 +- scripts/kconfig/zconf.l | 16 ++++++++-------- scripts/kconfig/zconf.y | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 20 deletions(-)scripts/kconfig/lkc.h +0
-0
scripts/kconfig/lkc.h struct kconf_id { · line 72
Quoted 5 lines
scripts/kconfig/lkc.h +1
-1@@ -69,7 +69,7 @@ struct kconf_id { };#ifdef YYDEBUG -extern int zconfdebug; +extern int yyebug;
Missing 'd' in yyebug, maybe? See below...
[--SNIP--]
Quoted 18 lines
scripts/kconfig/zconf.y +2
-2@@ -21,10 +21,10 @@ int cdebug = PRINTD; -extern int zconflex(void); +extern int yylex(void); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); -static void zconferror(const char *err); +static void yyerror(const char *err); static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); struct symbol *symbol_hash[SYMBOL_HASHSIZE];
scripts/kconfig/zconf.y void conf_parse(const char *name) · line 508
Quoted 5 lines
scripts/kconfig/zconf.y +1
-1@@ -505,10 +505,10 @@ void conf_parse(const char *name) #if YYDEBUG if (getenv("ZCONF_DEBUG")) - zconfdebug = 1; + yydebug = 1;
... here we use yydebug with a 'd'.
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +0/33 662376056 | Software Designer | \ / CAMPAIGN | ^ | | --==< O_o >==-- '------------.-------: X AGAINST | /e\ There is no | | http://ymorin.is-a-geek.org/ | (*_*) | / \ HTML MAIL | """ conspiracy. | '------------------------------'-------'------------------'--------------------'
Re: [RFCv2 07/13] kconfig: back-out parser prefix, from `zconf' to `yy'
Hi,
Quoted 16 lines · Yann E. MORIN
Arnaud, All,
Quoted 13 lines · On Monday 23 May 2011 101033 Arnaud Lacombe wrote:
---
scripts/kconfig/lkc.h | 2 +-scripts/kconfig/zconf.l| 16 ++++++++--------scripts/kconfig/zconf.y| 22 +++++++++++-----------3 files changed, 20 insertions(+), 20 deletions(-)scripts/kconfig/lkc.h +0
-0@@ -69,7 +69,7 @@ struct kconf_id { };
Quoted 6 lines
scripts/kconfig/lkc.h struct kconf_id { · line 72
Quoted 3 lines
scripts/kconfig/lkc.h +1
-1#ifdef YYDEBUG -extern int zconfdebug; +extern int yyebug;Missing 'd' in yyebug, maybe? See below...
indeed :) ...fixed,
Thanks,
- Arnaud
RFC v2 8/13 kconfig: kill no longer needed reference to YYDEBUG
In reply to Arnaud Lacombe--- scripts/kconfig/lkc.h | 2 -- scripts/kconfig/zconf.y | 12 +++--------- 2 files changed, 3 insertions(+), 11 deletions(-)
scripts/kconfig/lkc.h +0 -2
@@ -68,9 +68,7 @@ struct kconf_id {enum symbol_type stype; }; -#ifdef YYDEBUG extern int yyebug; -#endif int zconfparse (void );void zconfdump (FILE *out);
scripts/kconfig/zconf.y +3 -9
@@ -31,10 +31,6 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; -#define YYDEBUG 0 -#if YYDEBUG -#define YYERROR_VERBOSE -#endif %} %expect 30
@@ -503,10 +499,10 @@ void conf_parse(const char *name) modules_sym->flags |= SYMBOL_AUTO; rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); -#if YYDEBUG - if (getenv("ZCONF_DEBUG")) + if (getenv("ZCONF_DEBUG")) { + extern int yydebug; yydebug = 1; -#endif + } yyparse(); if (yynerrs) exit(1);
@@ -590,9 +586,7 @@ static void zconf_error(const char *err, ...) static void yyerror(const char *err) { -#if YYDEBUG fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); -#endif } static void print_quoted_string(FILE *out, const char *str)
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 9/13 kconfig: migrate parser to implicit rules
In reply to Arnaud Lacombe--- scripts/kconfig/.gitignore | 2 +- scripts/kconfig/Makefile | 25 ------------------------- scripts/kconfig/zconf.y | 2 +- 3 files changed, 2 insertions(+), 27 deletions(-)
scripts/kconfig/.gitignore +1 -1
@@ -2,7 +2,7 @@ # Generated files # config* -lex.*.c +*.lex.c *.tab.c *.tab.h zconf.hash.c
scripts/kconfig/Makefile +0 -25
@@ -327,28 +327,3 @@ $(obj)/lkc_defs.h: $(src)/lkc_proto.h $(obj)/gconf.glade.h: $(obj)/gconf.glade intltool-extract --type=gettext/glade $(obj)/gconf.glade -### -# The following requires flex/bison/gperf -# By default we use the _shipped versions, uncomment the following line if -# you are modifying the flex/bison src. -# LKC_GENPARSER := 1 - -ifdef LKC_GENPARSER - -$(obj)/zconf.tab.c: $(src)/zconf.y -$(obj)/lex.zconf.c: $(src)/zconf.l -$(obj)/zconf.hash.c: $(src)/zconf.gperf - -%.tab.c: %.y - bison -l -b $* -p $(notdir $*) $< - cp $@ $@_shipped - -lex.%.c: %.l - flex -L -P$(notdir $*) -o$@ $< - cp $@ $@_shipped - -%.hash.c: %.gperf - gperf -C < $< > $@ - cp $@ $@_shipped - -endif
scripts/kconfig/zconf.y +1 -1
@@ -735,7 +735,7 @@ void zconfdump(FILE *out) } } -#include "lex.zconf.c" +#include "zconf.lex.c" #include "util.c" #include "confdata.c" #include "expr.c"
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 10/13 kconfig: regen parser
In reply to Arnaud Lacombe---
scripts/kconfig/Makefile | 6 +-
scripts/kconfig/zconf.hash.c_shipped | 273 +++++++-----
.../{lex.zconf.c_shipped => zconf.lex.c_shipped} | 493 +++++++++-----------
scripts/kconfig/zconf.tab.c_shipped | 102 ++---
4 files changed, 438 insertions(+), 436 deletions(-)
rename scripts/kconfig/{lex.zconf.c_shipped => zconf.lex.c_shipped} (81%)scripts/kconfig/Makefile +3 -3
@@ -197,7 +197,7 @@ gconf-objs := gconf.o kconfig_load.o zconf.tab.o endif clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ - .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h + .tmp_gtkcheck zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h clean-files += mconf qconf gconf nconf clean-files += config.pot linux.pot
@@ -213,7 +213,7 @@ always := dochecklxdialog HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) # generated files seem to need this to find local include files -HOSTCFLAGS_lex.zconf.o := -I$(src) +HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl
@@ -309,7 +309,7 @@ $(obj)/.tmp_gtkcheck: fi endif -$(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c +$(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c $(obj)/kconfig_load.o: $(obj)/lkc_defs.h
scripts/kconfig/zconf.hash.c_shipped +157 -116
352 lines not on this page · raw message
scripts/kconfig/zconf.lex.c_shipped renamed from scripts/kconfig/lex.zconf.c_shipped +230 -263
1,210 lines not on this page · raw message
scripts/kconfig/zconf.tab.c_shipped +48 -54
225 lines not on this page · raw message
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 11/13 dtc: include the lexer from the parser
In reply to Arnaud Lacombe--- scripts/dtc/dtc-lexer.l | 1 - scripts/dtc/dtc-parser.y | 2 ++ 2 files changed, 2 insertions(+), 1 deletions(-)
scripts/dtc/dtc-lexer.l +0 -1
@@ -36,7 +36,6 @@ LINECOMMENT "//".*\n %{ #include "dtc.h" #include "srcpos.h" -#include "dtc-parser.tab.h" YYLTYPE yylloc;
scripts/dtc/dtc-parser.y +2 -0
@@ -343,3 +343,5 @@ static unsigned long long eval_literal(const char *s, int base, int bits) print_error("bad literal"); return val; } + +#include "dtc-lexer.lex.c"
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 12/13 dtc: migrate parser to implicit rules
In reply to Arnaud Lacombe--- scripts/dtc/Makefile | 29 ++--------------------------- 1 files changed, 2 insertions(+), 27 deletions(-)
scripts/dtc/Makefile +2 -27
@@ -5,7 +5,7 @@ always := $(hostprogs-y) dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ srcpos.o checks.o util.o -dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o +dtc-objs += dtc-parser.tab.o # Source files need to get at the userspace version of libfdt_env.h to compile
@@ -21,35 +21,10 @@ HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC) HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC) HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC) -HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC) HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) # dependencies on generated files need to be listed explicitly -$(obj)/dtc-parser.tab.o: $(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h -$(obj)/dtc-lexer.lex.o: $(obj)/dtc-lexer.lex.c $(obj)/dtc-parser.tab.h +$(obj)/dtc-parser.tab.o: $(obj)/dtc-lexer.lex.c targets += dtc-parser.tab.c dtc-lexer.lex.c -clean-files += dtc-parser.tab.h - -# GENERATE_PARSER := 1 # Uncomment to rebuild flex/bison output - -ifdef GENERATE_PARSER - -BISON = bison -FLEX = flex - -quiet_cmd_bison = BISON $@ - cmd_bison = $(BISON) -o$@ -d $<; cp $@ $@_shipped -quiet_cmd_flex = FLEX $@ - cmd_flex = $(FLEX) -o$@ $<; cp $@ $@_shipped - -$(obj)/dtc-parser.tab.c: $(src)/dtc-parser.y FORCE - $(call if_changed,bison) - -$(obj)/dtc-parser.tab.h: $(obj)/dtc-parser.tab.c - -$(obj)/dtc-lexer.lex.c: $(src)/dtc-lexer.l FORCE - $(call if_changed,flex) - -endif
Signature · 1 line
1.7.3.4.574.g608b.dirty
RFC v2 13/13 dtc: regen parser
In reply to Arnaud Lacombe--- scripts/dtc/dtc-lexer.lex.c_shipped | 60 ++---------------- scripts/dtc/dtc-parser.tab.c_shipped | 118 ++++++---------------------------- scripts/dtc/dtc-parser.tab.h_shipped | 91 -------------------------- 3 files changed, 24 insertions(+), 245 deletions(-) delete mode 100644 scripts/dtc/dtc-parser.tab.h_shipped
scripts/dtc/dtc-lexer.lex.c_shipped +5 -55
@@ -1,6 +1,5 @@ -#line 2 "dtc-lexer.lex.c" -#line 4 "dtc-lexer.lex.c" +#line 3 "scripts/dtc/dtc-lexer.lex.c_shipped" #define YY_INT_ALIGNED short int
@@ -54,6 +53,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN
@@ -84,8 +84,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus
@@ -142,15 +140,7 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer.
@@ -550,7 +540,6 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "dtc-lexer.l" /* * (C) Copyright David Gibson <[email protected]>, IBM Corporation. 2005. *
@@ -572,13 +561,8 @@ char *yytext; */ #define YY_NO_INPUT 1 - - - -#line 37 "dtc-lexer.l" #include "dtc.h" #include "srcpos.h" -#include "dtc-parser.tab.h" YYLTYPE yylloc;
@@ -603,7 +587,6 @@ static int dts_version = 1; static void push_input_file(const char *filename); static int pop_input_file(void); -#line 607 "dtc-lexer.lex.c" #define INITIAL 0 #define INCLUDE 1
@@ -686,12 +669,7 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */
@@ -710,7 +688,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + unsigned n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \
@@ -792,10 +770,6 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 66 "dtc-lexer.l" - -#line 798 "dtc-lexer.lex.c" - if ( !(yy_init) ) { (yy_init) = 1;
@@ -876,7 +850,6 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 67 "dtc-lexer.l" { char *name = strchr(yytext, '\"') + 1; yytext[yyleng-1] = '\0';
@@ -888,7 +861,6 @@ case YY_STATE_EOF(INCLUDE): case YY_STATE_EOF(BYTESTRING): case YY_STATE_EOF(PROPNODENAME): case YY_STATE_EOF(V1): -#line 73 "dtc-lexer.l" { if (!pop_input_file()) { yyterminate();
@@ -898,7 +870,6 @@ case YY_STATE_EOF(V1): case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 79 "dtc-lexer.l" { DPRINT("String: %s\n", yytext); yylval.data = data_copy_escape_string(yytext+1,
@@ -908,7 +879,6 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 86 "dtc-lexer.l" { DPRINT("Keyword: /dts-v1/\n"); dts_version = 1;
@@ -918,7 +888,6 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 93 "dtc-lexer.l" { DPRINT("Keyword: /memreserve/\n"); BEGIN_DEFAULT();
@@ -927,7 +896,6 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 99 "dtc-lexer.l" { DPRINT("Label: %s\n", yytext); yylval.labelref = xstrdup(yytext);
@@ -937,7 +905,6 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 106 "dtc-lexer.l" { yylval.literal = xstrdup(yytext); DPRINT("Literal: '%s'\n", yylval.literal);
@@ -946,7 +913,6 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 112 "dtc-lexer.l" { /* label reference */ DPRINT("Ref: %s\n", yytext+1); yylval.labelref = xstrdup(yytext+1);
@@ -955,7 +921,6 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 118 "dtc-lexer.l" { /* new-style path reference */ yytext[yyleng-1] = '\0'; DPRINT("Ref: %s\n", yytext+2);
@@ -965,7 +930,6 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 125 "dtc-lexer.l" { yylval.byte = strtol(yytext, NULL, 16); DPRINT("Byte: %02x\n", (int)yylval.byte);
@@ -974,7 +938,6 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 131 "dtc-lexer.l" { DPRINT("/BYTESTRING\n"); BEGIN_DEFAULT();
@@ -983,7 +946,6 @@ YY_RULE_SETUP YY_BREAK case 11: YY_RULE_SETUP -#line 137 "dtc-lexer.l" { DPRINT("PropNodeName: %s\n", yytext); yylval.propnodename = xstrdup(yytext);
@@ -993,7 +955,6 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 144 "dtc-lexer.l" { DPRINT("Binary Include\n"); return DT_INCBIN;
@@ -1002,24 +963,20 @@ YY_RULE_SETUP case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 149 "dtc-lexer.l" /* eat whitespace */ YY_BREAK case 14: /* rule 14 can match eol */ YY_RULE_SETUP -#line 150 "dtc-lexer.l" /* eat C-style comments */ YY_BREAK case 15: /* rule 15 can match eol */ YY_RULE_SETUP -#line 151 "dtc-lexer.l" /* eat C++-style comments */ YY_BREAK case 16: YY_RULE_SETUP -#line 153 "dtc-lexer.l" { DPRINT("Char: %c (\\x%02x)\n", yytext[0], (unsigned)yytext[0]);
@@ -1037,10 +994,8 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 168 "dtc-lexer.l" ECHO; YY_BREAK -#line 1044 "dtc-lexer.lex.c" case YY_END_OF_BUFFER: {
@@ -1756,8 +1711,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */
@@ -1996,10 +1951,6 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 168 "dtc-lexer.l" - - - static void push_input_file(const char *filename) { assert(filename);
@@ -2011,7 +1962,6 @@ static void push_input_file(const char *filename) yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE)); } - static int pop_input_file(void) { if (srcfile_pop() == 0)
scripts/dtc/dtc-parser.tab.c_shipped +19 -99
426 lines not on this page · raw message
scripts/dtc/dtc-parser.tab.h_shipped deleted +0 -91
91 lines not on this page · raw message
Signature · 1 line
1.7.3.4.574.g608b.dirty
Hi,
Quoted 5 lines · Arnaud Lacombe
Hi,
[...]
A few notes:
- the parser should not include the lexer; however, this has the advantage to avoid having to deals with the parser's header.
fixed in https://github.com/lacombar/linux-2.6/commits/kbuild-implicit-parser-rule.
new diffstat:
% git ds -M v2.6.39..HEAD
scripts/Makefile.lib | 38 ++-
scripts/dtc/Makefile | 23 -
scripts/dtc/dtc-lexer.lex.c_shipped | 59 +---
scripts/dtc/dtc-parser.tab.c_shipped | 116 +----
scripts/dtc/dtc-parser.tab.h_shipped | 11 +-
scripts/genksyms/.gitignore | 7 +-
scripts/genksyms/Makefile | 48 +--
scripts/genksyms/keywords.gperf | 3 +
...{keywords.c_shipped => keywords.hash.c_shipped} | 96 ++--
scripts/genksyms/lex.l | 4 +-
.../genksyms/{lex.c_shipped => lex.lex.c_shipped} | 359 +--------------
.../{parse.c_shipped => parse.tab.c_shipped} | 198 +-------
.../{parse.h_shipped => parse.tab.h_shipped} | 7 +-
scripts/kconfig/.gitignore | 2 +-
scripts/kconfig/Makefile | 31 +--
scripts/kconfig/lkc.h | 4 +-
scripts/kconfig/zconf.gperf | 2 +-
scripts/kconfig/zconf.hash.c_shipped | 273 +++++++-----
scripts/kconfig/zconf.l | 20 +-
.../{lex.zconf.c_shipped => zconf.lex.c_shipped} | 493 +++++++++-----------
scripts/kconfig/zconf.tab.c_shipped | 102 ++---
.../zconf.tab.h_shipped} | 96 ++--
scripts/kconfig/zconf.y | 44 +-
23 files changed, 668 insertions(+), 1368 deletions(-)That should remove any incompatibilities with the upstream dtc tree.
- Arnaud
Quoted 13 lines · Arnaud Lacombe
Hi,
[ Original RFC and motivation can be found at:
http://marc.info/?l=linux-kbuild&m=130456101131801&w=2 ]I tried to re-think the order in this serie to address Michal comments.
Main changes since v1 are:
- includescripts/dtc/' parser in the scope of the patchset
- do not rename any parser source
- make lexer file name consistent, ie. name it %.lex.c, not lex.%.c
- rebase on top of v2.6.39
Quoted 8 lines
A few notes:
- the parser should not include the lexer; however, this has the advantage to avoid having to deals with the parser's header.
- the tuple ( "migrate parser to implicit rules", regen parser) should really be one commit, to enforce bisect'abilityComments welcome!
- Arnaud
Hi,
thanks for the series, but I will probably not have time to review it before this merge window closes. So it will have to wait for .41 most likely.
Michal
Hi,
2011/5/24 Michal Marek <[email protected]>:
Quoted 23 lines · Arnaud Lacombe
Quoted 22 lines
Hi,
[ Original RFC and motivation can be found at:
http://marc.info/?l=linux-kbuild&m=130456101131801&w=2 ]I tried to re-think the order in this serie to address Michal comments.
Main changes since v1 are:
- includescripts/dtc/' parser in the scope of the patchset
- do not rename any parser source
- make lexer file name consistent, ie. name it %.lex.c, not lex.%.c
- rebase on top of v2.6.39A few notes:
- the parser should not include the lexer; however, this has the advantage to
avoid having to deals with the parser's header.
- the tuple ( "migrate parser to implicit rules", regen parser) should really
be one commit, to enforce bisect'ability
Quoted 8 lines
Quoted 2 lines
Comments welcome!
- ArnaudHi,
thanks for the series, but I will probably not have time to review it before this merge window closes. So it will have to wait for .41 most likely.
fine with me, I am not entirely happy with that serie anyway, so I'll certainly do another iteration after -rc1 (to include whatever has changed in the mean time).
- Arnaud
RFC v3 1/1 Kbuild: factor parser rules
In reply to Arnaud LacombeHi Michal,
Here is some update concerning the parser generation merge. I do not repost the whole serie as it may be overkill. You can find the latest branch at:
git://github.com/lacombar/linux-2.6.git kbuild-implicit-parser-rule
You'll find an updated diff between v2 [rebased on top of v3.0-rc1] and v3 below.
Changes since v2:
- allow a parser to specify the prefix to be used. This will allow for multiple parser to use the implicit rules, which was not previously possible, as it was using the `yy' default.
- drop the zconf prefix changes
- add a baseprereq' global to kbuild, which mimics basetarget'
- rebase on top of v3.0-rc1
Changes since v1:
- include scripts/dtc/' parser in the scope of the patchset
- do not rename any parser source
- make lexer file name consistent, ie. name it %.lex.c, not lex.%.c
- rebase on top of v2.6.39
I am still not a huge fan of the {YACC,LEX}_PREFIX_ naming, if you got a better idea, it is most welcome !
Regards,
- Arnaud
Arnaud Lacombe (11):
kbuild: add `baseprereq'
kbuild: add implicit rules for parser generation
genksyms: pass hash and lookup functions name and target language though the input file
genksyms: migrate parser to implicit rules
genksym: regen parser
kconfig: constify `kconf_id_lookup'
kconfig: kill no longer needed reference to YYDEBUG
kconfig: migrate parser to implicit rules
kconfig: regen parser
dtc: migrate parser to implicit rules
dtc: regen parser
--- scripts/Kbuild.include | 4 ++++ scripts/Makefile.lib | 5 +++-- scripts/kconfig/Makefile | 3 +++ scripts/kconfig/lkc.h | 2 +- scripts/kconfig/zconf.l | 16 ++++++++-------- scripts/kconfig/zconf.y | 28 ++++++++++++++-------------- 6 files changed, 33 insertions(+), 25 deletions(-)
scripts/Kbuild.include +4 -0
@@ -21,6 +21,10 @@ depfile = $(subst $(comma),_,$(dot-target).d) basetarget = $(basename $(notdir $@)) ### +# filename of first prerequisite with directory and extension stripped +baseprereq = $(basename $(notdir $<)) + +### # Escape single quote for use in echo statements escsq = $(subst $(squote),'\$(squote)',$1)
scripts/Makefile.lib +3 -2
@@ -171,14 +171,15 @@ $(src)/%.hash.c_shipped: $(src)/%.gperf # LEX # --------------------------------------------------------------------------- quiet_cmd_flex = LEX $@ - cmd_flex = flex -o$@ -L $< + cmd_flex = flex -o$@ -L -P $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy) $< + $(src)/%.lex.c_shipped: $(src)/%.l $(call cmd,flex) # YACC # --------------------------------------------------------------------------- quiet_cmd_bison = YACC $@ - cmd_bison = bison -o$@ -d -t -l $< + cmd_bison = bison -o$@ -d -t -l -p $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy) $< $(src)/%.tab.c_shipped: $(src)/%.y $(call cmd,bison)
scripts/kconfig/Makefile +3 -0
@@ -223,6 +223,9 @@ HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) +LEX_PREFIX_zconf := zconf +YACC_PREFIX_zconf := zconf + HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
scripts/kconfig/lkc.h +1 -1
@@ -68,7 +68,7 @@ struct kconf_id {enum symbol_type stype; }; -extern int yydebug; +extern int zconfdebug;int zconfparse (void );void zconfdump (FILE *out);
scripts/kconfig/zconf.l +8 -8
@@ -101,11 +101,11 @@ n [A-Za-z0-9_] current_pos.file = current_file; current_pos.lineno = current_file->lineno; if (id && id->flags & TF_COMMAND) { - yylval.id = id; + zconflval.id = id; return id->token; } alloc_string(yytext, yyleng); - yylval.string = text; + zconflval.string = text; return T_WORD; } .
@@ -134,11 +134,11 @@ n [A-Za-z0-9_] ({n}|[-/.])+ { const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); if (id && id->flags & TF_PARAM) { - yylval.id = id; + zconflval.id = id; return id->token; } alloc_string(yytext, yyleng); - yylval.string = text; + zconflval.string = text; return T_WORD; } #.* /* comment */
@@ -152,7 +152,7 @@ n [A-Za-z0-9_] <STRING>{ [^'"\\\n]+/\n { append_string(yytext, yyleng); - yylval.string = text; + zconflval.string = text; return T_WORD_QUOTE; } [^'"\\\n]+ {
@@ -160,7 +160,7 @@ n [A-Za-z0-9_] } \\.?/\n { append_string(yytext + 1, yyleng - 1); - yylval.string = text; + zconflval.string = text; return T_WORD_QUOTE; } \\.? {
@@ -169,7 +169,7 @@ n [A-Za-z0-9_] \'|\" { if (str == yytext[0]) { BEGIN(PARAM); - yylval.string = text; + zconflval.string = text; return T_WORD_QUOTE; } else append_string(yytext, 1);
@@ -252,7 +252,7 @@ void zconf_starthelp(void) static void zconf_endhelp(void) { - yylval.string = text; + zconflval.string = text; BEGIN(INITIAL); }
scripts/kconfig/zconf.y +14 -14
@@ -21,10 +21,10 @@ int cdebug = PRINTD; -extern int yylex(void); +extern int zconflex(void); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); -static void yyerror(const char *err); +static void zconferror(const char *err); static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); struct symbol *symbol_hash[SYMBOL_HASHSIZE];
@@ -499,12 +499,12 @@ void conf_parse(const char *name) modules_sym->flags |= SYMBOL_AUTO; rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); - if (getenv("ZCONF_DEBUG")) { - extern int yydebug; - yydebug = 1; - } - yyparse(); - if (yynerrs) +#if YYDEBUG + if (getenv("ZCONF_DEBUG")) + zconfdebug = 1; +#endif + zconfparse(); + if (zconfnerrs) exit(1); if (!modules_sym->prop) { struct property *prop;
@@ -519,9 +519,9 @@ void conf_parse(const char *name) menu_finalize(&rootmenu); for_all_symbols(i, sym) { if (sym_check_deps(sym)) - yynerrs++; + zconfnerrs++; } - if (yynerrs) + if (zconfnerrs) exit(1); sym_set_change_count(1); }
@@ -546,7 +546,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok if (id->token != endtoken) { zconf_error("unexpected '%s' within %s block", kconf_id_strings + id->name, zconf_tokenname(starttoken)); - yynerrs++; + zconfnerrs++; return false; } if (current_menu->file != current_file) {
@@ -555,7 +555,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok fprintf(stderr, "%s:%d: location of the '%s'\n", current_menu->file->name, current_menu->lineno, zconf_tokenname(starttoken)); - yynerrs++; + zconfnerrs++; return false; } return true;
@@ -576,7 +576,7 @@ static void zconf_error(const char *err, ...) { va_list ap; - yynerrs++; + zconfnerrs++; fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); va_start(ap, err); vfprintf(stderr, err, ap);
@@ -584,7 +584,7 @@ static void zconf_error(const char *err, ...) fprintf(stderr, "\n"); } -static void yyerror(const char *err) +static void zconferror(const char *err) { fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); }
Quoted 10 lines · Arnaud Lacombe
Hi Michal,
Here is some update concerning the parser generation merge. I do not repost the whole serie as it may be overkill. You can find the latest branch at:
git://github.com/lacombar/linux-2.6.gitkbuild-implicit-parser-ruleYou'll find an updated diff between v2 [rebased on top of v3.0-rc1] and v3 below.
Quoted 7 lines
Changes since v2:
- allow a parser to specify the prefix to be used. This will allow for multiple parser to use the implicit rules, which was not previously possible, as it was using the `yy' default.
- drop the zconf prefix changes
- add abaseprereq' global to kbuild, which mimicsbasetarget'
- rebase on top of v3.0-rc1
Nice. But it still breaks the _shipped rule for files other than those handled explicitely. I guess the problem you are trying to solve is the double-colon in rule? That was added back in 2002 by
http://git.kernel.org/?p=linux/kernel/git/tglx/history.git;a=commitdiff;h=2e8556ce
and it looks to me like a hack to make the _shipped rule fire early enough. Maybe it's not needed nowadays at all, because 53c700.o is a normal object file and not the final module. Nevertheless, if I change it to a normal rule and delete the ones added by you, it all works fine except for genksyms:
scripts/Makefile.lib +1 -11
@@ -192,20 +192,10 @@ endif quiet_cmd_shipped = SHIPPED $@ cmd_shipped = cat $< > $@ -$(obj)/%.tab.c: $(src)/%.tab.c_shipped - $(call cmd,shipped) - -$(obj)/%.tab.h: $(src)/%.tab.h_shipped - $(call cmd,shipped) -$(obj)/%.lex.c: $(src)/%.lex.c_shipped +$(obj)/%: $(src)/%_shipped $(call cmd,shipped) -$(obj)/%.hash.c: $(src)/%.hash.c_shipped - $(call cmd,shipped) - -$(obj)/%:: $(src)/%_shipped - # Commands useful for building a boot image # =========================================================================== #
I'll look into the problem with genksyms later today.
Michal
Hi,
Quoted 49 lines · Michal Marek
Quoted 10 lines · Arnaud Lacombe
Hi Michal,
Here is some update concerning the parser generation merge. I do not repost the whole serie as it may be overkill. You can find the latest branch at:
git://github.com/lacombar/linux-2.6.gitkbuild-implicit-parser-ruleYou'll find an updated diff between v2 [rebased on top of v3.0-rc1] and v3 below.
Quoted 7 lines
Changes since v2:
- allow a parser to specify the prefix to be used. This will allow for multiple parser to use the implicit rules, which was not previously possible, as it was using the `yy' default.
- drop the zconf prefix changes
- add abaseprereq' global to kbuild, which mimicsbasetarget'
- rebase on top of v3.0-rc1Nice. But it still breaks the
_shippedrule for files other than those handled explicitely. I guess the problem you are trying to solve is the double-colon in rule? That was added back in 2002 by
http://git.kernel.org/?p=linux/kernel/git/tglx/history.git;a=commitdiff;h=2e8556ce
and it looks to me like a hack to make the_shippedrule fire early enough. Maybe it's not needed nowadays at all, because 53c700.o is a normal object file and not the final module. Nevertheless, if I change it to a normal rule and delete the ones added by you, it all works fine except for genksyms:scripts/Makefile.lib +0
-0@@ -192,20 +192,10 @@ endifquiet_cmd_shipped = SHIPPED $@
cmd_shipped = cat $< > $@-$(obj)/%.tab.c: $(src)/%.tab.c_shipped
- $(call cmd,shipped)
-
-$(obj)/%.tab.h: $(src)/%.tab.h_shipped
- $(call cmd,shipped)-$(obj)/%.lex.c: $(src)/%.lex.c_shipped
+$(obj)/%: $(src)/%_shipped
$(call cmd,shipped)-$(obj)/%.hash.c: $(src)/%.hash.c_shipped
- $(call cmd,shipped)
scripts/Makefile.lib endif · line 208
Quoted 3 lines
scripts/Makefile.lib +0
-3- -$(obj)/%:: $(src)/%_shipped -
Do'h! This is why the _shipped stuff is broken, it was missing a "$(call cmd,shipped)" here. I'll address that issue today. Eventually without duplicating targets.
- Arnaud
Quoted 8 lines
# Commands useful for building a boot image
# =========================================================================== #I'll look into the problem with genksyms later today.
Michal
RFC v4 1/1 Kbuild: factor parser rules
In reply to Michal MarekHi Michal,
Here is some update concerning the parser generation merge. I do not repost the whole serie as it may be overkill. You can find the latest branch at:
git://github.com/lacombar/linux-2.6.git kbuild-implicit-parser-rule
For the record, I did full test build in the following environment:
% cat allno.configCONFIG_SCSI=yCONFIG_SCSI_LOWLEVEL=yCONFIG_SCSI_AIC7XXX=yCONFIG_SCSI_AIC79XX=yCONFIG_AIC7XXX_REG_PRETTY_PRINT=yCONFIG_AIC79XX_REG_PRETTY_PRINT=yCONFIG_NETDEVICES=yCONFIG_NET=yCONFIG_HDLC=yCONFIG_EISA=yCONFIG_PCI=yCONFIG_VT=yCONFIG_HW_CONSOLE=yCONFIG_WAN=yCONFIG_WANXL=y
% gmake CONFIG_DTC=y CONFIG_MODVERSIONS=y REGENERATE_PARSERS=1 \
scripts allnoconfig vmlinux
finalize without error.
Then, re-started after having updated the parsers:
% touch scripts/*/*.[ly]
finalized without error.
Then, various combinaison of:
% git clean -fdx scripts/
% rm -f $(find . -name *_shipped | sed 's/_shipped//')
% rm -f $(find scripts/ -name '*_shipped') scripts/dtc/dtc-parser.tab.* scripts/genksyms/parse.tab.*
All build finalized without error.
You'll find an updated diff between v3 and v4 below.
Changes since v3:
- fix the %_shipped implicit rule
- attempt to tweak the relation between $(src)/%.tab.c_shipped' and $(src)/%.tab.h_shipped' to make it more robust. This is _very_ delicate as gmake has trouble to properly generate $(obj)/%.tab.h' from $(src)/%.tab.h_shipped' if it is missing and requires `$(src)/%.tab.c_shipped' to be created. This now survives a full deletion of the %_shipped files.
- a few spacing nits
- removes a few useless explicit dependency
- do not degerate extra `lex.debug' file when regenerating kconfig's parser
- removed missed occurences of YYDEBUG
Changes since v2:
- allow a parser to specify the prefix to be used. This will allow for multiple parser to use the implicit rules, which was not previously possible, as it was using the `yy' default.
- drop the zconf prefix changes
- add a baseprereq' global to kbuild, which mimics basetarget'
- rebase on top of v3.0-rc1
Changes since v1:
- include scripts/dtc/' parser in the scope of the patchset
- do not rename any parser source
- make lexer file name consistent, ie. name it %.lex.c, not lex.%.c
- rebase on top of v2.6.39
Regards,
- Arnaud
Arnaud Lacombe (13):
kbuild: add `baseprereq'
kbuild: add implicit rules for parser generation
kbuild: simplify the %_shipped rule
genksyms: pass hash and lookup functions name and target language though the input file
genksyms: migrate parser to implicit rules
genksym: regen parser
kconfig: constify `kconf_id_lookup'
kconfig: kill no longer needed reference to YYDEBUG
kconfig/zconf.l: do not ask to generate backup
kconfig: migrate parser to implicit rules
kconfig: regen parser
dtc: migrate parser to implicit rules
dtc: regen parser
--- scripts/Makefile.lib | 19 +++++-------------- scripts/dtc/Makefile | 3 +-- scripts/genksyms/Makefile | 5 ++++- scripts/kconfig/zconf.l | 4 ++-- scripts/kconfig/zconf.y | 2 -- 5 files changed, 12 insertions(+), 21 deletions(-)
scripts/Makefile.lib +5 -14
@@ -161,10 +161,12 @@ modname-multi = $(sort $(foreach m,$(multi-used),\ $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) ifdef REGENERATE_PARSERS + # GPERF # --------------------------------------------------------------------------- quiet_cmd_gperf = GPERF $@ cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $< + $(src)/%.hash.c_shipped: $(src)/%.gperf $(call cmd,gperf)
@@ -180,10 +182,10 @@ $(src)/%.lex.c_shipped: $(src)/%.l # --------------------------------------------------------------------------- quiet_cmd_bison = YACC $@ cmd_bison = bison -o$@ -d -t -l -p $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy) $< -$(src)/%.tab.c_shipped: $(src)/%.y + +$(src)/%.tab.c_shipped $(src)/%.tab.h_shipped: $(src)/%.y $(call cmd,bison) -$(src)/%.tab.h_shipped: $(src)/%.tab.c_shipped endif # Shipped files
@@ -192,20 +194,9 @@ endif quiet_cmd_shipped = SHIPPED $@ cmd_shipped = cat $< > $@ -$(obj)/%.tab.c: $(src)/%.tab.c_shipped - $(call cmd,shipped) - -$(obj)/%.tab.h: $(src)/%.tab.h_shipped +$(obj)/%: $(src)/%_shipped $(call cmd,shipped) -$(obj)/%.lex.c: $(src)/%.lex.c_shipped - $(call cmd,shipped) - -$(obj)/%.hash.c: $(src)/%.hash.c_shipped - $(call cmd,shipped) - -$(obj)/%:: $(src)/%_shipped - # Commands useful for building a boot image # =========================================================================== #
scripts/dtc/Makefile +1 -2
@@ -26,7 +26,6 @@ HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) # dependencies on generated files need to be listed explicitly $(obj)/dtc-parser.tab.o: $(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h -$(obj)/dtc-lexer.lex.o: $(obj)/dtc-lexer.lex.c $(obj)/dtc-parser.tab.h -targets += dtc-parser.tab.c dtc-lexer.lex.c +$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h
scripts/genksyms/Makefile +4 -1
@@ -7,5 +7,8 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o # -I needed for generated C source (shipped source) HOSTCFLAGS_parse.tab.o := -Wno-uninitialized -I$(src) -$(obj)/lex.lex.o: $(obj)/parse.tab.h $(obj)/keywords.hash.c +$(obj)/parse.tab.o: $(obj)/parse.tab.c $(obj)/parse.tab.h + +$(obj)/lex.lex.o: $(obj)/keywords.hash.c +$(obj)/lex.lex.o: $(obj)/parse.tab.c $(obj)/parse.tab.h
scripts/kconfig/zconf.l +2 -2
@@ -1,5 +1,5 @@ -%option backup nostdinit noyywrap never-interactive full ecs -%option 8bit backup nodefault perf-report perf-report +%option nostdinit noyywrap never-interactive full ecs +%option 8bit nodefault perf-report perf-report %option noinput %x COMMAND HELP STRING PARAM %{
scripts/kconfig/zconf.y +0 -2
@@ -499,10 +499,8 @@ void conf_parse(const char *name) modules_sym->flags |= SYMBOL_AUTO; rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); -#if YYDEBUG if (getenv("ZCONF_DEBUG")) zconfdebug = 1; -#endif zconfparse(); if (zconfnerrs) exit(1);
Signature · 1 line
1.7.3.4.574.g608b.dirty
Hi,
[Bringing that on linux-kernel@, to try to get a little more audience, and eventually a gmake(1) guru. Original motivation about the serie available at http://marc.info/?l=linux-kbuild&m=130456101131801&w=2.
All diff applies to the v4 of the RFC.]
Quoted 9 lines · Arnaud Lacombe
[...]
Changes since v3:
- fix the %_shipped implicit rule
- attempt to tweak the relation between$(src)/%.tab.c_shipped' and$(src)/%.tab.h_shipped' to make it more robust. This is _very_ delicate as gmake has trouble to properly generate$(obj)/%.tab.h' from$(src)/%.tab.h_shipped' if it is missing and requires `$(src)/%.tab.c_shipped' to be created. This now survives a full deletion of the %_shipped file.
Just to illustrate the delicacy of this part, forbidding make(1) to delete the intermediate target, by declaring a .SECONDARY target without any prerequisite (which would seem a desirable behavior):
scripts/Makefile.build +2 -0
@@ -463,3 +463,5 @@ endif # information in a variable se we can use it in if_changed and friends. .PHONY: $(PHONY) + +.SECONDARY:
require to change the order of the .c and .h in the prerequisite:
scripts/dtc/Makefile +2 -2
@@ -25,7 +25,7 @@ HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC) HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) # dependencies on generated files need to be listed explicitly -$(obj)/dtc-parser.tab.o: $(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h +$(obj)/dtc-parser.tab.o: $(obj)/dtc-parser.tab.h $(obj)/dtc-parser.tab.c -$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h +$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h $(obj)/dtc-parser.tab.c
scripts/genksyms/Makefile +2 -2
@@ -7,8 +7,8 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o # -I needed for generated C source (shipped source) HOSTCFLAGS_parse.tab.o := -Wno-uninitialized -I$(src) -$(obj)/parse.tab.o: $(obj)/parse.tab.c $(obj)/parse.tab.h +$(obj)/parse.tab.o: $(obj)/parse.tab.h $(obj)/parse.tab.c $(obj)/lex.lex.o: $(obj)/keywords.hash.c -$(obj)/lex.lex.o: $(obj)/parse.tab.c $(obj)/parse.tab.h +$(obj)/lex.lex.o: $(obj)/parse.tab.h $(obj)/parse.tab.c
else, the .h is regenerated first. Something we do not want. However, if we revert the change to the precedent version, that is:
scripts/Makefile.lib +0 -0
@@ -183,9 +183,11 @@ $(src)/%.lex.c_shipped: $(src)/%.l quiet_cmd_bison = YACC $@ cmd_bison = bison -o$@ -d -t -l -p $(if
$(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy) $<
-$(src)/%.tab.c_shipped $(src)/%.tab.h_shipped: $(src)/%.y +$(src)/%.tab.c_shipped: $(src)/%.y
$(call cmd,bison)
+$(src)/%.tab.h_shipped: $(src)/%.tab.c_shipped
+
which would seem more "logical", the chaining breaks:
HOSTCC scripts/basic/fixdep HOSTCC scripts/dtc/checks.o HOSTCC scripts/dtc/data.o LEX scripts/dtc/dtc-lexer.lex.c_shipped
SHIPPED scripts/dtc/dtc-lexer.lex.c
gmake[3]: *** No rule to make target scripts/dtc/dtc-parser.tab.h', needed by scripts/dtc/dtc-lexer.lex.o'. Stop.
gmake[2]: *** [scripts/dtc] Error 2
gmake[1]: *** [scripts] Error 2
gmake: *** [scripts] Error 2
So, make(1) is smart enough to link, in the general case, scripts/dtc/dtc-parser.tab.c' to scripts/dtc/dtc-parser.tab.c_shipped' then to scripts/dtc/dtc-parser.y'. However, it seems to be unable to link scripts/dtc/dtc-parser.tab.h' to scripts/dtc/dtc-parser.tab.h_shipped', which in turns is be linked explicitly to scripts/dtc/dtc-parser.tab.c_shipped' and `scripts/dtc/dtc-parser.y'.
A possible more robust workaround for this situation would be to generate the shipped header independently from the parser source. In which case we would have something ala:
# YACC
# ---------------------------------------------------------------------------
quiet_cmd_bison = YACC $@
cmd_bison = bison -o$@ -t -l -p [...]
$(src)/%.tab.c_shipped: $(src)/%.y
$(call cmd,bison)
quiet_cmd_bison_h = YACC $@
cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p [...]
$(src)/%.tab.h_shipped: $(src)/%.y
$(call cmd,bison_h)
Regards,
- Arnaud
ps: this is all with gmake 3.82.
RFC v5 1/1 Kbuild: factor parser rules
In reply to Arnaud LacombeHi Michal,
Here is some update concerning the parser generation merge. I do not repost the whole serie as it may be overkill. You can find the latest branch at:
git://github.com/lacombar/linux-2.6.git kbuild-implicit-parser-rule
So let't get it done the safe way...
Changes since v4:
- split the parser definition and its associated header. This workaround gmake(1) inabilities to link implicit rules [... or my own to find the right sequence :)]. As you can see with the incremental diff, the .tab.c is absolutly not alterated by this change
- nuke the unused `scripts/kconfig/zconf.tab.h_shipped'
- avoids long lines in the lexer/parser command
- clean-up {genksyms,dtc}/Makefile
Changes since v3:
- fix the %_shipped implicit rule
- attempt to tweak the relation between $(src)/%.tab.c_shipped' and $(src)/%.tab.h_shipped' to make it more robust. This is _very_ delicate as gmake has trouble to properly generate $(obj)/%.tab.h' from $(src)/%.tab.h_shipped' if it is missing and requires `$(src)/%.tab.c_shipped' to be created. This now survives a full deletion of the i%_shipped files.
- a few spacing nits
- removes a few useless explicit dependency
- do not degerate extra `lex.debug' file when regenerating kconfig's parser
- removed missed occurences of YYDEBUG
Changes since v2:
- allow a parser to specify the prefix to be used. This will allow for multiple parser to use the implicit rules, which was not previously possible, as it was using the `yy' default.
- drop the zconf prefix changes
- add a baseprereq' global to kbuild, which mimics basetarget'
- rebase on top of v3.0-rc1
Changes since v1:
- include scripts/dtc/' parser in the scope of the patchset
- do not rename any parser source
- make lexer file name consistent, ie. name it %.lex.c, not lex.%.c
- rebase on top of v2.6.39
Regards,
- Arnaud
Arnaud Lacombe (14):
kbuild: add `baseprereq'
kbuild: add implicit rules for parser generation
kbuild: simplify the %_shipped rule
genksyms: pass hash and lookup functions name and target language though the input file
genksyms: drop -Wno-uninitialized from HOSTCFLAGS_parse.tab.o
genksyms: migrate parser to implicit rules
genksym: regen parser
kconfig: constify `kconf_id_lookup'
kconfig: kill no longer needed reference to YYDEBUG
kconfig/zconf.l: do not ask to generate backup
kconfig: migrate parser to implicit rules
kconfig: regen parser
dtc: migrate parser to implicit rules
dtc: regen parser
--- scripts/Makefile.lib | 16 +++++- scripts/dtc/Makefile | 4 +- scripts/genksyms/Makefile | 9 ++-- scripts/kconfig/zconf.tab.h_shipped | 101 ----------------------------------- 4 files changed, 18 insertions(+), 112 deletions(-)
scripts/Makefile.lib +13 -3
@@ -172,20 +172,30 @@ $(src)/%.hash.c_shipped: $(src)/%.gperf # LEX # --------------------------------------------------------------------------- +LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy) + quiet_cmd_flex = LEX $@ - cmd_flex = flex -o$@ -L -P $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy) $< + cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $< $(src)/%.lex.c_shipped: $(src)/%.l $(call cmd,flex) # YACC # --------------------------------------------------------------------------- +YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy) + quiet_cmd_bison = YACC $@ - cmd_bison = bison -o$@ -d -t -l -p $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy) $< + cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $< -$(src)/%.tab.c_shipped $(src)/%.tab.h_shipped: $(src)/%.y +$(src)/%.tab.c_shipped: $(src)/%.y $(call cmd,bison) +quiet_cmd_bison_h = YACC $@ + cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $< + +$(src)/%.tab.h_shipped: $(src)/%.y + $(call cmd,bison_h) + endif # Shipped files
scripts/dtc/Makefile +1 -3
@@ -25,7 +25,5 @@ HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC) HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) # dependencies on generated files need to be listed explicitly -$(obj)/dtc-parser.tab.o: $(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h - -$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h +$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
scripts/genksyms/Makefile +4 -5
@@ -5,10 +5,9 @@ always := $(hostprogs-y) genksyms-objs := genksyms.o parse.tab.o lex.lex.o # -I needed for generated C source (shipped source) -HOSTCFLAGS_parse.tab.o := -Wno-uninitialized -I$(src) +HOSTCFLAGS_parse.tab.o := -I$(src) +HOSTCFLAGS_lex.lex.o := -I$(src) -$(obj)/parse.tab.o: $(obj)/parse.tab.c $(obj)/parse.tab.h - -$(obj)/lex.lex.o: $(obj)/keywords.hash.c -$(obj)/lex.lex.o: $(obj)/parse.tab.c $(obj)/parse.tab.h +# dependencies on generated files need to be listed explicitly +$(obj)/lex.lex.o: $(obj)/keywords.hash.c $(obj)/parse.tab.h
scripts/kconfig/zconf.tab.h_shipped deleted +0 -101
101 lines not on this page · raw message
Signature · 1 line
1.7.3.4.574.g608b.dirty
Quoted 11 lines · Arnaud Lacombe
Hi Michal,
Here is some update concerning the parser generation merge. I do not repost the whole serie as it may be overkill. You can find the latest branch at:
git://github.com/lacombar/linux-2.6.gitkbuild-implicit-parser-ruleSo let't get it done the safe way...
Changes since v4:
[...]
Hi, I found now what my problem with genksyms was. I use O= and you removed the -I$(src) for the lexer (which is a generated file, but needs genksyms.h from the source directory). With the following patch, everything should work again (test builds still running, but they built genksyms already):
scripts/genksyms/Makefile +1 -0
@@ -6,6 +6,7 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o # -I needed for generated C source (shipped source) HOSTCFLAGS_parse.tab.o := -Wno-uninitialized -I$(src) +HOSTCFLAGS_lex.lex.o := -I$(src) $(obj)/parse.tab.o: $(obj)/parse.tab.c $(obj)/parse.tab.h
Michal
Hi,
Quoted 14 lines · Michal Marek
Quoted 11 lines · Arnaud Lacombe
Hi Michal,
Here is some update concerning the parser generation merge. I do not repost the whole serie as it may be overkill. You can find the latest branch at:
git://github.com/lacombar/linux-2.6.gitkbuild-implicit-parser-ruleSo let't get it done the safe way...
Changes since v4:
[...]
Quoted 6 lines
Hi, I found now what my problem with genksyms was. I use O= and you removed the -I$(src) for the lexer (which is a generated file, but needs
genksyms.hfrom the source directory). With the following patch, everything should work again (test builds still running, but they built genksyms already):
yes, I spotted that yesterday, this is fixed in v5.
- Arnaud
Quoted 14 lines
scripts/genksyms/Makefile +1
-0@@ -6,6 +6,7 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o # -I needed for generated C source (shipped source) HOSTCFLAGS_parse.tab.o := -Wno-uninitialized -I$(src) +HOSTCFLAGS_lex.lex.o := -I$(src)$(obj)/parse.tab.o: $(obj)/parse.tab.c $(obj)/parse.tab.h
Michal
Dne 8.6.2011 18:11, Arnaud Lacombe napsal(a):
Quoted 17 lines
Hi,
Quoted 14 lines · Michal Marek
Quoted 11 lines · Arnaud Lacombe
Hi Michal,
Here is some update concerning the parser generation merge. I do not repost the whole serie as it may be overkill. You can find the latest branch at:
git://github.com/lacombar/linux-2.6.gitkbuild-implicit-parser-ruleSo let't get it done the safe way...
Changes since v4:
[...]
Quoted 7 lines
Quoted 6 lines
Hi, I found now what my problem with genksyms was. I use O= and you removed the -I$(src) for the lexer (which is a generated file, but needs
genksyms.hfrom the source directory). With the following patch, everything should work again (test builds still running, but they built genksyms already):yes, I spotted that yesterday, this is fixed in v5.
Then please push it to github :)
$ git ls-remote git://github.com/lacombar/linux-2.6.git | grep kbuild-implicit-parser-rule a483784894fcbba51be58afc4a2ff1373ed96ca0 refs/heads/kbuild-implicit-parser-rule $ git show a483784894fcbba51be58afc4a2ff1373ed96ca0:scripts/genksyms/Makefile | grep FLAGS HOSTCFLAGS_parse.tab.o := -Wno-uninitialized -I$(src) $
Michal
Hi,
Quoted 24 lines · Michal Marek
Dne 8.6.2011 18:11, Arnaud Lacombe napsal(a):
Quoted 23 lines
Hi,
Quoted 20 lines · Michal Marek
Quoted 11 lines · Arnaud Lacombe
Hi Michal,
Here is some update concerning the parser generation merge. I do not repost the whole serie as it may be overkill. You can find the latest branch at:
git://github.com/lacombar/linux-2.6.gitkbuild-implicit-parser-ruleSo let't get it done the safe way...
Changes since v4:
[...]Hi, I found now what my problem with genksyms was. I use O= and you removed the -I$(src) for the lexer (which is a generated file, but needs
genksyms.hfrom the source directory). With the following patch, everything should work again (test builds still running, but they built genksyms already):
Quoted 4 lines
Quoted 1 line
yes, I spotted that yesterday, this is fixed in v5.
Then please push it to github :)
@#$... I should stop sending stuff at 1 a.m. This is now fixed. New head is c51572047d18641be2350d188f9493f6a39f6b26.
Btw, as a small remainder, none of the patch are Signed-off. When you'll be happy with the branch, I'll post the serie for final review.
- Arnaud
Quoted 12 lines
$ git ls-remote git://github.com/lacombar/linux-2.6.git | grep kbuild-implicit-parser-rule a483784894fcbba51be58afc4a2ff1373ed96ca0 refs/heads/kbuild-implicit-parser-rule $ git show a483784894fcbba51be58afc4a2ff1373ed96ca0:scripts/genksyms/Makefile | grep FLAGS HOSTCFLAGS_parse.tab.o := -Wno-uninitialized -I$(src) $Michal
Quoted 5 lines · Arnaud Lacombe
@#$... I should stop sending stuff at 1 a.m. This is now fixed. New head is
c51572047d18641be2350d188f9493f6a39f6b26.Btw, as a small remainder, none of the patch are Signed-off. When you'll be happy with the branch, I'll post the serie for final review.
Thanks, this looks perfect now, please add your signoffs and push once more.
Michal
Hi,
Quoted 10 lines · Michal Marek
Quoted 6 lines · Arnaud Lacombe
@#$... I should stop sending stuff at 1 a.m. This is now fixed. New head is
c51572047d18641be2350d188f9493f6a39f6b26.Btw, as a small remainder, none of the patch are Signed-off. When you'll be happy with the branch, I'll post the serie for final review.
Thanks, this looks perfect now, please add your signoffs and push once more.
Done,
The following changes since commit 55922c9d1b84b89cb946c777fddccb3247e7df2c:
Linux 3.0-rc1 (2011-05-29 17:43:36 -0700)
are available in the git repository at:
[email protected]:lacombar/linux-2.6.git kbuild-implicit-parser-rule
Arnaud Lacombe (14):
kbuild: add `baseprereq'
kbuild: add implicit rules for parser generation
kbuild: simplify the %_shipped rule
genksyms: pass hash and lookup functions name and target
language though the input file
genksyms: drop -Wno-uninitialized from HOSTCFLAGS_parse.tab.o
genksyms: migrate parser to implicit rules
genksym: regen parser
kconfig: constify `kconf_id_lookup'
kconfig: kill no longer needed reference to YYDEBUG kconfig/zconf.l: do not ask to generate backup
kconfig: migrate parser to implicit rules
kconfig: regen parser
dtc: migrate parser to implicit rules
dtc: regen parser
scripts/Kbuild.include | 4 +
scripts/Makefile.lib | 40 +++-
scripts/dtc/Makefile | 28 +--
scripts/dtc/dtc-lexer.lex.c_shipped | 59 +---
scripts/dtc/dtc-parser.tab.c_shipped | 116 +------
scripts/dtc/dtc-parser.tab.h_shipped | 11 +-
scripts/genksyms/.gitignore | 7 +-
scripts/genksyms/Makefile | 48 +---
scripts/genksyms/keywords.gperf | 3 +
...{keywords.c_shipped => keywords.hash.c_shipped} | 96 +++---
scripts/genksyms/lex.l | 4 +-
.../genksyms/{lex.c_shipped => lex.lex.c_shipped} | 359 +-------------------
.../{parse.c_shipped => parse.tab.c_shipped} | 198 +----------
.../{parse.h_shipped => parse.tab.h_shipped} | 7 +-
scripts/kconfig/.gitignore | 2 +-
scripts/kconfig/Makefile | 34 +--
scripts/kconfig/lkc.h | 2 -
scripts/kconfig/zconf.gperf | 2 +-
scripts/kconfig/zconf.hash.c_shipped | 273 +++++++++-------
scripts/kconfig/zconf.l | 8 +-
.../{lex.zconf.c_shipped => zconf.lex.c_shipped} | 26 +--
scripts/kconfig/zconf.tab.c_shipped | 68 ++--
scripts/kconfig/zconf.y | 18 +-
23 files changed, 370 insertions(+), 1043 deletions(-)
rename scripts/genksyms/{keywords.c_shipped => keywords.hash.c_shipped} (94%)
rename scripts/genksyms/{lex.c_shipped => lex.lex.c_shipped} (89%)
rename scripts/genksyms/{parse.c_shipped => parse.tab.c_shipped} (92%)
rename scripts/genksyms/{parse.h_shipped => parse.tab.h_shipped} (96%)
rename scripts/kconfig/{lex.zconf.c_shipped => zconf.lex.c_shipped} (98%)- Arnaud
Quoted 13 lines · Arnaud Lacombe
Hi,
Quoted 10 lines · Michal Marek
Quoted 6 lines · Arnaud Lacombe
@#$... I should stop sending stuff at 1 a.m. This is now fixed. New head is
c51572047d18641be2350d188f9493f6a39f6b26.Btw, as a small remainder, none of the patch are Signed-off. When you'll be happy with the branch, I'll post the serie for final review.
Thanks, this looks perfect now, please add your signoffs and push once more.
Quoted 8 lines
Done,
The following changes since commit
55922c9d1b84b89cb946c777fddccb3247e7df2c:Linux 3.0-rc1 (2011-05-29 17:43:36 -0700)
are available in the git repository at:
[email protected]:lacombar/linux-2.6.git kbuild-implicit-parser-rule
Merged now, sorry for the delay.
Michal