[6/6] fixdep: do not parse *.so, *.rmeta, *.rlib

Message ID 20221231064203.1623793-7-masahiroy@kernel.org
State New
Headers
Series kbuild: fix dep-file processing for rust |

Commit Message

Masahiro Yamada Dec. 31, 2022, 6:42 a.m. UTC
  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 *.so, *.rmeta, *rlib to dep-info. fixdep needs them in
the dependency, but there is no point to parse such binary files.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/basic/fixdep.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
  

Comments

Miguel Ojeda Jan. 3, 2023, 8:46 p.m. UTC | #1
On Sat, Dec 31, 2022 at 7:42 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> rustc outputs *.so, *.rmeta, *rlib to dep-info. fixdep needs them in
> the dependency, but there is no point to parse such binary files.

Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>

Cheers,
Miguel
  

Patch

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index cc8f6d34c2ca..b70885116ed2 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -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 output binary files into 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
@@ -378,7 +387,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);