selftests: Use optional USERCFLAGS and USERLDFLAGS
authorMickaël Salaün <mic@digikod.net>
Fri, 9 Sep 2022 10:39:01 +0000 (12:39 +0200)
committerShuah Khan <skhan@linuxfoundation.org>
Thu, 20 Oct 2022 14:55:40 +0000 (08:55 -0600)
This change enables to extend CFLAGS and LDFLAGS from command line, e.g.
to extend compiler checks: make USERCFLAGS=-Werror USERLDFLAGS=-static

USERCFLAGS and USERLDFLAGS are documented in
Documentation/kbuild/makefiles.rst and Documentation/kbuild/kbuild.rst

This should be backported (down to 5.10) to improve previous kernel
versions testing as well.

Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: stable@vger.kernel.org
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Link: https://lore.kernel.org/r/20220909103901.1503436-1-mic@digikod.net
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/lib.mk

index 9d4cb94..f419683 100644 (file)
@@ -123,6 +123,11 @@ endef
 clean:
        $(CLEAN)
 
+# Enables to extend CFLAGS and LDFLAGS from command line, e.g.
+# make USERCFLAGS=-Werror USERLDFLAGS=-static
+CFLAGS += $(USERCFLAGS)
+LDFLAGS += $(USERLDFLAGS)
+
 # When make O= with kselftest target from main level
 # the following aren't defined.
 #