Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp854943imm; Wed, 19 Sep 2018 07:59:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ0z8hciwZskmDHoLDX+tRFQ/aPy8DCWAO4rBzV0H3mQctWVnwuSXxdQNUR93X47e2aMzAj X-Received: by 2002:a65:65c6:: with SMTP id y6-v6mr33291322pgv.436.1537369145312; Wed, 19 Sep 2018 07:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537369145; cv=none; d=google.com; s=arc-20160816; b=ErVcaRPNeW1To404ANzpSPaW25BHQPVLQTdnYHgMkyntGIM8Ajx2+oLkWJFvd8awJU RD5VD+vnGs/P7pU8JsL5P9OH8r0mSLcXIJ6hQP2+5AUINN4f+X8X/WO2Okgcz0Lku54O bis69cpv2VIbrbQPltsbZw6Hvn7vw55so7ph6DoTSTrzC7HSwRW8TffYSWU5Kefnjv43 smTSGcFFhKmpZQx2hsgxry1dI/Gr1jiFS9N04RW22eHS37V8fGUqa9haO/f3hntVKnp5 5hFT26KOOZgmGj4XACROvp8cMdJyd+0IIxhd51LwXunoqk+CjaMck8qwgQ9SFTKwIxnZ ++cw== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-filter; bh=dtUG84h5nZgiuksyt6J7DnZ3wXMHYQqz9KcmN1398X0=; b=Bp19OL5VrNzRLX/fbFI/vjcEBZCQbjjmugEzc5sEkctdRgMUgQGwnFqsUbznr8QxO5 J20PKrxd1OjrOIgpERxSioyhb67XKA0O7wVoCzqBs674cnyqAN/lJC+dkQIzkW1O6Jx2 V11vRVHqdoJtfU0qK9ZyNbPYfAW3zUZkw1sAtdqpIIN3R5lEyvyKvOa/Yi5Lw9Vc+GDe pYJAgrREoiAaibJXUgbMuobXU6TGRsnmOiFYGWwsBVOxV0NIbTsq2YUNQp9EO79mluSd qZxmF6+XIiodVK0doOaFpDN+AZj+nhuUEzLAjQOtrsFBnuw9lt3k8L5KX+mac+f/N7o2 iCnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=vIlgq66v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6-v6si21239382plp.434.2018.09.19.07.58.49; Wed, 19 Sep 2018 07:59:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=vIlgq66v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732317AbeISUga (ORCPT + 99 others); Wed, 19 Sep 2018 16:36:30 -0400 Received: from conssluserg-06.nifty.com ([210.131.2.91]:49838 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732079AbeISUga (ORCPT ); Wed, 19 Sep 2018 16:36:30 -0400 Received: from mail-vk1-f179.google.com (mail-vk1-f179.google.com [209.85.221.179]) (authenticated) by conssluserg-06.nifty.com with ESMTP id w8JEvlck013213; Wed, 19 Sep 2018 23:57:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com w8JEvlck013213 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1537369067; bh=dtUG84h5nZgiuksyt6J7DnZ3wXMHYQqz9KcmN1398X0=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=vIlgq66vblFzmZDoDSJ3BTMD5q5egMsePfNQzi5luv09BlFpAbMJZ1GsRyCisfUDG yFfMbirVSQX6LqUX0rLkTp+dtguCXLyujANhV5NVW4WJov2Y8a0G91m+I5sdAsCxNu 8AiwoYxQMhcNwMAdTCdV56PCu1S2iyAQ3JbGHzrFUTh099xVO8fXync0/iaxMedzvv u3J+LQ+nunNqkwJfjOgIZm2zDhrVxRLPbwfyCltRCMEO2ro5MzgGOUzSlVFONw15kx xcFQAnPAEhLLs/nZ2waRkcVWCg/EuXt9J3XpVlBpvbER2cO2MvBwhD0HfgVaZus+za uurYsN5kbZDpw== X-Nifty-SrcIP: [209.85.221.179] Received: by mail-vk1-f179.google.com with SMTP id s17-v6so1193647vke.10; Wed, 19 Sep 2018 07:57:47 -0700 (PDT) X-Gm-Message-State: APzg51Aefv3sgc3B2AxTP+FJOF428nHsZosSv/vmVJAr2DtvrsfP2UE/ iVNCfuA0T+vaDgCy4Qe0x5xFTcyGDp94a0d3L9Y= X-Received: by 2002:a1f:328a:: with SMTP id y132-v6mr8973221vky.84.1537369066365; Wed, 19 Sep 2018 07:57:46 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:7111:0:0:0:0:0 with HTTP; Wed, 19 Sep 2018 07:57:05 -0700 (PDT) In-Reply-To: References: <20180918023157.23951-1-stefan@agner.ch> From: Masahiro Yamada Date: Wed, 19 Sep 2018 23:57:05 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: allow to use GCC toolchain not in Clang search path To: Nick Desaulniers Cc: Stefan Agner , Michal Marek , Arnd Bergmann , Linux Kbuild mailing list , LKML , Stephen Hines 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 2018-09-19 2:16 GMT+09:00 Nick Desaulniers : > On Mon, Sep 17, 2018 at 7:32 PM Stefan Agner wrote: >> >> When using a GCC cross toolchain which is not in a compiled in >> Clang search path, Clang reverts to the system assembler and >> linker. This leads to assembler or linker errors, depending on >> which tool is first used for a given architecture. >> >> It seems that Clang is not searching $PATH for a matching >> assembler or linker. > > Yes, Clang uses what's called a sysroot, which is meant to be more > hygenic than $PATH, IIUC. This is surprising to folks familiar with > $PATH, but really helps include the correct headers and use the > correct toolchain when cross compiling, at the cost of freedom to put > the cross toolchain wherever in the filesystem. (this is my > understanding of sysroot, I just learned about it yesterday, so take > this with a grain of salt). > >> >> Make sure that Clang picks up the correct assembler or linker by >> passing the cross compilers bin directory as search path. >> >> This allows to use Clang provided by distributions with GCC >> toolchains not in /usr/bin. > > IIUC, its just utilities in binutils we're using (as, bfd.ld, > objcopy), not GCC, but maybe that's just being pedantic. > >> >> Link: https://github.com/ClangBuiltLinux/linux/issues/78 >> Signed-off-by: Stefan Agner >> --- >> Nick, I removed your Reviewed-by since I had to change variable >> assignment slightly... > > Yes, thank you, that's the right thing to do. > >> >> Makefile | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/Makefile b/Makefile >> index 4d5c883a98e5..d5de2db4b549 100644 >> --- a/Makefile >> +++ b/Makefile >> @@ -495,13 +495,15 @@ endif >> ifeq ($(cc-name),clang) >> ifneq ($(CROSS_COMPILE),) >> CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%)) >> -GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..) >> +GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD))) >> +CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR) > > Yep: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-b-dir > >> +GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) >> endif >> ifneq ($(GCC_TOOLCHAIN),) >> CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN) >> endif >> -KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) >> -KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) >> +KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) >> +KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) >> KBUILD_CFLAGS += $(call cc-option, -no-integrated-as) >> KBUILD_AFLAGS += $(call cc-option, -no-integrated-as) >> endif >> -- >> 2.19.0 >> > > Thanks for this patch Stefan. > Reviewed-and-tested-by: Nick Desaulniers > -- > Thanks, > ~Nick Desaulniers Applied to linux-kbuild/fixes. Thanks! -- Best Regards Masahiro Yamada