linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: propagate CC to selftest submakes
@ 2020-12-03 22:10 Andrew Delgadillo
  2020-12-10 23:07 ` Nick Desaulniers
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Delgadillo @ 2020-12-03 22:10 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Nathan Chancellor, Nick Desaulniers, linux-kselftest,
	linux-kernel, clang-built-linux, Andrew Delgadillo

lib.mk defaults to gcc when CC is not set. When building selftests
as part of a kernel compilation, MAKEFLAGS is cleared to allow implicit
build rules to be used. This has the side-effect of clearing the CC
variable, which will cause selftests to be built with gcc regardless of
if we are using gcc or clang. To remedy this, propagate the CC variable
when clearing makeflags to ensure the correct compiler is used.

Signed-off-by: Andrew Delgadillo <adelg@google.com>
---
 tools/testing/selftests/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index d9c283503159..a4dd6d7e8276 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -90,10 +90,12 @@ FORCE_TARGETS ?=
 
 # Clear LDFLAGS and MAKEFLAGS when implicit rules are missing.  This provides
 # implicit rules to sub-test Makefiles which avoids build failures in test
-# Makefile that don't have explicit build rules.
+# Makefile that don't have explicit build rules. Since lib.mk defaults to
+# using gcc for compilation when the CC variable is not set, we propagate the
+# CC variable so if clang is being used, selftests will build with clang.
 ifeq (,$(LINK.c))
 override LDFLAGS =
-override MAKEFLAGS =
+override MAKEFLAGS = CC=$(CC)
 endif
 
 # Append kselftest to KBUILD_OUTPUT and O to avoid cluttering
-- 
2.29.2.576.ga3fc446d84-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-11 21:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 22:10 [PATCH] selftests: propagate CC to selftest submakes Andrew Delgadillo
2020-12-10 23:07 ` Nick Desaulniers
2020-12-11  0:10   ` Andrew Delgadillo
2020-12-11  0:31     ` Shuah Khan
2020-12-11 20:27       ` Andrew Delgadillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).