diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2024-07-27 17:02:36 +0200 |
---|---|---|
committer | Kees Cook <kees@kernel.org> | 2024-08-15 18:26:02 +0200 |
commit | 4e9903b0861c9df3464b82db4a7025863bac1897 (patch) | |
tree | 9aeb5aad112b45f92de800545c8ca05013466207 /scripts/remove-stale-files | |
parent | Linux 6.11-rc2 (diff) | |
download | linux-4e9903b0861c9df3464b82db4a7025863bac1897.tar.xz linux-4e9903b0861c9df3464b82db4a7025863bac1897.zip |
fortify: refactor test_fortify Makefile to fix some build problems
There are some issues in the test_fortify Makefile code.
Problem 1: cc-disable-warning invokes compiler dozens of times
To see how many times the cc-disable-warning is evaluated, change
this code:
$(call cc-disable-warning,fortify-source)
to:
$(call cc-disable-warning,$(shell touch /tmp/fortify-$$$$)fortify-source)
Then, build the kernel with CONFIG_FORTIFY_SOURCE=y. You will see a
large number of '/tmp/fortify-<PID>' files created:
$ ls -1 /tmp/fortify-* | wc
80 80 1600
This means the compiler was invoked 80 times just for checking the
-Wno-fortify-source flag support.
$(call cc-disable-warning,fortify-source) should be added to a simple
variable instead of a recursive variable.
Problem 2: do not recompile string.o when the test code is updated
The test cases are independent of the kernel. However, when the test
code is updated, $(obj)/string.o is rebuilt and vmlinux is relinked
due to this dependency:
$(obj)/string.o: $(obj)/$(TEST_FORTIFY_LOG)
always-y is suitable for building the log files.
Problem 3: redundant code
clean-files += $(addsuffix .o, $(TEST_FORTIFY_LOGS))
... is unneeded because the top Makefile globally cleans *.o files.
This commit fixes these issues and makes the code readable.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Link: https://lore.kernel.org/r/20240727150302.1823750-2-masahiroy@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'scripts/remove-stale-files')
-rwxr-xr-x | scripts/remove-stale-files | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/scripts/remove-stale-files b/scripts/remove-stale-files index f38d26b78c2a..8fc55a749ccc 100755 --- a/scripts/remove-stale-files +++ b/scripts/remove-stale-files @@ -21,3 +21,5 @@ set -e # then will be really dead and removed from the code base entirely. rm -f *.spec + +rm -f lib/test_fortify.log |