1 From 3892606be20bea6f1144b0c81836e9c555f0b53b Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Thu, 8 Oct 2020 15:26:21 +0300
4 Subject: selftests: filter kselftest headers from command in lib.mk
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Tommi Rantala <tommi.t.rantala@nokia.com>
11 [ Upstream commit f825d3f7ed9305e7dd0a3e0a74673a4257d0cc53 ]
13 Commit 1056d3d2c97e ("selftests: enforce local header dependency in
14 lib.mk") added header dependency to the rule, but as the rule uses $^,
15 the headers are added to the compiler command line.
17 This can cause unexpected precompiled header files being generated when
20 $ echo { >> openat2_test.c
23 gcc -Wall -O2 -g -fsanitize=address -fsanitize=undefined openat2_test.c
24 tools/testing/selftests/kselftest_harness.h tools/testing/selftests/kselftest.h helpers.c
25 -o tools/testing/selftests/openat2/openat2_test
26 openat2_test.c:313:1: error: expected identifier or ‘(’ before ‘{’ token
29 make: *** [../lib.mk:140: tools/testing/selftests/openat2/openat2_test] Error 1
32 openat2_test: GCC precompiled header (version 014) for C
33 openat2_test.c: C source, ASCII text
35 Fix it by filtering out the headers, so that we'll only pass the actual
36 *.c files in the compiler command line.
38 Fixes: 1056d3d2c97e ("selftests: enforce local header dependency in lib.mk")
39 Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
40 Acked-by: Kees Cook <keescook@chromium.org>
41 Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>
42 Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
43 Signed-off-by: Sasha Levin <sashal@kernel.org>
45 tools/testing/selftests/lib.mk | 2 +-
46 1 file changed, 1 insertion(+), 1 deletion(-)
48 diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
49 index 7a17ea8157367..66f3317dc3654 100644
50 --- a/tools/testing/selftests/lib.mk
51 +++ b/tools/testing/selftests/lib.mk
52 @@ -137,7 +137,7 @@ endif
53 ifeq ($(OVERRIDE_TARGETS),)
54 LOCAL_HDRS := $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
55 $(OUTPUT)/%:%.c $(LOCAL_HDRS)
56 - $(LINK.c) $^ $(LDLIBS) -o $@
57 + $(LINK.c) $(filter-out $(LOCAL_HDRS),$^) $(LDLIBS) -o $@