History

fixdep: do not parse *.rlib, *.rmeta, *.so

fixdep is designed only for parsing text files. read_file() appends a terminating null byte ('\0') and parse_config_file() calls strstr() to search for CONFIG options. rustc outputs *.rlib, *.rmeta, *.so to dep-info. fixdep needs them in the dependency, but there is no point in parsing such binary files.

Masahiro Yamada committed 3 years ago

Commit 93c656d1 parent faa91c41 file · +10 −1Browse files

Showing the changes to scripts/basic (1 of 1 file). Show all

Unified · Split

scripts/basic/fixdep.c+10−1
@@ -250,6 +250,15 @@ static int is_ignored_file(const char *s, int len) · 249 unmodified lines
250 str_ends_with(s, len, "include/generated/autoksyms.h");250 str_ends_with(s, len, "include/generated/autoksyms.h");
251}251}
252 252
253/* Do not parse these files */
254static int is_no_parse_file(const char *s, int len)
255{
256 /* rustc may list binary files in dep-info */
257 return str_ends_with(s, len, ".rlib") ||
258 str_ends_with(s, len, ".rmeta") ||
259 str_ends_with(s, len, ".so");
260}
261
253/*262/*
254 * Important: The below generated source_foo.o and deps_foo.o variable263 * Important: The below generated source_foo.o and deps_foo.o variable
255 * assignments are parsed not only by make, but also by the rather simple264 * assignments are parsed not only by make, but also by the rather simple
@@ -382,7 +391,7 @@ static void parse_dep_file(char *p, const char *target) · 126 unmodified lines
382 need_parse = true;391 need_parse = true;
383 }392 }
384 393
385 if (need_parse) {394 if (need_parse && !is_no_parse_file(p, q - p)) {
386 void *buf;395 void *buf;
387 396
388 buf = read_file(p);397 buf = read_file(p);