llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Nathan Chancellor <nathan@kernel.org>,
	Ryan Roberts <ryan.roberts@arm.com>
Cc: Mark Brown <broonie@kernel.org>, Shuah Khan <shuah@kernel.org>,
	"Muhammad Usama Anjum" <usama.anjum@collabora.com>,
	Beau Belgrave <beaub@linux.microsoft.com>,
	Steven Rostedt <rostedt@goodmis.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>
Subject: Re: [PATCH v2 1/2] selftests/lib.mk: handle both LLVM=1 and CC=clang builds
Date: Fri, 7 Jun 2024 13:13:23 -0700	[thread overview]
Message-ID: <6b32399f-d9c6-4df5-b1e5-755ef4acf25d@nvidia.com> (raw)
In-Reply-To: <20240607171533.GA2636750@thelio-3990X>

On 6/7/24 10:15 AM, Nathan Chancellor wrote:
> On Fri, Jun 07, 2024 at 12:12:19PM +0100, Ryan Roberts wrote:
>> On 04/06/2024 05:55, John Hubbard wrote:
>>> On 6/3/24 3:47 PM, Nathan Chancellor wrote:
...
>> If we are concluding that CC=clang is an invalid way to do this, then I guess we
>> should report that back to [1]?
>>
>> [1] https://lore.kernel.org/all/202404141807.LgsqXPY5-lkp@intel.com/
>> [2]
>> https://lore.kernel.org/linux-kselftest/20240417160740.2019530-1-ryan.roberts@arm.com/
> 
> I can only speak from the perspective of the main kernel build, as I
> don't really know much if anything about the selftests, but I think
> CC=clang and LLVM=1 should both be valid. Ideally, they would behave as
> they do for the main kernel build (i.e., CC=clang just uses clang for
> the compiler and LLVM=1 uses the entire LLVM tools). I realize that for
> the selftests, there is probably little use for tools other than the
> compiler, assembler, and linker but I think consistency is desirable
> here.
> 
> I am not at all familiar with the selftests build system, which is
> completely different from Kbuild, but I would ack a patch that does
> that. Otherwise, I think having a different meaning or handling of
> CC=clang or LLVM=1 is the end of the world, but I do think that it
> should be documented.
> 

OK, that can be easily done, as shown below. And there are so far only
a handful of selftests that key off of LLVM (plus a few of my pending
patches). I can post this, plus a few patches (and patch updates for
pending patches) to use the new CC_IS_CLANG where appropriate:

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 429535816dbd..ea643d1a65dc 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -43,6 +43,15 @@ else
  CC := $(CROSS_COMPILE)gcc
  endif # LLVM
  
+# CC might have been set above (by inferring it from LLVM==1), or CC might have
+# been set from the environment. In either case, if CC is an invocation of clang
+# in any form, set CC_IS_CLANG. This allows subsystem selftests to selectively
+# control clang-specific behavior, such as, in particular, compiler warnings.
+CC_IS_CLANG := 0
+ifeq ($(findstring clang,$(CC)),clang)
+    CC_IS_CLANG := 1
+endif
+
  ifeq (0,$(MAKELEVEL))
      ifeq ($(OUTPUT),)
         OUTPUT := $(shell pwd)



thanks,
-- 
John Hubbard
NVIDIA


  reply	other threads:[~2024-06-07 20:13 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 [this message]
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

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=6b32399f-d9c6-4df5-b1e5-755ef4acf25d@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=beaub@linux.microsoft.com \
    --cc=broonie@kernel.org \
    --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=ryan.roberts@arm.com \
    --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).