Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4688033ybb; Tue, 7 Apr 2020 12:22:09 -0700 (PDT) X-Google-Smtp-Source: APiQypJoZuzz8zBpxsBdHQhDlr2yvVH3QSHjLWzBZFPpdfhCyDYtfWCTydjlCE9dK94hPbTg/aMP X-Received: by 2002:aca:2b01:: with SMTP id i1mr341890oik.162.1586287329497; Tue, 07 Apr 2020 12:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586287329; cv=none; d=google.com; s=arc-20160816; b=WjZoK7Mext9wZTZg8Jr7L6sP4IZZ2ysnxel6lwDLRnKWQW1G+KKEbC/OXPgyMTuczT zRHD8282vWa+UyO7GdyaUTqO7WeV3NYAalBBslYc+k9AvEpvIotB7ioOII7sJzzmm9+h 9epMuiLJ6YqbqsrlPpmmgvSDx4iYn+0G3xJ3//gOGsopOb90JVxFcgSeAdaUANzqK3Ij gPEs2ywXygNDJV158nODUXFc7qhDB+7f9J3mLlfZ9GmXhe+RnYq8C5QOxeEt+trI8AfR 6LTTRRTVO/tPdt0w5l6K+RmEXwMZcC/h36MeljFkbZwhWkEjymMFadNUeVcVj6lnoZ82 mfLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=rG3gvegGYMuy2XFIc5WCw+t7albL71jqGTx3h+oz3PU=; b=h2fboFLQZBkPAgi5KdDRohJgiGMHhhJ43H3iHULeg2m5GHW4jSwT4Cg/NajmtMVW75 t9Tb1lK661R51RBCAa56Sp5OLrwOjdEL6A37Q8TxOq2hdt3lREQ3ESeR6Yzissu/wEXU /bUHTO1ltw5XjLpuObrsi+lqs0/ouG42SaVLaMhVzDb+VPstGYtBg0S1CTCHkx4RHo1t Fb8IAaKVAoeZcet99buARTld0d/sXJWs/G1GLIvYQWUW/1JXM9fMNlFGK/H265aq8Stc 3FhtAgyalG8BQmYFWbU/GRPLFqnt63Kecr8SfhREc9T0A0W3vctcG2WTNd0kVTfW7FD0 nV0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fCkFOEvt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si1071781otj.160.2020.04.07.12.21.55; Tue, 07 Apr 2020 12:22:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fCkFOEvt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbgDGTT3 (ORCPT + 99 others); Tue, 7 Apr 2020 15:19:29 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:53510 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726791AbgDGTT2 (ORCPT ); Tue, 7 Apr 2020 15:19:28 -0400 Received: by mail-pj1-f65.google.com with SMTP id l36so162001pjb.3 for ; Tue, 07 Apr 2020 12:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rG3gvegGYMuy2XFIc5WCw+t7albL71jqGTx3h+oz3PU=; b=fCkFOEvtzj2top7sZTwblS/ZXmLkcMYJ8BO67ogp03C115ys5kxUV0awOlROlf5Bfr J+3pA/OqikQfzArrvPi7mX+qMFyC6y/hiMQZOOKeQex3CPx6s3hXodEQuJWpOP6WAFo/ 1WiQSpoalWXTn8Zs7ab0/JgYioVxsr3U4/o0WeUk+nV7ZnCSXDaErkQ6elBolGznqrL2 ThBdUnTuofOAWtkxbRq8mKlK6GDlTTLm6pWrTL07YI/GYk7n6NMJdEdnaoqOi40S8BbK /ri697JjwrOE3Xb8FlbNYfn4BFZsrS4ozV3KI1OR4VnZKH/uYoSHrKu4NFsS2pjZ9w6W EhRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rG3gvegGYMuy2XFIc5WCw+t7albL71jqGTx3h+oz3PU=; b=XJJtdJbGqtKsLT5ZFctEl6v9Er4CAaAJKDve8Hw3u840Zjl09sfAQOavN34eI36yMu q8UK33xM7B6lS3rMvrhOU4J1NUmeyzmPdzEJZvwUpJo5GdGc94kSO74w7th1eDr+C7cR rJ7tIL/iAMITlK7spib95OuBbZ+tlZlPrSTnIC9X6Cvcckl1Dl8EzBX3B6YzUiWl4JmV eZeLvwTF7aZeAYRqUhhFbZTFLaoXqLbIWyBoC5VU+tFqBQiCTcdMgESp9L5/9BUk84iZ ZQ5hBuHRwQ+PzGXWwSS8MwYPh/fTg0aUHiqrui6zfJqD0mS3qwwQN/wrhw7rut4RHmv4 jHnA== X-Gm-Message-State: AGi0PuZApFeeqeR8QjOOD7J/ZDFwARby3L4cun/2cREMvaN+qre+kTlT r2wy6ZmJf0oyNtXNytI2EFnzdg== X-Received: by 2002:a17:902:598e:: with SMTP id p14mr3523199pli.276.1586287167194; Tue, 07 Apr 2020 12:19:27 -0700 (PDT) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id 203sm320233pfw.25.2020.04.07.12.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 12:19:26 -0700 (PDT) Date: Tue, 7 Apr 2020 12:19:23 -0700 From: Fangrui Song To: 'Nick Desaulniers' via Clang Built Linux Cc: Masahiro Yamada , Matthias Maennich , Linux Kbuild mailing list , Nathan Chancellor , Jonathan Corbet , Michal Marek , "open list:DOCUMENTATION" , Linux Kernel Mailing List , Jian Cai , Stephen Hines , Luis Lozano Subject: Re: [PATCH] kbuild: support 'LLVM' to switch the default tools to Clang/LLVM Message-ID: <20200407191923.txaggm7ntxrinddf@google.com> References: <20200403051709.22407-1-masahiroy@kernel.org> <20200406112220.GB126804@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-07, 'Nick Desaulniers' via Clang Built Linux wrote: >On Tue, Apr 7, 2020 at 10:47 AM Masahiro Yamada wrote: >> >> On Wed, Apr 8, 2020 at 2:01 AM Nick Desaulniers wrote: >> > >> > On Tue, Apr 7, 2020 at 9:17 AM Masahiro Yamada wrote: >> > > >> > > On Mon, Apr 6, 2020 at 8:22 PM 'Matthias Maennich' via Clang Built >> > > Linux 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.