Skip to content

Commit

Permalink
fixdep: do not parse *.rlib, *.rmeta, *.so
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
  • Loading branch information
masahir0y committed Jan 8, 2023
1 parent da2b86d commit b8ae458
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/basic/fixdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ static int is_ignored_file(const char *s, int len)
str_ends_with(s, len, "include/generated/autoksyms.h");
}

/* Do not parse these files */
static int is_no_parse_file(const char *s, int len)
{
/* rustc may list binary files in dep-info */
return str_ends_with(s, len, ".rlib") ||
str_ends_with(s, len, ".rmeta") ||
str_ends_with(s, len, ".so");
}

/*
* Important: The below generated source_foo.o and deps_foo.o variable
* assignments are parsed not only by make, but also by the rather simple
Expand Down Expand Up @@ -382,7 +391,7 @@ static void parse_dep_file(char *p, const char *target)
need_parse = true;
}

if (need_parse) {
if (need_parse && !is_no_parse_file(p, q - p)) {
void *buf;

buf = read_file(p);
Expand Down

0 comments on commit b8ae458

Please sign in to comment.