diff options
| author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-11-29 20:05:26 -0500 |
|---|---|---|
| committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-12-01 09:13:14 -0500 |
| commit | bbda5ec671d3fe62faefa1cab7270aa586042a4b (patch) | |
| tree | a1d375f74ad25efd2797bffaadfb0dc5fc1f65fe /scripts/basic | |
| parent | ee3e46b7efd2954479f87030d31fda3c22bbc763 (diff) | |
kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS
My main motivation of this commit is to clean up scripts/Kbuild.include
and scripts/Makefile.build.
Currently, CONFIG_TRIM_UNUSED_KSYMS works with a tricky gimmick;
possibly exported symbols are detected by letting $(CPP) replace
EXPORT_SYMBOL* with a special string '=== __KSYM_*===', which is
post-processed by sed, and passed to fixdep. The extra preprocessing
is costly, and hacking cmd_and_fixdep is ugly.
I came up with a new way to find exported symbols; insert a dummy
symbol __ksym_marker_* to each potentially exported symbol. Those
dummy symbols are picked up by $(NM), post-processed by sed, then
appended to .*.cmd files. I collected the post-process part to a
new shell script scripts/gen_ksymdeps.sh for readability. The dummy
symbols are put into the .discard.* section so that the linker
script rips them off the final vmlinux or modules.
A nice side-effect is building with CONFIG_TRIM_UNUSED_KSYMS will
be much faster.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Diffstat (limited to 'scripts/basic')
| -rw-r--r-- | scripts/basic/fixdep.c | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 850966f3d602..facbd603adf6 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c | |||
| @@ -105,8 +105,7 @@ | |||
| 105 | 105 | ||
| 106 | static void usage(void) | 106 | static void usage(void) |
| 107 | { | 107 | { |
| 108 | fprintf(stderr, "Usage: fixdep [-e] <depfile> <target> <cmdline>\n"); | 108 | fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n"); |
| 109 | fprintf(stderr, " -e insert extra dependencies given on stdin\n"); | ||
| 110 | exit(1); | 109 | exit(1); |
| 111 | } | 110 | } |
| 112 | 111 | ||
| @@ -131,21 +130,6 @@ static void print_dep(const char *m, int slen, const char *dir) | |||
| 131 | printf(".h) \\\n"); | 130 | printf(".h) \\\n"); |
| 132 | } | 131 | } |
| 133 | 132 | ||
| 134 | static void do_extra_deps(void) | ||
| 135 | { | ||
| 136 | char buf[80]; | ||
| 137 | |||
| 138 | while (fgets(buf, sizeof(buf), stdin)) { | ||
| 139 | int len = strlen(buf); | ||
| 140 | |||
| 141 | if (len < 2 || buf[len - 1] != '\n') { | ||
| 142 | fprintf(stderr, "fixdep: bad data on stdin\n"); | ||
| 143 | exit(1); | ||
| 144 | } | ||
| 145 | print_dep(buf, len - 1, "include/ksym"); | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 | struct item { | 133 | struct item { |
| 150 | struct item *next; | 134 | struct item *next; |
| 151 | unsigned int len; | 135 | unsigned int len; |
| @@ -293,7 +277,7 @@ static int is_ignored_file(const char *s, int len) | |||
| 293 | * assignments are parsed not only by make, but also by the rather simple | 277 | * assignments are parsed not only by make, but also by the rather simple |
| 294 | * parser in scripts/mod/sumversion.c. | 278 | * parser in scripts/mod/sumversion.c. |
| 295 | */ | 279 | */ |
| 296 | static void parse_dep_file(char *m, const char *target, int insert_extra_deps) | 280 | static void parse_dep_file(char *m, const char *target) |
| 297 | { | 281 | { |
| 298 | char *p; | 282 | char *p; |
| 299 | int is_last, is_target; | 283 | int is_last, is_target; |
| @@ -369,9 +353,6 @@ static void parse_dep_file(char *m, const char *target, int insert_extra_deps) | |||
| 369 | exit(1); | 353 | exit(1); |
| 370 | } | 354 | } |
| 371 | 355 | ||
| 372 | if (insert_extra_deps) | ||
| 373 | do_extra_deps(); | ||
| 374 | |||
| 375 | printf("\n%s: $(deps_%s)\n\n", target, target); | 356 | printf("\n%s: $(deps_%s)\n\n", target, target); |
| 376 | printf("$(deps_%s):\n", target); | 357 | printf("$(deps_%s):\n", target); |
| 377 | } | 358 | } |
| @@ -379,13 +360,9 @@ static void parse_dep_file(char *m, const char *target, int insert_extra_deps) | |||
| 379 | int main(int argc, char *argv[]) | 360 | int main(int argc, char *argv[]) |
| 380 | { | 361 | { |
| 381 | const char *depfile, *target, *cmdline; | 362 | const char *depfile, *target, *cmdline; |
| 382 | int insert_extra_deps = 0; | ||
| 383 | void *buf; | 363 | void *buf; |
| 384 | 364 | ||
| 385 | if (argc == 5 && !strcmp(argv[1], "-e")) { | 365 | if (argc != 4) |
| 386 | insert_extra_deps = 1; | ||
| 387 | argv++; | ||
| 388 | } else if (argc != 4) | ||
| 389 | usage(); | 366 | usage(); |
| 390 | 367 | ||
| 391 | depfile = argv[1]; | 368 | depfile = argv[1]; |
| @@ -395,7 +372,7 @@ int main(int argc, char *argv[]) | |||
| 395 | printf("cmd_%s := %s\n\n", target, cmdline); | 372 | printf("cmd_%s := %s\n\n", target, cmdline); |
| 396 | 373 | ||
| 397 | buf = read_file(depfile); | 374 | buf = read_file(depfile); |
| 398 | parse_dep_file(buf, target, insert_extra_deps); | 375 | parse_dep_file(buf, target); |
| 399 | free(buf); | 376 | free(buf); |
| 400 | 377 | ||
| 401 | return 0; | 378 | return 0; |
