Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4856058pxv; Tue, 20 Jul 2021 13:02:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHQ3QdOD+HDBOEedJ+sDzMHMGKe2MgbsOYlkGmMEFtWkymnTlihCmmtge+cJVT+XrdFCme X-Received: by 2002:a17:906:4a8d:: with SMTP id x13mr34553933eju.349.1626811343411; Tue, 20 Jul 2021 13:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626811343; cv=none; d=google.com; s=arc-20160816; b=ztHKsk5g/f3YK9s/6yJYEeASS/civPsKvQOTfgSkKEir0+yhMGK9vb1sOGHhD5caMR DCrtHhbgpmBl27OPV8vPd5wA6piyY2Yii9NygTN/6gcK995w4RbQfNEBNhe/lwYeYLZs HVZXwXZ7rtep++iM5tRwDC98yQH5Wi/ueCGIDCyB1EDsS2rulXF+w95Gbyu8BiBkTOcG YztrtDikejzzUDZV5RizdjVO8lH+eRA9kVMjRnZ2LGHRg9y6O9EIF9CStg5Ifwb2CAxG hIjoWyP0XCgwmX8coe+mSDxOyoHNFmxkK/Hg7D1AHRjOicihaX+b5gmK2HvSnSdWl9el hYYQ== 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=1NAK6ReYdddIOpKLpri57J2o7TSWeKUSgE8SLOuORyc=; b=ApDZvJV1cBGGvLSspp6tvXnLofHxzMUYqpXwpVtbpJaKeODk0Y9Db7i89hh0WG4H3Q w5w19icI06sITo2MB2M7hsRIMJ/KTniif3sqk5GV4vYX5LDGYMKUR/JfF+nSyxtsBRAR y3uquV/iNFsx5C1tmKBl9EeIpVGz8K/aOj7lVZuB9BtLB6RVFRjXFChgKkf8iPRvfP3R QF4KF42PpckN6t5hmL9U8WOYizCP1KEpDmvPQESkSpYr8FuOF9CNzU+kag/XC7y3i2vB U2S0mRjqvGVnRtOJc7kMrxU8hN+OteM/R6KEYdUvF4lLvadUBqoddBKnSM9nMs/dY2/s 2SUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MVTeDBI5; 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 w21si25027229edx.566.2021.07.20.13.01.59; Tue, 20 Jul 2021 13:02:23 -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=@kernel.org header.s=k20201202 header.b=MVTeDBI5; 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 S229617AbhGTTTV (ORCPT + 99 others); Tue, 20 Jul 2021 15:19:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:52432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232025AbhGTTS0 (ORCPT ); Tue, 20 Jul 2021 15:18:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 30950611F2; Tue, 20 Jul 2021 19:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626811131; bh=gj/ZyZfKT5W/PMZKp3qddd7AG7he0FV77gp+PYIZ1RU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MVTeDBI5Zz6zcG8Ebsth6zDu6pmNx/dGRyHsoWOnuSOLaaJ7Tz+bUCZbDVjzeqEWv ZsxalzKYOCXVvM50Qedc06e2hpYHW7qoIKzwJY1tX30vi9gMccQSlMiXff7LZdz2++ 9MshRB0odBuJe2fwOTZVX/Tj2IOWOULDBvp7hwcj8YMxvW9VKvT3pYrIftvPBxfBPy sTKpmZcx7lNnqby+prQ7dTfnjcaGeuUfhSmVitGvhXA5Ga2Xtw/Gn+VOZwzkcfcrnc rkZwQi6oC6LhGgAwUHYQhSM0DOhN5QQ54FXzm1kaFcFBj3YRYdnxwvoXogwe8zkkmi 45OY60QF/9zSQ== Received: by mail-wm1-f51.google.com with SMTP id p15-20020a05600c358fb0290245467f26a4so257533wmq.0; Tue, 20 Jul 2021 12:58:51 -0700 (PDT) X-Gm-Message-State: AOAM532LqhNPdi9BIAf6CshLQYaLKF306s/D52UuXYHi1zfFZyYUqTwH ZIiVTCQcVF0hiDJrqvM3xmevT4Zs8d8xQwjhw/o= X-Received: by 2002:a1c:c90f:: with SMTP id f15mr123895wmb.142.1626811129717; Tue, 20 Jul 2021 12:58:49 -0700 (PDT) MIME-Version: 1.0 References: <20210708232522.3118208-1-ndesaulniers@google.com> <20210708232522.3118208-3-ndesaulniers@google.com> In-Reply-To: From: Arnd Bergmann Date: Tue, 20 Jul 2021 21:58:32 +0200 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: Linus Torvalds Cc: Masahiro Yamada , 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 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'. 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. Arnd