linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: 'Nick Desaulniers' via Clang Built Linux 
	<clang-built-linux@googlegroups.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Matthias Maennich <maennich@google.com>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Michal Marek <michal.lkml@markovi.net>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Jian Cai <jiancai@google.com>, Stephen Hines <srhines@google.com>,
	Luis Lozano <llozano@google.com>
Subject: Re: [PATCH] kbuild: support 'LLVM' to switch the default tools to Clang/LLVM
Date: Tue, 7 Apr 2020 12:19:23 -0700	[thread overview]
Message-ID: <20200407191923.txaggm7ntxrinddf@google.com> (raw)
In-Reply-To: <CAKwvOdkicpNMqQipZ+AMTEz7JVou3bkcKiQ3Cih20qH0hoziDg@mail.gmail.com>


On 2020-04-07, 'Nick Desaulniers' via Clang Built Linux wrote:
>On Tue, Apr 7, 2020 at 10:47 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>>
>> On Wed, Apr 8, 2020 at 2:01 AM Nick Desaulniers <ndesaulniers@google.com> wrote:
>> >
>> > On Tue, Apr 7, 2020 at 9:17 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>> > >
>> > > On Mon, Apr 6, 2020 at 8:22 PM 'Matthias Maennich' via Clang Built
>> > > Linux <clang-built-linux@googlegroups.com> wrote:
>> > > >
>> > > > On Fri, Apr 03, 2020 at 02:17:09PM +0900, Masahiro Yamada wrote:
>> > > > >As Documentation/kbuild/llvm.rst implies, building the kernel with a
>> > > > >full set of LLVM tools gets very verbose and unwieldy.
>> > > > >
>> > > > >Provide a single switch 'LLVM' to use Clang and LLVM tools instead of
>> > > > >GCC and Binutils. You can pass LLVM=1 from the command line or as an
>> > > > >environment variable. Then, Kbuild will use LLVM toolchains in your
>> > > > >PATH environment.
>> > > > >
>> > > > >Please note LLVM=1 does not turn on the LLVM integrated assembler.
>> > > > >You need to explicitly pass AS=clang to use it. When the upstream
>> > > > >kernel is ready for the integrated assembler, I think we can make
>> > > > >it default.
>> > > > >
>> > > > >We discussed what we need, and we agreed to go with a simple boolean
>> > > > >switch (https://lkml.org/lkml/2020/3/28/494).
>> > > > >
>> > > > >Some items in the discussion:
>> > > > >
>> > > > >- LLVM_DIR
>> > > > >
>> > > > >  When multiple versions of LLVM are installed, I just thought supporting
>> > > > >  LLVM_DIR=/path/to/my/llvm/bin/ might be useful.
>> > > > >
>> > > > >  CC      = $(LLVM_DIR)clang
>> > > > >  LD      = $(LLVM_DIR)ld.lld
>> > > > >    ...
>> > > > >
>> > > > >  However, we can handle this by modifying PATH. So, we decided to not do
>> > > > >  this.
>> > > > >
>> > > > >- LLVM_SUFFIX
>> > > > >
>> > > > >  Some distributions (e.g. Debian) package specific versions of LLVM with
>> > > > >  naming conventions that use the version as a suffix.
>> > > > >
>> > > > >  CC      = clang$(LLVM_SUFFIX)
>> > > > >  LD      = ld.lld(LLVM_SUFFIX)
>> > > > >    ...
>> > > > >
>> > > > >  will allow a user to pass LLVM_SUFFIX=-11 to use clang-11 etc.,
>> > > > >  but the suffixed versions in /usr/bin/ are symlinks to binaries in
>> > > > >  /usr/lib/llvm-#/bin/, so this can also be handled by PATH.
>> > > > >
>> > > > >- HOSTCC, HOSTCXX, etc.
>> > > > >
>> > > > >  We can switch the host compilers in the same way:
>> > > > >
>> > > > >  ifneq ($(LLVM),)
>> > > > >  HOSTCC       = clang
>> > > > >  HOSTCXX      = clang++
>> > > > >  else
>> > > > >  HOSTCC       = gcc
>> > > > >  HOSTCXX      = g++
>> > > > >  endif
>> > > > >
>> > > > >  This may the right thing to do, but I could not make up my mind.
>> > > > >  Because we do not frequently switch the host compiler, a counter
>> > > > >  solution I had in my mind was to leave it to the default of the
>> > > > >  system.
>> > > > >
>> > > > >  HOSTCC       = cc
>> > > > >  HOSTCXX      = c++
>> > > >
>> > > > What about HOSTLD ? I saw recently, that setting HOSTLD=ld.lld is not
>> > > > yielding the expected result (some tools, like e.g. fixdep still require
>> > > > an `ld` to be in PATH to be built). I did not find the time to look into
>> > > > that yet, but I would like to consistently switch to the llvm toolchain
>> > > > (including linker and possibly more) also for hostprogs.
>> > >
>> > >
>> > > HOSTLD=ld.lld worked for me, but HOSTCC=clang did not.
>> > >
>> > >
>> > >
>> > > HOSTCC=clang without CC=clang fails to build objtool.
>> > >
>> > > The build system of objtool is meh.  :(
>> >
>> > Let's tackle that in a follow up, with the goal of build hermiticity
>> > in mind.  I think there's good feedback in this thread to inform the
>> > design of a v2:
>> > 1. CLANG_AS=0 to disable integrated as.  Hopefully we won't need this
>> > much longer, so we don't need to spend too much time on this, Masahiro
>> > please just choose a name for this.  llvm-as naming conventions
>> > doesn't follow the rest of binutils.
>>
>> I am not so familiar with the terminology in LLVM,
>> but I feel 'integrated' is a keyword IMHO.
>> I prefer LLVM_IA=1.  (or  LLVM_INTEGRATED_AS=1)
>
>I'm happy with either, and I trust your judgement.  You choose.
>Hopefully we will fix all our assembler bugs soon and won't need the
>flag much longer.

Maybe "IAS", e.g. LLVM_IAS=1 or CLANG_IAS=1

IAS is referred to in a few places. IA is not a common abbreviation.

I don't have strong opinion here and thank Masahiro a lot for the
improvement!

>
>-- 
>You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
>To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/CAKwvOdkicpNMqQipZ%2BAMTEz7JVou3bkcKiQ3Cih20qH0hoziDg%40mail.gmail.com.

  reply	other threads:[~2020-04-07 19:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03  5:17 [PATCH] kbuild: support 'LLVM' to switch the default tools to Clang/LLVM Masahiro Yamada
2020-04-03  8:57 ` Nathan Chancellor
2020-04-03  9:26   ` Masahiro Yamada
2020-04-03 18:23 ` Nick Desaulniers
2020-04-05 16:45   ` Masahiro Yamada
2020-04-05 23:55     ` Fangrui Song
2020-04-06  1:33       ` Masahiro Yamada
2020-04-06  3:14         ` Fangrui Song
2020-04-06  9:12         ` Sedat Dilek
2020-04-06 11:22 ` Matthias Maennich
2020-04-07 16:16   ` Masahiro Yamada
2020-04-07 17:01     ` Nick Desaulniers
2020-04-07 17:46       ` Masahiro Yamada
2020-04-07 17:53         ` Nick Desaulniers
2020-04-07 19:19           ` Fangrui Song [this message]
2020-04-08  1:23             ` Masahiro Yamada

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=20200407191923.txaggm7ntxrinddf@google.com \
    --to=maskray@google.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=corbet@lwn.net \
    --cc=jiancai@google.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llozano@google.com \
    --cc=maennich@google.com \
    --cc=masahiroy@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=natechancellor@gmail.com \
    --cc=srhines@google.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).