Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4896919pxv; Tue, 20 Jul 2021 14:01:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygqL8J/syP042DoDbTOFex7uJ49YwKzUvnmhOy6Cc67+WE/GrpuU0KYtHdx/WpKDDQtwzU X-Received: by 2002:a5d:9c4a:: with SMTP id 10mr24171422iof.23.1626814879358; Tue, 20 Jul 2021 14:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626814879; cv=none; d=google.com; s=arc-20160816; b=ph5BU/CW7k0kqRrkQlCxnwRbRZjwrMwmpCMatEic0ucQH79rmoPmLG0cCm40x0twRL VCYYCnWawMR7adr2bR4DvlNTTqmYo42BKUol1of9eiBExNGfo58i/vPZ/6bHwr/XHbhY L0X6oQ5NnM3D7lWPcmNNXQEqG+xjJ8id9ZLik6nlapryDXqd+RFGBmc7sToXHuhjaWeP NzjmhHKVd3I3laaBXLL29rCRis5aDFovDbL7F+jVfbl8P2UjWz9TfjJxX6T81/luFsPg hgZf3KFCPuLp1ZY8xf4HHSpsOVvFcEzz0Up+ho7P7sTNLKgJMOdMGN0AeAMv31JaIIO8 B6XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SbK6o7K/EkXUAGGxjZp7cQsvPy5H+b1sgULKd5tuIl8=; b=bjJB8+YgZrxXTbjWQeFYyN0/QHTaim7k+WbduAhqn9jOEDqBFrH+THDcU/zsXMwyU+ 7ZEs4w2+H2hw7QCj14jDuFBGUD728iW0CZtmlMxSuCLCNlfQxhog7ylPruPeYcHRuZeR EBccoBKJZBZV718OTIrGQuc5jnhT8FzFuENKeo6FSTIzCExJz1GOGUg8okW2UcOwpp7Q 0GoguDFjOIg4/YVYQ4tbO9wAozxlWDeQ9vTPy5maYGzUHWIRD++BIiER6V5EuWW2+t1K Jm44m9cN+IIdxVOKha3hlEDe+vp9GYH8Z+WEz5f1XdJovv9VtuqBFK0Cmc3zwdNE2k+r VsGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RZrjkrsp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id s8si26024094ilu.146.2021.07.20.14.01.06; Tue, 20 Jul 2021 14:01:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RZrjkrsp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S235700AbhGTUSf (ORCPT + 99 others); Tue, 20 Jul 2021 16:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234902AbhGTUMm (ORCPT ); Tue, 20 Jul 2021 16:12:42 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ACCEC0613E2 for ; Tue, 20 Jul 2021 13:52:52 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id h4so146310ljo.6 for ; Tue, 20 Jul 2021 13:52:52 -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=SbK6o7K/EkXUAGGxjZp7cQsvPy5H+b1sgULKd5tuIl8=; b=RZrjkrspMlyjhNfo8C2mQdLOvr7mkdUI4sM5tGIno3VN2G/g9g9xRd9ju+RP62eh6E bUueDNj0aBrWk0OwADCCXZ5OjPY6DtaZB6JTVxIgotjf2Duygyli7h0/9UuDF1pQk1JE HYEmV2qZC+4H/O2fjmBMyCgAWyJfDDYDpv6wPDVAotBqoNjehS88/YaRfL+hpJSYPPQf KzsQfjeE34J+kYZXTHCbLzJzQkA8BEyhWQHk1ok6eWaGyRJv0XuDFBo/SMu9rw5EjAcl PgfratM3omlSEVece2KEdYBAXuf03kx+c2v/8grGQ56/utkw5aodZN9yjw6uAULuWydf PKKA== 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=SbK6o7K/EkXUAGGxjZp7cQsvPy5H+b1sgULKd5tuIl8=; b=OdZ9QyCiK0iIFnLjW5zHvARuV2aMFcWMHkr5VVOikydbkdbax/yqFc/fyAhc6fLt3F hJBIuSy6KGgIJ3Zw0TgVAaaX2zwm09aYwZOQsexLFtmmFGOtAYrHpYY5F2gq0cQXzhYF ol50hpGEXIkHrfLEPxTGkwQAcgTGqj4Yub5RybcDbiepD9Yj2yCi/zS5ZEx1iNDKr0Xg RawvcUrNvbkN6abaAv0Ic0LHu3AOAIBbLu9AxnQL2K8JDltHZdA4w4sw7IK1T74+Bg8T lHe3iuO3oZlsjZkgb2gKhywjqygd/pijgOsuE/TamkV6knd2aIcmZV8EHhpPjrbDDtBg 7M4w== X-Gm-Message-State: AOAM532+HTbHDN/brl5NaIK3Mah+c0wxVSRNYagEcCNdan1mcY+nORWn lEfNl325pWQannmQc9ker0ANzgvEUBWrWNY7HqfHFg== X-Received: by 2002:a2e:a911:: with SMTP id j17mr28057523ljq.341.1626814370202; Tue, 20 Jul 2021 13:52:50 -0700 (PDT) MIME-Version: 1.0 References: <20210708232522.3118208-1-ndesaulniers@google.com> <20210708232522.3118208-3-ndesaulniers@google.com> In-Reply-To: From: Nick Desaulniers Date: Tue, 20 Jul 2021 13:52:39 -0700 Message-ID: Subject: Re: [PATCH v2 2/2] Makefile: infer CROSS_COMPILE from SRCARCH for LLVM=1 LLVM_IAS=1 To: Linus Torvalds Cc: Masahiro Yamada , Miguel Ojeda , Fangrui Song , Michal Marek , Arnd Bergmann , Linux Kernel Mailing List , Linux Kbuild mailing list , clang-built-linux , Geert Uytterhoeven , Christoph Hellwig , Nathan Chancellor Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 20, 2021 at 10:43 AM Linus Torvalds wrote: > > On Tue, Jul 20, 2021 at 1:05 AM Masahiro Yamada wrote: > > > > LLVM=1 is a convenient switch to change all the > > defaults, but yet you can flip each tool individually. > > Actually, I'd argue that "LLVM=1" is *not* a convenient switch. Compared to the old way of CC=clang LD=ld.lld OBJCOPY=.... it certainly is. > Neither are the individual other command line settings. Agreed, but we needed flexibility until we could get all of the command line tools working for each architecture. They're still useful when there's a regression and we need to fall back. So I wouldn't be in favor of removing them (not that that's been proposed). > When clang was the odd man out, and special, it all made sense. > Changing the path to CC was similar to changing the path to AWK. And > that's obviously why we have what we have. > > But clang has become a primary compiler for some kernel communities, > and I think it might be time to just re-visit that entirely. :^) > In particular, I think we should just make it a Kconfig option. I hate > the command flag stuff so much, that my clang tree literally has this > patch in it: > > -CC = $(CROSS_COMPILE)gcc > +CC = $(CROSS_COMPILE)clang > > so that I can just do the same "make -j128" in both my gcc tree and my > clang tree. So you haven't been using LLD... :( (imagine using more than one thread to link, and being faster than ld.gold) If anything you should be hard coding LLVM=1 in that tree. Also, please be careful you don't accidentally commit that! 0:-) > But each build tree already has its own .config file, so it would be a > lot more convenient if that was how the compiler was chosen, and then > "make oldconfig" would just DTRT. > > We do most of the other heavy lifting in this area in Kconfig anyway, > why not add that compiler choice? > > Obviously it would be gated by the tests to see which compilers are > _installed_ (and that they are valid versions), so that it doesn't ask > stupid things ("do you want gcc or clang" when only one of them is > installed and/or viable). > > Hmm? So then any "LLVM=1" thing would be about the "make config" > stage, not the actual build stage. > > (It has annoyed me for years that if you want to cross-compile, you > first have to do "make ARCH=xyz config" and then remember to do "make > ARCH=xyz" for the build too, but I cross-compile so seldom that I've > never really cared). > > Let the flame wars^H^Hpolite discussions ensue.. I agree with you. Overall the command line invocation of make when cross compiling, or when using LLVM is too long. You even call out LLVM=1 and ARCH separately. Each one of these had good reasons to exist for years. But I disagree that all needs to be sorted out together, or right now. And I'd much rather tackle them separately, one by one, than try to completely rewrite how we cross compile the kernel today. Right now, we have: $ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make LLVM=1 LLVM_IAS=1 -j72 This series is concerned with just CROSS_COMPILE (and just for LLVM=1). Next I plan to default on LLVM_IAS=1 for all architectures we support, minus ppc and s390 where we still have some assembler bugs. Your/Arnd's ideas about LLVM=1 or not via Kconfig, or pre-Kconfig is a good idea for eliminating LLVM=1. Then that just leaves ARCH. Arnd's idea about helping you install a toolchain from kernel.org is one I support, but orthogonal to the above somewhat. Do you allow someone to have a config that denotes intent to build with clang then prompt if they don't have clang installed to download it? Or do you prevent someone from selecting building with clang because it's not in the $PATH? Your/Arnd's idea about detecting which toolchains are installed is one I support, but orthogonal to the above somewhat. (For that, I'm curious for our build servers if that means having to put tools in certain locations; I prefer we reference $PATH when possible. Or if .configs can no longer be shared if tools are in different locations. But perhaps that's a non-issue). I'm also curious how many stat calls we'll need to test/probe/find these, and how we prioritize which tools are selected when there's more than one version installed. I encourage us to make steps in the right direction; but I think this series is ready to go for at least one of the command line variables. I don't think we need to wait for some probing machinery to eliminate CROSS_COMPILE when LLVM=1; and if we ever get such machinery we can revisit whether that helps this case at all. -- Thanks, ~Nick Desaulniers