Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4702825imm; Mon, 17 Sep 2018 20:11:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdacXkt9dCnZK6YttmWTp92hY68F1n/O6HWnyQT5h49Be+suFh1k1ZtoCb06/YuZKUMsAFQk X-Received: by 2002:a63:9f19:: with SMTP id g25-v6mr26472276pge.39.1537240314823; Mon, 17 Sep 2018 20:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537240314; cv=none; d=google.com; s=arc-20160816; b=IssRbZYWQeg6AWzc/9JG8Wkr+9Wk+N776nfeI5v9iZ7OI3AQDQIfD0+lQe4gX1Dl9w /5wngs9iNNz8UaEkHzuQoyAKPbQf7B6V4MPalf8S8K7fOXZsURnS13iJlT7tRa4ju3SM GWRsr4T+h6QLZX/KBEA/yBtiiOl9QUd8uKKjaFuOTAqU9kKpVw/Sn0RqD16iYNfsukWc phEPJpXseQmT4tXwow+yBBDkj5adH66DRKmDN/GGJWtMXjlCMD6LdIAgBcX8geoNnsu0 yQN0qfYEafYgQ4CocLibmd8VxBRXhjZkI9vjA5OT7TEmpNgM6ws+Fk7j906UwmFtC1K+ QXbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=X2tLV6SYZVQXTTN+sxElDRLhxwYJAer6ny7FcOZAFOI=; b=n7sBjQrs3dw7djthsQa2Ko+Fa5yh9Pl/LD+B28l6lIEISIg1fIAfZqUnErFiLTYQ56 SKkhcGo58zr/9pmy/0Eh1sCZT4dJYlp3E8B5RmIHTjEVZFhN4PAijMujnzMV7X4A+ae9 dYPgvC4rWFSxonUAKzwJZya6u4cZbwiWG23ozgrFzPsm+LJAhI2z0V9AboFpR+LA/Qti tM6nIzTGUzKBxNeyPWn35LnurSddERVmSM0MIJejr0NOmiff9q/JQnd478NTyO9dsqJ6 huNNtnYeDgC8fqZdPn6MqrLPGlChDNYmWSHbJ3qm74yIz5753RUTFpskMbY2ybhFZ2hP i7UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=Wlb3trhV; 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 d128-v6si18681028pfc.211.2018.09.17.20.11.39; Mon, 17 Sep 2018 20:11:54 -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=@agner.ch header.s=dkim header.b=Wlb3trhV; 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 S1727070AbeIRIl5 (ORCPT + 99 others); Tue, 18 Sep 2018 04:41:57 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:33536 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbeIRIl5 (ORCPT ); Tue, 18 Sep 2018 04:41:57 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 112FA5C05D1; Tue, 18 Sep 2018 05:11:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1537240286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X2tLV6SYZVQXTTN+sxElDRLhxwYJAer6ny7FcOZAFOI=; b=Wlb3trhVxtQrC5HvyPNhBCtw3VWhlGCWBfP7fY7mJmFjpi18GWCVlg80m0T6rxyUWhTFFv 7pF5JJXOhrwClTrGcPpnJ2i3P+5Hb+ff73aEAteiH/Hmaepw72jQpVVxK5YBQfO7jHDKNS F4H4b4M1BAzzeuDfsDVPdkfdlI4+tZA= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Mon, 17 Sep 2018 20:11:26 -0700 From: Stefan Agner To: Masahiro Yamada Cc: Michal Marek , Nick Desaulniers , Arnd Bergmann , Linux Kbuild mailing list , Linux Kernel Mailing List Subject: Re: [PATCH] kbuild: allow to use GCC toolchain not in Clang search path In-Reply-To: References: <20180918023157.23951-1-stefan@agner.ch> Message-ID: X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17.09.2018 20:06, Masahiro Yamada wrote: > Hi Stefan, > > 2018-09-18 11:31 GMT+09:00 Stefan Agner : >> 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. > > > The current code passes the absolute path of toolchains > to --gcc-toolchain option. > In my understanding, this is enough for Clang > to find the proper linker and the assembler. > > > Why is the --prefix option also needed ? > It seems that Clang makes a difference between "toolchain" and search path for toolchain binaries. Without this patch building fails for the described use case, see the github link for more context. -- Stefan > > Am I missing something? > > > >> 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. >> >> 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... >> >> 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) >> +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 >>