Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp141952ybh; Mon, 20 Jul 2020 12:29:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVRi7k90soan1i5KOEdvLLl0ov5BC5t3UX5sGVvsLgNUUXI+qbiFMfg/6BL/pUC6ALsvQ8 X-Received: by 2002:a05:6402:1d35:: with SMTP id dh21mr23586624edb.186.1595273354216; Mon, 20 Jul 2020 12:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595273354; cv=none; d=google.com; s=arc-20160816; b=vfSvRmcJswYFt3HOoBUNy2a8tUcDdlU4GV32gWTnxFJRcqMhf+qT56Dlhpx2o0M3wI ht95niymACYaL2PPvg45IjYBK7psdiLwE3MgA0ZdRPqnjYiDYfPeX6cJVjfPUvybl6MV 0JvwVpHwCfq+Vt39Z8A/0DomWPSo1skUsUgV7XdRQWDAN5+je+FAzTX80f6UT8HCM/wW mczqL2d04MkpN+OkLn+Fs8ibjiU06lvPsnHxO+NFFzLolf3/X2PcUSVun3XRQJBVepRg pn3n649afN8u+ZhgEqIVBJFKHbLLijTcZaWYUV3Tq+8d6SmaQN16sHtgjhNFepG1F+nb tYWQ== 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=qQtHutRKhkC0xmSMdXzm89kbzbrbZVJj4BoYmmxXY+o=; b=p8SaJVzNIiRZvl4gCluJa+bbX7KacauHCK5UdJesVEinfmZmIDrMZ7A0ud4nnYjLju YZaI3cOnY7QuKlrbJWD3dlw0omt4KYsw+RkDGb9YTUfJg07BcI9Dw8DXEaZU6HXJvYF6 ScS/35opm7jwR9Kv08E4fNUtV1eY4S6aghkCNILkOiKYrRJImG389hHzJ8MK6vlXmevR tjnwMt38V0/XdacRWTju0Z6obl1F0hQ+18wIctqfXK4kexP5DpIHm4Gt5BGLNe69MeS7 oc3iRhdFkpLe0dOHdzYsgsyvR3UunhoSJWEbLTstB1aWxKlk6luj0rNaPvUhtGbQVtll 6WlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=q87Rwtko; 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 di16si10995582edb.397.2020.07.20.12.28.50; Mon, 20 Jul 2020 12:29:14 -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=q87Rwtko; 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 S1730533AbgGTT2O (ORCPT + 99 others); Mon, 20 Jul 2020 15:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729092AbgGTT2N (ORCPT ); Mon, 20 Jul 2020 15:28:13 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4344FC0619D2 for ; Mon, 20 Jul 2020 12:28:13 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id n5so10761296pgf.7 for ; Mon, 20 Jul 2020 12:28:13 -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=qQtHutRKhkC0xmSMdXzm89kbzbrbZVJj4BoYmmxXY+o=; b=q87Rwtko9DSoJjwynLK7R/BbSPDvRnR8BKOcJLnYSKi7HHsC+P9x24MHhIT+0PEKHU tSHzBU5D6A+frU+7xj6EuBPWB12k7JDwWjz/R7tUIRNBOCKb+po5KsBqZPGKDStJLAIy 00BUhLT04M2DAcC8Mk2n74OuakYxuGpMPQrtIE6DHVJHgm3923LLTaCmGLJo6IdVkYqU lUQZVxs53zif0UeVOU+lNbuqUdduUfD/FvkALom69lTYsYXhEEni3R6gG9FJrIGnOYI2 J31lRErv7EtFsAY/Ew84JV3Jx5UUUC98nd5dc79NTQZr6aHijOoCgm1MPDRRbnDP9NRU xwkw== 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=qQtHutRKhkC0xmSMdXzm89kbzbrbZVJj4BoYmmxXY+o=; b=jWhWSCCbHWZyghuMK2n7/Irtf87CQaelG6o3d1LNNWZd+WbD7EWupGeV+ER9kmgHyu yiypRbaPnlh5kjhWvKqLqbTjoQmOrhPTSaSKZ6gjwphJaCJof6CHCFrQ+hmaBkhrXvTr jwEQvcuwb27rY6ip4Qzq/cLqXRrwWVTnDYSTkFHbgl0Az9YH7ZpAPgl7TuS62PxhqfUW GS/tB4ty93gzBHZ4qsiazYd2wPRTLYvkBs5T13tp/gHAHgh2JysZO/8uATTBI3RKyRsQ x+kzTfn/215BDlGYBD73x6JDWRoQ1gQnlT5qlyRYNVtFFcZmQU43TUE/fQJOXMKPLuUY NFsw== X-Gm-Message-State: AOAM5338rDel+TXmkYo6X3tOBqjwHYLbsmauE5Sq4lw9r7PJVxqCbbr8 0XXE732zqUi86rI0Wn9MIyzHO9Wyw+xqi5GVeGOtyA== X-Received: by 2002:a62:86cc:: with SMTP id x195mr20778276pfd.39.1595273292322; Mon, 20 Jul 2020 12:28:12 -0700 (PDT) MIME-Version: 1.0 References: <20200720181237.3015826-1-maskray@google.com> <20200720181646.GA6160@ubuntu-n2-xlarge-x86> In-Reply-To: <20200720181646.GA6160@ubuntu-n2-xlarge-x86> From: Nick Desaulniers Date: Mon, 20 Jul 2020 12:28:01 -0700 Message-ID: Subject: Re: [PATCH] Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang cross compilation To: Fangrui Song Cc: Masahiro Yamada , Michal Marek , Linux Kbuild mailing list , LKML , clang-built-linux , Nathan Chancellor , Manoj Gupta , Jian Cai , Bill Wendling 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 Mon, Jul 20, 2020 at 11:16 AM Nathan Chancellor wrote: > > On Mon, Jul 20, 2020 at 11:12:22AM -0700, Fangrui Song wrote: > > When CROSS_COMPILE is set (e.g. aarch64-linux-gnu-), if > > $(CROSS_COMPILE)elfedit is found at /usr/bin/aarch64-linux-gnu-, > > GCC_TOOLCHAIN_DIR will be set to /usr/bin/. --prefix= will be set to > > /usr/bin/ and Clang as of 11 will search for both > > $(prefix)aarch64-linux-gnu-$needle and $(prefix)$needle. > > > > GCC searchs for $(prefix)aarch64-linux-gnu/$version/$needle, > > $(prefix)aarch64-linux-gnu/$needle and $(prefix)$needle. In practice, > > $(prefix)aarch64-linux-gnu/$needle rarely contains executables. > > > > To better model how GCC's -B/--prefix takes in effect in practice, newer > > Clang only searches for $(prefix)$needle and for example it will find "newer Clang" requires the reader to recall that "Clang as of 11" was the previous frame of reference. I think it would be clearer to: 1. call of clang-12 as having a difference in behavior. 2. explicitly link to the commit, ie: Link: https://github.com/llvm/llvm-project/commit/3452a0d8c17f7166f479706b293caf6ac76ffd90 > > /usr/bin/as instead of /usr/bin/aarch64-linux-gnu-as. That's a common source of pain (for example, when cross compiling without having the proper cross binutils installed, it's common to get spooky errors about unsupported configs or host binutils not recognizing flags specific to cross building). /usr/bin/as: unrecognized option '-EL' being the most common. So in that case, I'm actually very happy with the llvm change if it solves that particularly common pain point. > > > > Set --prefix= to $(GCC_TOOLCHAIN_DIR)$(CROSS_COMPILE) > > (/usr/bin/aarch64-linux-gnu-) so that newer Clang can find the > > appropriate cross compiling GNU as (when -no-integrated-as is in > > effect). > > > > Signed-off-by: Nathan Chancellor > > Signed-off-by: Fangrui Song > > Link: https://github.com/ClangBuiltLinux/linux/issues/1099 > > Sorry that I did not pay attention before but this needs > > Cc: stable@vger.kernel.org Agreed. This change to llvm will blow up all of our CI jobs that cross compile if not backported to stable. > > in the body so that it gets automatically backported into all of our > stable branches. I am not sure if Masahiro is okay with adding that > after the fact or if he will want a v2. > > I am fine with having my signed-off-by on the patch but I did not really > do much :) I am fine with having that downgraded to Not a big deal, but there's only really two cases I can think of where it's appropriate to attach someone else's "SOB" to a patch: 1. It's their patch that you're resending on their behalf, possibly as part of a larger series. 2. You're a maintainer, and...well I guess that's also case 1 above. Reported-by is more appropriate, and you can include the tags collected from this thread. Please ping me internally for help sending a v2, if needed. > > Reviewed-by: Nathan Chancellor > Tested-by: Nathan Chancellor I tested with this llvm pre- and post- https://github.com/llvm/llvm-project/commit/3452a0d8c17f7166f479706b293caf6ac76ffd90. I also tested downstream Android kernel builds with 3452a0d8c17f7166f479706b293caf6ac76ffd90. Builds that don't make use of CROSS_COMPILE (native host targets) are obviously unaffected. We might see this issue pop up a few more times internally if the patch isn't picked up by stable, or if those downstream kernel trees don't rebase on stable kernel trees as often as they refresh their toolchain. Tested-by: Nick Desaulniers > > if people find it odd. > > Thanks for sending this along! > > Cheers, > Nathan > > > --- > > Makefile | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/Makefile b/Makefile > > index 0b5f8538bde5..3ac83e375b61 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -567,7 +567,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) > > ifneq ($(CROSS_COMPILE),) > > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > > -CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) > > +CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(CROSS_COMPILE) > > GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > > endif > > ifneq ($(GCC_TOOLCHAIN),) > > -- > > 2.28.0.rc0.105.gf9edc3c819-goog > > > > -- -- Thanks, ~Nick Desaulniers