Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4678310imm; Mon, 17 Sep 2018 19:32:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbouBkl5tO1CuI/Q+t+vFUT0zZpJqxkwTG51Cke1FcLBzi2WuCfvZAZbJBnxg24yjaJgbw8 X-Received: by 2002:a63:10c:: with SMTP id 12-v6mr25461049pgb.62.1537237949786; Mon, 17 Sep 2018 19:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537237949; cv=none; d=google.com; s=arc-20160816; b=Lw/lpHeTaPcN7tzXSvgR1vp4n5jBr/8sU71yNnGNCoPDxZJhXPKC+CQ/wkJd5AzmZM uHo8g1G8siS0fMQ94iQdJzraz1AMsFfwWrxWh5nXYMyktIxCUoDFH5fs4n4ieustCRcx 51Y2loPYBg2WQlun7MInRB5TV0jXAhXeL43MYM7cgvkILOCBG3gqBuoD2oL2YEnDV6JT ntprkb80f/x4VclhvHFVz7MDvW6Nrq4MRqbOvkFSAQm56wEDEfuHE6C8Id3CFkxaja0K KCWQI62Y03kdYF+jGwdQXOqguCmcLBURV/7m1WIwwJMmm/mj977wcaZ1dDXk0GHPbCf4 CQLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Qi8Ccmt0r7+/9ZfBFG1S0C59VGKyxUMlJg4TnVziE3Q=; b=YHifh6s1UkJXxYoF8FNgUMzyBHPdSNRNhOIrkPEsGwhjU3Ya9ttvoyLKKJ9xlCp7DS kDpCmU318fgsR5KLTecqd9B4Ii/x1vEianCkWqNqRUgha5rTD2daBQksXumjZxuLQcYp JPo+BJkMGhzcv8h7l8cJxEWtmkRsHBVQynoGLfJ6aj1E9G5FesHeihC611l1FEeF46sC cwx9A1Ge0Q+vIAyE+xgP3eUUVknYaJEKVrMN80oqUaBdu6A6KyEjNFQUGrOY9iTWe7km exAauSduG/N6ULSa15nXJV8jVSPR0W2gN9VLFo4NwTC+48G6hOHQ6h9QJJ9Lx23hgMn2 tptw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=NUen7gI6; 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 x22-v6si16637678pfh.84.2018.09.17.19.32.13; Mon, 17 Sep 2018 19:32:29 -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=NUen7gI6; 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 S1727200AbeIRICX (ORCPT + 99 others); Tue, 18 Sep 2018 04:02:23 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:33262 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbeIRICW (ORCPT ); Tue, 18 Sep 2018 04:02:22 -0400 Received: from localhost.localdomain (unknown [24.87.206.252]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 747D65C045D; Tue, 18 Sep 2018 04:32:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1537237926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=Qi8Ccmt0r7+/9ZfBFG1S0C59VGKyxUMlJg4TnVziE3Q=; b=NUen7gI6/465+gp2OlGdeI2waN+dAYjmF1Pt5553iJfClIURjb8AHmZqsqWreyhk6SxrXV myejhP7X64Wq4yIR/KtKOWBAFeeQAbH5mM55we+b7wfbInKHywAe0pTKRrrn58GIyTPqaH Rdpp9RN37DlH+X0vSdSZR+Nwk4mFTwo= From: Stefan Agner To: yamada.masahiro@socionext.com, michal.lkml@markovi.net Cc: ndesaulniers@google.com, arnd@arndb.de, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Agner Subject: [PATCH] kbuild: allow to use GCC toolchain not in Clang search path Date: Mon, 17 Sep 2018 19:31:57 -0700 Message-Id: <20180918023157.23951-1-stefan@agner.ch> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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