Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp914485ybh; Tue, 21 Jul 2020 10:57:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLGrYs5gVX22GjG9KomxaJaxTan7B6euzhfOwH1JTY8Q6i34DycMgqr3rvrSOIinVqUHHk X-Received: by 2002:a17:906:408c:: with SMTP id u12mr25612511ejj.162.1595354255158; Tue, 21 Jul 2020 10:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595354255; cv=none; d=google.com; s=arc-20160816; b=D0b84fsILb4PI2XLSeViAz7sWhsbCazmQPZqMkMqKYSnQRXzCX1e78ujYKAK2oQUK8 LwijL9XK9ejb8Duo83OjY4bKoLuhaytZSX1aD1Qrk3MHefI76G4GM7lwWiNJMIjo5pg4 ElFCDfuWtyreg52hVnYBSJbTDGjLB7mDRyWCF2D3FbfrAofzA5fMsMcjFaINv2Wl56ks QCTxxFiRXaEocxkY/QlDN8quIQLXZ2kx/A0zVBP27MZptlPsWSdn9v/IJ/2w4fp57X4t 8NTO45TGue/6kg09p5Tb4IkPaC5HdXLr1ZvOKkLxhnzqhT1QJ28vjpdzxweL0T+kRDJq DHlQ== 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=jzIH5N8X89auq1yzOeN+/XIVI9FfDEkSMipXnUL9KwI=; b=fW/dMXzpGVz1IoaeXAQkxeQOyvpQ4/XcZFa0OutGf8aUbRJxXuOKqepuBx1zDbWhd9 MJ9pVyBgIua5RQCZhKSqzz/m01BrpOKH/kMILNC8CCruN5HzHEXGX9Cppf1kDUJY/b18 tml0wW/GyxkHS6VCLwe3YPgatdK1DzKFmJc146ABqBUo++9D8xOTZwQmi1ykauWdWYkA h+tr6NaHt/hF5ScGBhHlC6e1WkAB0N62bpeZI9W5MPeto4RuHBlzrrvbna8787Xfi8mU 3EIyuj/sv7FlPX5JAxi6bcrsyoO32bIk390yLFvKf3/009ssb1aDvFKRtHcYici5rJlZ K6pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=K2vAwTSi; 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 n14si8591981eji.489.2020.07.21.10.57.11; Tue, 21 Jul 2020 10:57:35 -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=K2vAwTSi; 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 S1729314AbgGUR4D (ORCPT + 99 others); Tue, 21 Jul 2020 13:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729226AbgGUR4D (ORCPT ); Tue, 21 Jul 2020 13:56:03 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFCF0C0619DB for ; Tue, 21 Jul 2020 10:56:02 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id a24so11080162pfc.10 for ; Tue, 21 Jul 2020 10:56:02 -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=jzIH5N8X89auq1yzOeN+/XIVI9FfDEkSMipXnUL9KwI=; b=K2vAwTSirJJQPZG/CYaqut1fiZefV7wpVLDUtpTY0a0OD4d6BfcTvOSfiZ8AGVfkwt oEbEBxsKFM4JtoIJiiV0D9UjHTn1jHYQ0sqzypvamxqa5HNnw/zjsVmSq3ztmZ/np9Q6 TrXqEpW00t8D8nTQFNc5xmFBygK3rPi+wGeEu2H4S4HhhNEcvX7lNta53rW7f1pxdL7A pGi98fo49S30iAzg1eT5+5fIQ/AkUXyBUAWa+8uQVwCL3wavkoSIbxWQkAixjIuBb2ps p5bawOd5RpRWRdEy3gU1Y6S4CeA2vTjbzYnpMuDUydTMZTZDMmgF4mGf8KniQoJrNqZI IPkA== 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=jzIH5N8X89auq1yzOeN+/XIVI9FfDEkSMipXnUL9KwI=; b=k9P+Tasy5cojYrZVLokoMvtblFSe0HZMfK2VyOIMvOmFBXJ8ZduwdqOLc5kBtZWIec fW5uDmPE1UhZoa0jM8rHAxLXRtEjCg/jd3FfjXeR9I8pKbWlpTNp7zeeWtVt8pj26Nw6 ZmXJUvvXbFybMwAyueSuL3U1QaeJ0IjPekVNz7XWEraDMQd82C2P8C+NiN7nenI41xWy JV7WhKKG590GydEevv2H2ONhwu+p02dovf5LHVFENexBdZAFW/gaMztf4B88110oCqKz iSPN9MJOck1Bl/AVTFJkegRNCiRNeGjszo/EogbbsYOg9FsJAmbxUM9sz+/bZbLXtYrn NiwA== X-Gm-Message-State: AOAM531slQ9qVfC1hcB52wvcdKB76SDWTm7/hi+1oIwJfU5bEu0gP3Jc KpgFFw91TZ0aVaAI1UCh0Z5NcjMQz7F73RQBQZLs9BFT X-Received: by 2002:aa7:84d7:: with SMTP id x23mr4452563pfn.169.1595354161941; Tue, 21 Jul 2020 10:56:01 -0700 (PDT) MIME-Version: 1.0 References: <20200721173125.1273884-1-maskray@google.com> In-Reply-To: <20200721173125.1273884-1-maskray@google.com> From: Nick Desaulniers Date: Tue, 21 Jul 2020 10:55:50 -0700 Message-ID: Subject: Re: [PATCH v3] 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 , Jian Cai , Bill Wendling , Manoj Gupta , "# 3.4.x" , Nathan Chancellor 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, Jul 21, 2020 at 10:31 AM 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-elfedit, > 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 (since > https://github.com/llvm/llvm-project/commit/3452a0d8c17f7166f479706b293caf6ac76ffd90) > only searches for $(prefix)$needle. Currently it will find /usr/bin/as > instead of /usr/bin/aarch64-linux-gnu-as. > > 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). > > Cc: stable@vger.kernel.org > Reported-by: Nathan Chancellor > Signed-off-by: Fangrui Song > Reviewed-by: Nathan Chancellor > Tested-by: Nathan Chancellor > Tested-by: Nick Desaulniers Reviewed-by: Nick Desaulniers > Link: https://github.com/ClangBuiltLinux/linux/issues/1099 > --- > Changes in v2: > * Updated description to add tags and the llvm-project commit link. > * Fixed a typo. > > Changes in v3: > * Add Cc: stable@vger.kernel.org > --- > 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