93c656de | 07-Jan-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
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 CON
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.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Tested-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
faa91c47 | 07-Jan-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
fixdep: avoid parsing the same file over again
The dep files (*.d files) emitted by C compilers usually contain the deduplicated list of included files.
One exceptional case is when a header is inc
fixdep: avoid parsing the same file over again
The dep files (*.d files) emitted by C compilers usually contain the deduplicated list of included files.
One exceptional case is when a header is included by the -include command line option, and also by #include directive.
For example, the top Makefile adds the command line option, "-include $(srctree)/include/linux/kconfig.h". You do not need to include <linux/kconfig.h> in every source file.
In fact, include/linux/kconfig.h is listed twice in many .*.cmd files due to include/linux/xarray.h having "#include <linux/kconfig.h>". I did not fix that since it is a small redundancy.
However, this is more annoying for rustc. rustc emits the dependency for each emission type.
For example, cmd_rustc_library emits dep-info, obj, and metadata. So, the emitted *.d file contains the dependency for those 3 targets, which makes fixdep parse the same file 3 times.
$ grep rust/alloc/raw_vec.rs rust/.alloc.o.cmd rust/alloc/raw_vec.rs \ rust/alloc/raw_vec.rs \ rust/alloc/raw_vec.rs \
To skip the second parsing, this commit adds a hash table for parsed files, just like we did for CONFIG options.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Miguel Ojeda <ojeda@kernel.org> Tested-by: Miguel Ojeda <ojeda@kernel.org> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
show more ...
|
bc6df812 | 07-Jan-2023 |
Masahiro Yamada <masahiroy@kernel.org> |
fixdep: parse Makefile more correctly to handle comments etc.
fixdep parses dependency files (*.d) emitted by the compiler.
*.d files are Makefiles describing the dependencies of the main source fi
fixdep: parse Makefile more correctly to handle comments etc.
fixdep parses dependency files (*.d) emitted by the compiler.
*.d files are Makefiles describing the dependencies of the main source file.
fixdep understands minimal Makefile syntax. It works well enough for GCC and Clang, but not for rustc.
This commit improves the parser a little more for better processing comments, escape sequences, etc.
My main motivation is to drop comments. rustc may output comments (e.g. env-dep). Currentyly, rustc build rules invoke sed to remove comments, but it is more efficient to do it in fixdep.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Miguel Ojeda <ojeda@kernel.org> Tested-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
3f9070a6 | 18-Feb-2020 |
Masahiro Yamada <masahiroy@kernel.org> |
fixdep: remove redundant null character check
If *q is '\0', the condition (isalnum(*q) || *q == '_') is false anyway.
It is redundant to ensure non-zero *q.
Signed-off-by: Masahiro Yamada <masahi
fixdep: remove redundant null character check
If *q is '\0', the condition (isalnum(*q) || *q == '_') is false anyway.
It is redundant to ensure non-zero *q.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
show more ...
|
638e69cf | 28-Feb-2018 |
Rasmus Villemoes <linux@rasmusvillemoes.dk> |
fixdep: do not ignore kconfig.h
kconfig.h was excluded from consideration by fixdep by 6a5be57f0f00 (fixdep: fix extraneous dependencies) to avoid some false positive hits
(1) include/config/.h (2)
fixdep: do not ignore kconfig.h
kconfig.h was excluded from consideration by fixdep by 6a5be57f0f00 (fixdep: fix extraneous dependencies) to avoid some false positive hits
(1) include/config/.h (2) include/config/h.h (3) include/config/foo.h
(1) occurred because kconfig.h contains the string CONFIG_ in a comment. However, since dee81e988674 (fixdep: faster CONFIG_ search), we have a check that the part after CONFIG_ is non-empty, so this does not happen anymore (and CONFIG_ appears by itself elsewhere, so that check is worthwhile).
(2) comes from the include guard, __LINUX_KCONFIG_H. But with the previous patch, we no longer match that either.
That leaves (3), which amounts to one [1] false dependency (aka stat() call done by make), which I think we can live with:
We've already had one case [2] where the lack of include/linux/kconfig.h in the .o.cmd file caused a missing rebuild, and while I originally thought we should just put kconfig.h in the dependency list without parsing it for the CONFIG_ pattern, we actually do have some real CONFIG_ symbols mentioned in it, and one can imagine some translation unit that just does '#ifdef __BIG_ENDIAN' but doesn't through some other header actually depend on CONFIG_CPU_BIG_ENDIAN - so changing the target endianness could end up rebuilding the world, minus that small TU. Quoting Linus,
... when missing dependencies cause a missed re-compile, the resulting bugs can be _really_ subtle.
[1] well, two, we now also have CONFIG_BOOGER/booger.h - we could change that to FOO if we care
[2] https://lkml.org/lkml/2018/2/22/838
Cc: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
show more ...
|