* [PATCH 0/2] selftests/lib.mk: LLVM=1, CC=clang, and warnings
@ 2024-05-29 2:08 John Hubbard
2024-05-29 2:08 ` [PATCH 1/2] selftests/lib.mk: handle both LLVM=1 and CC=clang builds John Hubbard
2024-05-29 2:08 ` [PATCH 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores John Hubbard
0 siblings, 2 replies; 7+ messages in thread
From: John Hubbard @ 2024-05-29 2:08 UTC (permalink / raw)
To: Shuah Khan
Cc: Beau Belgrave, Steven Rostedt, Mark Brown, Naresh Kamboju,
Nick Desaulniers, Justin Stitt, Bill Wendling, sunliming,
Masami Hiramatsu, Valentin Obst, linux-kselftest, LKML, llvm,
John Hubbard
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.
Then, build upon that to disable a pair of clang warnings that are
already silenced on gcc.
Doing it this way is much better than the piecemeal approach that I
started with in [1] and [2]. Thanks to Nathan Chancellor for the patch
reviews that led to this approach.
[1] https://lore.kernel.org/20240527214704.300444-1-jhubbard@nvidia.com
[2] https://lore.kernel.org/20240527213641.299458-1-jhubbard@nvidia.com
John Hubbard (2):
selftests/lib.mk: handle both LLVM=1 and CC=clang builds
selftests/lib.mk: silence some clang warnings that gcc already ignores
tools/testing/selftests/lib.mk | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
base-commit: e0cce98fe279b64f4a7d81b7f5c3a23d80b92fbc
--
2.45.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] selftests/lib.mk: handle both LLVM=1 and CC=clang builds
2024-05-29 2:08 [PATCH 0/2] selftests/lib.mk: LLVM=1, CC=clang, and warnings John Hubbard
@ 2024-05-29 2:08 ` John Hubbard
2024-05-30 5:04 ` Muhammad Usama Anjum
2024-05-29 2:08 ` [PATCH 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores John Hubbard
1 sibling, 1 reply; 7+ messages in thread
From: John Hubbard @ 2024-05-29 2:08 UTC (permalink / raw)
To: Shuah Khan
Cc: Beau Belgrave, Steven Rostedt, Mark Brown, Naresh Kamboju,
Nick Desaulniers, Justin Stitt, Bill Wendling, sunliming,
Masami Hiramatsu, Valentin Obst, linux-kselftest, LKML, llvm,
John Hubbard, Nathan Chancellor, Ryan Roberts
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(+)
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)
--
2.45.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 1/2] selftests/lib.mk: handle both LLVM=1 and CC=clang builds
2024-05-29 2:08 ` [PATCH 1/2] selftests/lib.mk: handle both LLVM=1 and CC=clang builds John Hubbard
@ 2024-05-30 5:04 ` Muhammad Usama Anjum
0 siblings, 0 replies; 7+ messages in thread
From: Muhammad Usama Anjum @ 2024-05-30 5:04 UTC (permalink / raw)
To: John Hubbard, Shuah Khan
Cc: Muhammad Usama Anjum, Beau Belgrave, Steven Rostedt, Mark Brown,
Naresh Kamboju, Nick Desaulniers, Justin Stitt, Bill Wendling,
sunliming, Masami Hiramatsu, Valentin Obst, linux-kselftest, LKML,
llvm, Nathan Chancellor, Ryan Roberts
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)
--
BR,
Muhammad Usama Anjum
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores
2024-05-29 2:08 [PATCH 0/2] selftests/lib.mk: LLVM=1, CC=clang, and warnings John Hubbard
2024-05-29 2:08 ` [PATCH 1/2] selftests/lib.mk: handle both LLVM=1 and CC=clang builds John Hubbard
@ 2024-05-29 2:08 ` John Hubbard
2024-05-30 14:25 ` Shuah Khan
1 sibling, 1 reply; 7+ messages in thread
From: John Hubbard @ 2024-05-29 2:08 UTC (permalink / raw)
To: Shuah Khan
Cc: Beau Belgrave, Steven Rostedt, Mark Brown, Naresh Kamboju,
Nick Desaulniers, Justin Stitt, Bill Wendling, sunliming,
Masami Hiramatsu, Valentin Obst, linux-kselftest, LKML, llvm,
John Hubbard, Nathan Chancellor
gcc defaults to silence (off) for the following warnings, but clang
defaults to the opposite. These warnings are not useful for kselftests,
so silence them for the clang builds as well:
-Wno-address-of-packed-member
-Wno-gnu-variable-sized-type-not-at-end
This eliminates warnings for the net/ and user_events/ kselftest
subsystems, in these files:
./net/af_unix/scm_rights.c
./net/timestamping.c
./net/ipsec.c
./user_events/perf_test.c
Cc: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
tools/testing/selftests/lib.mk | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 2902787b89b2..41e879f3f8a2 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -50,6 +50,12 @@ else
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
endif # CROSS_COMPILE
+# gcc defaults to silence (off) for the following warnings, but clang defaults
+# to the opposite. These warnings are not useful for kselftests, so silence them
+# for the clang builds as well.
+CFLAGS += -Wno-address-of-packed-member
+CFLAGS += -Wno-gnu-variable-sized-type-not-at-end
+
CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
else
CC := $(CROSS_COMPILE)gcc
--
2.45.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores
2024-05-29 2:08 ` [PATCH 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores John Hubbard
@ 2024-05-30 14:25 ` Shuah Khan
2024-05-30 19:28 ` John Hubbard
0 siblings, 1 reply; 7+ messages in thread
From: Shuah Khan @ 2024-05-30 14:25 UTC (permalink / raw)
To: John Hubbard, Shuah Khan
Cc: Beau Belgrave, Steven Rostedt, Mark Brown, Naresh Kamboju,
Nick Desaulniers, Justin Stitt, Bill Wendling, sunliming,
Masami Hiramatsu, Valentin Obst, linux-kselftest, LKML, llvm,
Nathan Chancellor, Shuah Khan
On 5/28/24 20:08, John Hubbard wrote:
> gcc defaults to silence (off) for the following warnings, but clang
> defaults to the opposite. These warnings are not useful for kselftests,
> so silence them for the clang builds as well:
Please you add more information on why they aren't useful
for kselftests.
>
> -Wno-address-of-packed-member
> -Wno-gnu-variable-sized-type-not-at-end
>
> This eliminates warnings for the net/ and user_events/ kselftest
> subsystems, in these files:
>
> ./net/af_unix/scm_rights.c
> ./net/timestamping.c
> ./net/ipsec.c
> ./user_events/perf_test.c
>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> ---
> tools/testing/selftests/lib.mk | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 2902787b89b2..41e879f3f8a2 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -50,6 +50,12 @@ else
> CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
> endif # CROSS_COMPILE
>
> +# gcc defaults to silence (off) for the following warnings, but clang defaults
> +# to the opposite. These warnings are not useful for kselftests, so silence them
> +# for the clang builds as well.
> +CFLAGS += -Wno-address-of-packed-member
> +CFLAGS += -Wno-gnu-variable-sized-type-not-at-end
> +
> CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
> else
> CC := $(CROSS_COMPILE)gcc
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores
2024-05-30 14:25 ` Shuah Khan
@ 2024-05-30 19:28 ` John Hubbard
2024-05-31 14:30 ` Shuah Khan
0 siblings, 1 reply; 7+ messages in thread
From: John Hubbard @ 2024-05-30 19:28 UTC (permalink / raw)
To: Shuah Khan, Shuah Khan
Cc: Beau Belgrave, Steven Rostedt, Mark Brown, Naresh Kamboju,
Nick Desaulniers, Justin Stitt, Bill Wendling, sunliming,
Masami Hiramatsu, Valentin Obst, linux-kselftest, LKML, llvm,
Nathan Chancellor
On 5/30/24 7:25 AM, Shuah Khan wrote:
> On 5/28/24 20:08, John Hubbard wrote:
>> gcc defaults to silence (off) for the following warnings, but clang
>> defaults to the opposite. These warnings are not useful for kselftests,
>> so silence them for the clang builds as well:
>
> Please you add more information on why they aren't useful
> for kselftests.
Ah OK. My wording is a little misleading. The warnings are not useful
for the *kernel*, as previous decided by the gcc settings when building
the kernel. And it is only only due to including kernel data structures
in the selftests, that we get the warnings on clang.
So it is not something unique to the selftests. There is nothing that
the selftests' code does that triggers these warnings, other than the
act of including the kernel's data structures.
I can post a v2 to update both the comment and the commit description.
thanks,
--
John Hubbard
NVIDIA
>
>>
>> -Wno-address-of-packed-member
>> -Wno-gnu-variable-sized-type-not-at-end
>>
>> This eliminates warnings for the net/ and user_events/ kselftest
>> subsystems, in these files:
>>
>> ./net/af_unix/scm_rights.c
>> ./net/timestamping.c
>> ./net/ipsec.c
>> ./user_events/perf_test.c
>>
>> Cc: Nathan Chancellor <nathan@kernel.org>
>> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
>> ---
>> tools/testing/selftests/lib.mk | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/tools/testing/selftests/lib.mk
>> b/tools/testing/selftests/lib.mk
>> index 2902787b89b2..41e879f3f8a2 100644
>> --- a/tools/testing/selftests/lib.mk
>> +++ b/tools/testing/selftests/lib.mk
>> @@ -50,6 +50,12 @@ else
>> CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
>> endif # CROSS_COMPILE
>> +# gcc defaults to silence (off) for the following warnings, but clang
>> defaults
>> +# to the opposite. These warnings are not useful for kselftests, so
>> silence them
>> +# for the clang builds as well.
>> +CFLAGS += -Wno-address-of-packed-member
>> +CFLAGS += -Wno-gnu-variable-sized-type-not-at-end
>> +
>> CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
>> else
>> CC := $(CROSS_COMPILE)gcc
>
> thanks,
> -- Shuah
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores
2024-05-30 19:28 ` John Hubbard
@ 2024-05-31 14:30 ` Shuah Khan
0 siblings, 0 replies; 7+ messages in thread
From: Shuah Khan @ 2024-05-31 14:30 UTC (permalink / raw)
To: John Hubbard, Shuah Khan
Cc: Beau Belgrave, Steven Rostedt, Mark Brown, Naresh Kamboju,
Nick Desaulniers, Justin Stitt, Bill Wendling, sunliming,
Masami Hiramatsu, Valentin Obst, linux-kselftest, LKML, llvm,
Nathan Chancellor, Shuah Khan
On 5/30/24 13:28, John Hubbard wrote:
> On 5/30/24 7:25 AM, Shuah Khan wrote:
>> On 5/28/24 20:08, John Hubbard wrote:
>>> gcc defaults to silence (off) for the following warnings, but clang
>>> defaults to the opposite. These warnings are not useful for kselftests,
>>> so silence them for the clang builds as well:
>>
>> Please you add more information on why they aren't useful
>> for kselftests.
>
> Ah OK. My wording is a little misleading. The warnings are not useful
> for the *kernel*, as previous decided by the gcc settings when building
> the kernel. And it is only only due to including kernel data structures
> in the selftests, that we get the warnings on clang.
>
> So it is not something unique to the selftests. There is nothing that
> the selftests' code does that triggers these warnings, other than the
> act of including the kernel's data structures.
>
> I can post a v2 to update both the comment and the commit description.
>
Yes please.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-05-31 14:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 2:08 [PATCH 0/2] selftests/lib.mk: LLVM=1, CC=clang, and warnings John Hubbard
2024-05-29 2:08 ` [PATCH 1/2] selftests/lib.mk: handle both LLVM=1 and CC=clang builds John Hubbard
2024-05-30 5:04 ` Muhammad Usama Anjum
2024-05-29 2:08 ` [PATCH 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores John Hubbard
2024-05-30 14:25 ` Shuah Khan
2024-05-30 19:28 ` John Hubbard
2024-05-31 14:30 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox