Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: John Hubbard <jhubbard@nvidia.com>
Cc: Shuah Khan <shuah@kernel.org>,
	Beau Belgrave <beaub@linux.microsoft.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mark Brown <broonie@kernel.org>,
	Naresh Kamboju <naresh.kamboju@linaro.org>,
	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
Subject: Re: [PATCH v2] selftests/user_events: silence a clang warning: address of packed member
Date: Tue, 28 May 2024 13:35:15 -0700	[thread overview]
Message-ID: <20240528203515.GC2680415@thelio-3990X> (raw)
In-Reply-To: <20240528202833.GB2680415@thelio-3990X>

On Tue, May 28, 2024 at 01:28:33PM -0700, Nathan Chancellor wrote:
> Hi John,
> 
> On Mon, May 27, 2024 at 02:47:04PM -0700, John Hubbard wrote:
> > When building with clang, via:
> > 
> >     make LLVM=1 -C tools/testing/selftest
> > 
> > ...clang warns about "taking address of packed member 'write_index' ".
> > This is not particularly helpful, because the test code really wants to
> > write to exactly this location, and if it ends up being unaligned, then
> > the test won't work (and may segfault, depending on the CPU type).
> > 
> > If that ever comes up, it will be obvious and can be fixed. But all it's
> > doing now is prevent a clean clang build, so disable the warning.
> > 
> > Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> > ---
> > 
> > Changes since the first version:
> > 
> > 1) Rebased onto Linux 6.10-rc1
> > 
> > 
> > thanks,
> > John Hubbard
> > 
> > 
> >  tools/testing/selftests/user_events/Makefile | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/user_events/Makefile b/tools/testing/selftests/user_events/Makefile
> > index 10fcd0066203..617e94344711 100644
> > --- a/tools/testing/selftests/user_events/Makefile
> > +++ b/tools/testing/selftests/user_events/Makefile
> > @@ -1,5 +1,10 @@
> >  # SPDX-License-Identifier: GPL-2.0
> >  CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
> > +
> > +ifneq ($(LLVM),)
> 
> Perhaps it would be better if this were
> 
>   ifeq ($(CC),clang)
> 
> as that would catch both CC=clang and LLVM=1 users? I haven't tested
> this though.

Hmmm, now that I am actually looking at tools/testing/selftests/lib.mk,
it seems like CC is only set to clang when $(LLVM) is set, so keeping it
the way it is now is probably best. Sorry about that, I am not too
familiar with the tools build system.

> Additionally, I think it would be good to mention that
> -Wno-address-of-packed-member is GCC's default, whereas Clang enables
> -Waddress-of-packed-member by default.
> 
> > +    CFLAGS += -Wno-address-of-packed-member
> > +endif
> > +
> >  LDLIBS += -lrt -lpthread -lm
> >  
> >  TEST_GEN_PROGS = ftrace_test dyn_test perf_test abi_test
> > 
> > base-commit: 2bfcfd584ff5ccc8bb7acde19b42570414bf880b
> > -- 
> > 2.45.1
> > 
> > 
> 

  reply	other threads:[~2024-05-28 20:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27 21:47 [PATCH v2] selftests/user_events: silence a clang warning: address of packed member John Hubbard
2024-05-28 20:28 ` Nathan Chancellor
2024-05-28 20:35   ` Nathan Chancellor [this message]
2024-05-28 20:54     ` John Hubbard

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=20240528203515.GC2680415@thelio-3990X \
    --to=nathan@kernel.org \
    --cc=beaub@linux.microsoft.com \
    --cc=broonie@kernel.org \
    --cc=jhubbard@nvidia.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=naresh.kamboju@linaro.org \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=sunliming@kylinos.cn \
    /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