Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4614839ybb; Tue, 7 Apr 2020 10:54:58 -0700 (PDT) X-Google-Smtp-Source: APiQypJTpv+utZJsOtsdDUR7ik3lrohvUpf6VRyT228BMbIBFcBl/TyFjJfNSSfavNFFQfPnAST7 X-Received: by 2002:a9d:2dc1:: with SMTP id g59mr2510812otb.90.1586282098100; Tue, 07 Apr 2020 10:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586282098; cv=none; d=google.com; s=arc-20160816; b=d+5lBFOzyeSQ1Mi/pIkALUG858grzG0femTvo9SFikRfEVn0Ya0WnWRUfuGryTCXiF FTMLVNw5SyAGgpTt5Tvr81LVhzwJFh39mdB0dkMPP+vnCnpTFPIKciZCSRg//DJmib9H 1yU6EmEDzBlM7tvNfFl6f7FOVpV5iZx9EBKvJWBZ15rOHNp1/4XSGiwq8PHX+srEkX9Q 3evM6guGfq9soJud6kBdEGLBmxH1YvQkQBFwsQtoED3uhS91vclHW+QY2u2JHYNJuJ1L /HT5KWt6oqG87AdTrywYtaNqUH77XHWkQZh0W7B5VUp/KoEqF5aiTfcgRr9UWoFhvB06 MOpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IZsnHknmPnzlDnnD+lsQB+SUZRKz07GU9C9BlgnfmqY=; b=eAaKwOnDzjI8E5audYQgBU9Pw9DWnZp0vtNZtcEy03joxgU6XngFovAOf2CFVH2iiz 6KpBo9eAkMC4swxL2wtkYl9XvRemV4HWNvrsW5uKduXushfk8ndZlMN6kIjV4dHGsoPp kChlDo428kvhvuX9flGwVaVCb8ZWTdcoLUF2btzesSgNN321gty0MORk8U9+SSlio+Mq 4c5uuCDMU4uKhpIf7vi9I3jOvplwuTGCLvmgiiWvdbzyhtCd0RMjDIEwl3HvU52YcSkj 3ZX75lG+iLYzpfaZDRPEMftzgnS/La6V8oYpRIfSbMh6NVoZ8wgwr9rTjFMffyIgJoxx +P/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nAefzkZ2; 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 l14si1430678ooe.48.2020.04.07.10.54.42; Tue, 07 Apr 2020 10:54:58 -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=nAefzkZ2; 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 S1726628AbgDGRxV (ORCPT + 99 others); Tue, 7 Apr 2020 13:53:21 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38519 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726582AbgDGRxV (ORCPT ); Tue, 7 Apr 2020 13:53:21 -0400 Received: by mail-pf1-f195.google.com with SMTP id c21so1142088pfo.5 for ; Tue, 07 Apr 2020 10:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IZsnHknmPnzlDnnD+lsQB+SUZRKz07GU9C9BlgnfmqY=; b=nAefzkZ2JinyQVrK0n8MAikkoMhgx+2j7FIdTNzirnsibGhl1/ylmS9MckoCSPcMb8 dRSjnFECwT2RvISJR+xYvmQ/xy6L0148d4mdHPpIsERRxpYZXRO3sKuXnMPRnGhH+gnd 2pQMBdjOFQKmY75VSFEhg+4Jf41epd7vMuwTcMRqlF3K/eWMUKqWffaB+6qJGL6qDweb VVIv+/v6NhVSbVfgdDCnmRMXKZDhX8nbYLcdk1cwCaceANNvWGIiT3q7rYhe4zu9w4qy J9x/+QmbdeIGyzQHl8tNcqFzwrUtLYmKickm7OYk9HCN7aYHpQBRZMjyclL278K7la5R ys1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IZsnHknmPnzlDnnD+lsQB+SUZRKz07GU9C9BlgnfmqY=; b=giBH3Xskz7oKIAmb4AsIzYEbARS7LMU+qmvxsuMaujpjrDxaaUJPDCCGXBsupwfoie nUGuMkDatfRfXI6kZl8KjXeuyvNfoFqwQf76XKj41o2qkSKdbJaTNi3xPxIT6yHXDDZv W3Ilh97t6SNNafciZEZg5x148Reu7aELd8/JcsxY9jJOzVJCgPfxozNV2OCitqumI4kb HpzFG4ZXFW6tepl38TnSjVOjtNezl90e6xcAZ7W+gD619QTP/TpXxRfz0BNZ9XaU5Du2 8A3NfdR8yJ/ZTWjeH828syFqY38zyI1MwLROmmO0krLd0ndLtwoODsTUBVka1qTlZCL5 ysRQ== X-Gm-Message-State: AGi0PuaKpOPJTlYJBaZxNPKzOdr/ez6QU6rYVbwl9dFJG9RMANI9YHRZ 7Dsb28zoj3Mzi9YOlH6+PZLBOSpm7Ik8K/VT2n9nNQ== X-Received: by 2002:a62:e415:: with SMTP id r21mr3651186pfh.169.1586281999850; Tue, 07 Apr 2020 10:53:19 -0700 (PDT) MIME-Version: 1.0 References: <20200403051709.22407-1-masahiroy@kernel.org> <20200406112220.GB126804@google.com> In-Reply-To: From: Nick Desaulniers Date: Tue, 7 Apr 2020 10:53:08 -0700 Message-ID: Subject: Re: [PATCH] kbuild: support 'LLVM' to switch the default tools to Clang/LLVM To: Masahiro Yamada Cc: Matthias Maennich , Linux Kbuild mailing list , Nathan Chancellor , clang-built-linux , Jonathan Corbet , Michal Marek , "open list:DOCUMENTATION" , Linux Kernel Mailing List , Jian Cai , Stephen Hines , Luis Lozano Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Thanks, ~Nick Desaulniers