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
250250 str_ends_with(s, len, "include/generated/autoksyms.h");
251251 }
252252
253+/* Do not parse these files */
254+static 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+
253262 /*
254263 * Important: The below generated source_foo.o and deps_foo.o variable
255264 * 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
382391 need_parse = true;
383392 }
384393
385− if (need_parse) {
394+ if (need_parse && !is_no_parse_file(p, q - p)) {
386395 void *buf;
387396
388397 buf = read_file(p);