From: Shuah Khan <skhan@linuxfoundation.org>
To: Nathan Chancellor <nathan@kernel.org>,
John Hubbard <jhubbard@nvidia.com>
Cc: Shuah Khan <shuah@kernel.org>,
Muhammad Usama Anjum <usama.anjum@collabora.com>,
Beau Belgrave <beaub@linux.microsoft.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mark Brown <broonie@kernel.org>,
Naresh Kamboju <naresh.kamboju@linaro.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Justin Stitt <justinstitt@google.com>,
Bill Wendling <morbo@google.com>,
sunliming <sunliming@kylinos.cn>,
Masami Hiramatsu <mhiramat@kernel.org>,
Valentin Obst <kernel@valentinobst.de>,
linux-kselftest@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
llvm@lists.linux.dev, Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v2 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores
Date: Fri, 7 Jun 2024 11:23:30 -0600 [thread overview]
Message-ID: <b7de28bd-34fd-491a-9b66-9a37dc450e22@linuxfoundation.org> (raw)
In-Reply-To: <20240603223609.GC1802995@thelio-3990X>
On 6/3/24 16:36, Nathan Chancellor wrote:
> On Fri, May 31, 2024 at 11:37:51AM -0700, John Hubbard wrote:
>> gcc defaults to silence (off) for the following warnings, but clang
>> defaults to the opposite. The warnings are not useful for the kernel
>> itself, which is why they have remained disabled in gcc for the main
>> kernel build. And it is only due to including kernel data structures in
>> the selftests, that we get the warnings from clang.
>>
>> -Waddress-of-packed-member
>> -Wgnu-variable-sized-type-not-at-end
>>
>> In other words, the warnings are not 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. Therefore,
>> silence them for the clang builds as well.
>>
>> 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>
>
> This seems reasonable to me.
>
> Acked-by: Nathan Chancellor <nathan@kernel.org>
>
>> ---
>> tools/testing/selftests/lib.mk | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
>> index 2902787b89b2..c179c02281e9 100644
>> --- a/tools/testing/selftests/lib.mk
>> +++ b/tools/testing/selftests/lib.mk
>> @@ -50,6 +50,14 @@ 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. The warnings are not useful for the kernel itself, which is
>> +# why they have remained disabled in gcc for the main kernel build. And it is
>> +# only due to including kernel data structures in the selftests, that we get the
>> +# warnings from clang. Therefore, disable the warnings for clang builds.
>> +CFLAGS += -Wno-address-of-packed-member
>> +CFLAGS += -Wno-gnu-variable-sized-type-not-at-end
>> +
Thank you for adding this comment block.
>> CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
>> else
>> CC := $(CROSS_COMPILE)gcc
>> --
>> 2.45.1
>>
>>
>
Thank you both. I will apply this for the next release. I want this
change soaking in next for a bit.
thanks,
-- Shuah
prev parent reply other threads:[~2024-06-07 17:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 18:37 [PATCH v2 0/2] selftests/lib.mk: LLVM=1, CC=clang, and warnings John Hubbard
2024-05-31 18:37 ` [PATCH v2 1/2] selftests/lib.mk: handle both LLVM=1 and CC=clang builds John Hubbard
2024-06-03 15:32 ` Mark Brown
2024-06-03 17:09 ` John Hubbard
2024-06-03 20:11 ` John Hubbard
2024-06-03 22:47 ` Nathan Chancellor
2024-06-04 4:55 ` John Hubbard
2024-06-07 11:12 ` Ryan Roberts
2024-06-07 17:15 ` Nathan Chancellor
2024-06-07 20:13 ` John Hubbard
2024-06-04 13:14 ` Mark Brown
2024-05-31 18:37 ` [PATCH v2 2/2] selftests/lib.mk: silence some clang warnings that gcc already ignores John Hubbard
2024-06-03 21:06 ` John Hubbard
2024-06-03 22:36 ` Nathan Chancellor
2024-06-07 17:23 ` Shuah Khan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7de28bd-34fd-491a-9b66-9a37dc450e22@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=beaub@linux.microsoft.com \
--cc=broonie@kernel.org \
--cc=jhubbard@nvidia.com \
--cc=justinstitt@google.com \
--cc=kernel@valentinobst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mhiramat@kernel.org \
--cc=morbo@google.com \
--cc=naresh.kamboju@linaro.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
--cc=sunliming@kylinos.cn \
--cc=usama.anjum@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).