Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5143162pxv; Tue, 20 Jul 2021 21:07:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT8eBw78rlE1uxPUuleGEDJECYQis708C/stwlLXKEoBB+GjPEfZJFo3wwuDZRIgvGX2Bx X-Received: by 2002:a02:331e:: with SMTP id c30mr18542603jae.94.1626840431305; Tue, 20 Jul 2021 21:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626840431; cv=none; d=google.com; s=arc-20160816; b=mDHAIpTdmlOpb7x6OThRU7+P/4yPsLag90DF2A/HaIwPo1cQeUwyy/gPTAPe8sgKOn W4/YIkgYReOIK0arSRHullxEQ/U5a6GsEI2f5pc+t8q+Z90Hvep9EbUMPG9fD2Qht8Fq NfcBRu/fJ3yM7CLsreQcyCBCHgMWccon7qrn/Q52gRz71P3i8XSIwFIG2/eDRnp8MHuJ +2c+jFCBZ3fESQLiV+H+7CPdi4D+c41vHqdECXUxh7QnyoDr81JsqvJjJR/HJxQBaBui 7U5hZbT/yxU6DfaQhvlt+yKPEZhr3xEQG8zLtykifk/xeMJ5pwTsiEi0GEQ+/CGxLgCH F03w== 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:dkim-filter; bh=AfCQ8zWwU2kVtZFAJkMMPrdLTVubh6u8+7aVLlmJQ1M=; b=Sl8Q8GmF7HVQOwOQb20oziVqjia/ULbVukVKQ8mS7uSRetP5f9vguIKy8h6TAaxt5B syebzbXfku+MoMu3MUST5KyeIdXGWOlJkOOD3uI3vIcrKyg76LK0rVHlxStx//1dCYD3 fPDlTL8f+ZqaRO/TyYXXM/JxbmKEFx+TYqnNw3Lpu0V3JQ4Zy8m7HkhnYfkfgDe3+dpZ tz5+UM+8toLxexHNq69pRnJA4PlPN+M+/LDOxL6Gsh6H4rI7GMJzpwV8a7Nreu2+K7b1 PQPYpwoLd8TQ61NfaTOIWHe+d53mX3kx4dmiMqyeY2jnMH+b0sU+Zwq3kFnYGjypEDwZ O70A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=UoGntPjr; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n6si27097630ilj.66.2021.07.20.21.06.46; Tue, 20 Jul 2021 21:07:11 -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=@nifty.com header.s=dec2015msa header.b=UoGntPjr; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231499AbhGUDYb (ORCPT + 99 others); Tue, 20 Jul 2021 23:24:31 -0400 Received: from conssluserg-06.nifty.com ([210.131.2.91]:53929 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbhGUDYa (ORCPT ); Tue, 20 Jul 2021 23:24:30 -0400 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (authenticated) by conssluserg-06.nifty.com with ESMTP id 16L44svr031715; Wed, 21 Jul 2021 13:04:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 16L44svr031715 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1626840294; bh=AfCQ8zWwU2kVtZFAJkMMPrdLTVubh6u8+7aVLlmJQ1M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=UoGntPjrewv3EMKohf1coQEvbJTLFA38pl0GOwdCgdDKGHAAgiboqJ0RLT8t0wVLM jrflQ97dTN2xZrG6qmINNgUr9zk3POEu7QOcGyP4OX7wZLRNBmbh8LUxreR42N+fX8 T2qISlYG6kcBiWDWdENrYCN7CiNonb6Kcji7pFyMZBbLshisHaCw5vVtILHI4IPQCs J4ONOmQuyKfTJpvKE08a8ktY9kJds/8El8O61DLYR5norpPVf7HbCAkAg4Ul0ZD/aa tQRusa9GhJOAAX7JtIixydi7haasayZaj2cP3yFLdP+has49D80UKCu4rNe35hC/pC 4GnMpPKNctzSw== X-Nifty-SrcIP: [209.85.216.41] Received: by mail-pj1-f41.google.com with SMTP id gp5-20020a17090adf05b0290175c085e7a5so3265883pjb.0; Tue, 20 Jul 2021 21:04:54 -0700 (PDT) X-Gm-Message-State: AOAM532qVGtATBSkG7RtGEkN5++owlir4AqaDNEmeBA/Cc9dqlOZtp98 69B12DYelZUcd2nQ2IwCwftqy1r9eJKrvdxi5Fg= X-Received: by 2002:a17:90a:c506:: with SMTP id k6mr1773256pjt.198.1626840293821; Tue, 20 Jul 2021 21:04:53 -0700 (PDT) MIME-Version: 1.0 References: <20210708232522.3118208-1-ndesaulniers@google.com> <20210708232522.3118208-3-ndesaulniers@google.com> In-Reply-To: From: Masahiro Yamada Date: Wed, 21 Jul 2021 13:04:16 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] Makefile: infer CROSS_COMPILE from SRCARCH for LLVM=1 LLVM_IAS=1 To: Arnd Bergmann Cc: Linus Torvalds , Nick Desaulniers , Miguel Ojeda , Fangrui Song , Michal Marek , 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 Wed, Jul 21, 2021 at 4:58 AM Arnd Bergmann wrote: > > On Tue, Jul 20, 2021 at 7:43 PM Linus Torvalds > wrote: > > On Tue, Jul 20, 2021 at 1:05 AM Masahiro Yamada wrote: > > > > 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). > > I don't see a good way of making Kconfig options both select the > compiler and defining variables based on the compiler, since that > would mean teaching Kconfig about re-evaluating all compiler > dependent settings whenever the first option changes. > > I do have another idea that I think would work though. > > > 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). > > The best thing that I have come up with is a pre-configure step, where > an object tree gets seeded with a makefile fragment that gets included > for any 'make' invocation. This would set 'ARCH=', 'CROSS_COMPILE', > 'CC=' and possibly any other option that gets passed to 'make' as > a variable and has to exist before calling 'make *config'. There is no need to add a hook to include such makefile fragment(s). Quite opposite, you can put your Makefile (in a different filename) that includes the top Makefile. I think this is what people are already doing: GNU Make looks for 'GNUmakefile', 'makefile', and 'Makefile' in this order. So, you can put 'GNUmakefile' with your favorite setups. $ cat GNUmakefile ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CC=clang include Makefile Then, you can simply do "make defconfig; make" for building arm64 with clang. If you want to have multiple setups, you can put custom Makefiles, and select by the -f option. For example, $ cat Makefile-arm64 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- include Makefile $ cat Makefile-arm64-llvm ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 include Makefile $ cat Makefile-arm ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- include Makefile Then, $ make -f Makefile-arm64 defconfig all -j24 $ make -f Makefile-arm64-llvm defconfig all -j24 $ make -f Makefile-arm defconfig all -j24 You can use TAB-completion for the 'Makefile-*' part, so you can save many typings than you do make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- ... It is just a tip to ease your life without any change to upstream. Maybe, some people might be doing that. > > This is probably the easiest part here, and it lets you set up multiple > object directories in which you can then do > > make O=obj-x86 defconfig vmlinux modules -skj32 > make O=obj-x86-clang > make O=obj-arm64 randconfig > ... > > without ever having to type the additional CC/CROSS_COMPILE/LLVM > variables again. > > One step further is the script that automatically finds a working toolchain > for a given architecture and sets up that object directory accordingly, > or even downloads a working cross-toolchain from kernel.org when > asked to do that. I saw Intel's 0-day bot attached a shell script to download and set up cross compilers. (make.cross) -- Best Regards Masahiro Yamada