diff mbox series

[1/2] selftests/lib.mk: handle both LLVM=1 and CC=clang builds

Message ID 20240529020842.127275-2-jhubbard@nvidia.com (mailing list archive)
State New
Headers show
Series selftests/lib.mk: LLVM=1, CC=clang, and warnings | expand

Commit Message

John Hubbard May 29, 2024, 2:08 a.m. UTC
The kselftests may be built in a couple different ways:
    make LLVM=1
    make CC=clang

In order to handle both cases, set LLVM=1 if CC=clang. That way,the rest
of lib.mk, and any Makefiles that include lib.mk, can base decisions
solely on whether or not LLVM is set.

Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 tools/testing/selftests/lib.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Muhammad Usama Anjum May 30, 2024, 5:04 a.m. UTC | #1
On 5/29/24 7:08 AM, John Hubbard wrote:
> The kselftests may be built in a couple different ways:
>     make LLVM=1
>     make CC=clang
> 
> In order to handle both cases, set LLVM=1 if CC=clang. That way,the rest
> of lib.mk, and any Makefiles that include lib.mk, can base decisions
> solely on whether or not LLVM is set.
> 
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> 
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
LGTM

Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> ---
>  tools/testing/selftests/lib.mk | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 429535816dbd..2902787b89b2 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -1,5 +1,17 @@
>  # This mimics the top-level Makefile. We do it explicitly here so that this
>  # Makefile can operate with or without the kbuild infrastructure.
> +
> +# The kselftests may be built in a couple different ways:
> +#     make LLVM=1
> +#     make CC=clang
> +#
> +# In order to handle both cases, set LLVM=1 if CC=clang. That way,the rest of
> +# lib.mk, and any Makefiles that include lib.mk, can base decisions solely on
> +# whether or not LLVM is set.
> +ifeq ($(CC),clang)
> +    LLVM := 1
> +endif
> +
>  ifneq ($(LLVM),)
>  ifneq ($(filter %/,$(LLVM)),)
>  LLVM_PREFIX := $(LLVM)
diff mbox series

Patch

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 429535816dbd..2902787b89b2 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -1,5 +1,17 @@ 
 # This mimics the top-level Makefile. We do it explicitly here so that this
 # Makefile can operate with or without the kbuild infrastructure.
+
+# The kselftests may be built in a couple different ways:
+#     make LLVM=1
+#     make CC=clang
+#
+# In order to handle both cases, set LLVM=1 if CC=clang. That way,the rest of
+# lib.mk, and any Makefiles that include lib.mk, can base decisions solely on
+# whether or not LLVM is set.
+ifeq ($(CC),clang)
+    LLVM := 1
+endif
+
 ifneq ($(LLVM),)
 ifneq ($(filter %/,$(LLVM)),)
 LLVM_PREFIX := $(LLVM)