Skip to content

Commit f825d3f

Browse files
rantalashuahkh
authored andcommitted
selftests: filter kselftest headers from command in lib.mk
Commit 1056d3d ("selftests: enforce local header dependency in lib.mk") added header dependency to the rule, but as the rule uses $^, the headers are added to the compiler command line. This can cause unexpected precompiled header files being generated when compilation fails: $ echo { >> openat2_test.c $ make gcc -Wall -O2 -g -fsanitize=address -fsanitize=undefined openat2_test.c tools/testing/selftests/kselftest_harness.h tools/testing/selftests/kselftest.h helpers.c -o tools/testing/selftests/openat2/openat2_test openat2_test.c:313:1: error: expected identifier or ‘(’ before ‘{’ token 313 | { | ^ make: *** [../lib.mk:140: tools/testing/selftests/openat2/openat2_test] Error 1 $ file openat2_test* openat2_test: GCC precompiled header (version 014) for C openat2_test.c: C source, ASCII text Fix it by filtering out the headers, so that we'll only pass the actual *.c files in the compiler command line. Fixes: 1056d3d ("selftests: enforce local header dependency in lib.mk") Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com> Acked-by: Kees Cook <keescook@chromium.org> Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent e3e4031 commit f825d3f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/testing/selftests/lib.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ endif
136136
ifeq ($(OVERRIDE_TARGETS),)
137137
LOCAL_HDRS := $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
138138
$(OUTPUT)/%:%.c $(LOCAL_HDRS)
139-
$(LINK.c) $^ $(LDLIBS) -o $@
139+
$(LINK.c) $(filter-out $(LOCAL_HDRS),$^) $(LDLIBS) -o $@
140140

141141
$(OUTPUT)/%.o:%.S
142142
$(COMPILE.S) $^ -o $@

0 commit comments

Comments
 (0)